Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Setting state in _arguments
- X-seq: zsh-users 17570
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Setting state in _arguments
- Date: Wed, 16 Jan 2013 10:47:09 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=7r7RPDhVOBzOVixTLuC4WGC7hoTwSbDZLXGMWQ+iQsM=; b=MAbZgwm4a0hU1+g00RBEHwIhQs8Orn8lSUR1S33N6kev54AFu1ovmrVEs+Hl/gfgOl 8Ec1ctex5oI/Un+1Bc8xnUyfTkapcC6c8rc8hYsDHcOjQyOKTIBQ6IK/hk492ml0dy7n a4DibN+HJirDJDVapZI/OQmKn0z1clCDb2R0UAZQZqr5alDPtaKYYyQWU3GjBkTFW6SZ 3Ff71/Ki+Zv6Wd5WkkhpdQTnA6PSVQ4HCHqLu47nLLUevv76kPOzzSLN0qXi/vgj1YbE rfe6Fo0IbexuJaQnsp4IQTWsbn67HcCULTiCXz3oZgp+CLJQl62sprz337JgHs2S+RCP slHA==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
I am trying to improve the completion for the gradle command, and have run
into something I cannot explain. To simplify things as much as possible, I
have constructed this example file, calling it _myfoo:
#compdef myfoo
local curcontext="$curcontext" ret=1 state
_arguments -C \
'--option1' \
'--option2' \
'*:a subcommand:->subcommand' \
&& ret=0
if [[ -n $state ]]; then
print state: $state > /dev/pty2
fi
return ret
On the command line, I write: "myfoo --<tab>", and the completion kicks in
and gives me the options "--option1" and "--option2", which is what I
expected. However, on /dev/pty2 I see "state: subcommand", which I did NOT
expect. I would have thought that since only "--option1" or "--option2"
could possibly match after "--", state would not have been set*, *but it is.
The trouble with this is that in the gradle completion, the possible
subcommands are generated inside the if statement in this case, and thatis
time consuming. I would thus like to avoid going into it when the "--" on
the command line indicates that an option should be completed.
I would have thought that the call to _arguments did not set state since
found some matching options, but obviously I am using it incorrectly. What
should I do instead?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author