Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Completion using state-machine
- X-seq: zsh-users 12515
- From: "Marco Lombardi" <marco.lombardi@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Completion using state-machine
- Date: Thu, 31 Jan 2008 11:28:55 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=brxEGb0v3Ija2sTifCWwPb+yqcTFY+XYPnVjehfxMgc=; b=UErJb61RYUFg8MkC1tkLQt2boDndEssvmFwWoE2fBZt7PD7CBVNCmxzqXFjCCIgJ38WywAQQDFu/iGSSDQWTDsTO/kpSZmRNtcsCRTHHYIKpmBZLiNZWQRtmPB09y2zAaa8oy9/qV/OS3TAXPnUbvA76xC3FtjNP5J11RjHdfgk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Eqrw0OZNOPXIgCR9jA5TDafX/z0eKyKbHTp68eHvKHMxbL3KpaLTkg2gpErMnAqavK7bURQ7/4RpfRsSs1oL/8+VCUV0hdKtWzMSAPl6u8uykFY5nT6+bxaEjvxXI3fXKfdjwlu0PLat4cGYyR3nEs3Ie6pkXyRYJWcQ9t/SoYs=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
Dear all,
I need to write completion code for a complex program that can accept
different kind of arguments depending on what is already present on
the command line. To make an short example, consider the following
specifications
{-v,--verbose} - increase verbosity of messages, can be used up to three times
{-s,--simple} - simple flag, can be used only once in the whole line
{-p,--path}=PATH - specify a directory (e.g., _files -/) for following commands
{--parameter}=PAR - set some specific parameter, can be used once for
a specified path
Note that while --simple can be used only once in the whole line,
--parameter=PAR can be used many times for differeht --path's. For
example, the following command line is acceptable
command -vv --parameter=1 -p /tmp --parameter=2 --simple
--path=${HOME} --parameter=3
To implement this I would be tempted to use _arguments with the ->
action, which in principle would let me implement a full
state-machine. However, although I spent the last few days in trying
to understand how to use the possibilities offered by the -> and the
$state variable to do what I need to. I would appreciate then a
simple code example to implement the example I just provided.
Many thanks,
Marco Lombardi
Messages sorted by:
Reverse Date,
Date,
Thread,
Author