Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Fwd: Completion confusion around the _arguments -A flag
- X-seq: zsh-users 23533
- From: Mal Graty <mal@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Fwd: Completion confusion around the _arguments -A flag
- Date: Sun, 22 Jul 2018 16:16:23 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=idio-ai.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=PUuXEhVOKGkpRDLLwYYCbh3KJItFLfPFXL3V6VNGCCI=; b=bPYsOgXVT8npq2FBmzL8WsqGRXFHQTVq8hn9aYNJd9W1chtt6kBoJRJRFoTtBXQvuM OlrudY90RuyNSyBM9hPcruMthtTDcORABIGGnuOVCq2PRk4Aiv6sFtIJdRBm9azbZ5Ho ooYxnPzYYRTdU/xYhqNaML1w/3j+Z8tUgVHXG5k44mWpCS6LZVkjyaruodtezMD3NB3D 4uqVR2rHVb27LZsfC0k1yCLmOx4oai5nnDFiZdPe8+L+wLYaB6I714ZJSwF34JUGk8Cg DeBYf7Ebv868javKEHSih7/g6G9NITU5GI2Ar2fJ7irX3VjR5w2KXddj0Wq9jSKooI5A ZWNg==
- In-reply-to: <CAJCae=CUioiTBB8wc8vpzYii3_5T3VJjzqAOekKvRs=-=kVLWQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAJCae=CUioiTBB8wc8vpzYii3_5T3VJjzqAOekKvRs=-=kVLWQ@mail.gmail.com>
I have a binary (call it foo) with two, mutually exclusive, optional flags
(that must come first) and a required arg. The problem I'm having is that
when omitting both flags and using just the arg the completion tries to add
one of the flags after it. Reading the docs lead me to the -A flag, however
it doesn't seem to be preventing the flag completion despite being after
the first arg. I'm hoping I've just overlooked something but for the life
of me I can't see it.
Command structure:
foo [--name|--software] <node>
Current completion code:
#compdef foo
_nodes() {
compadd $(get_node_list)
}
local curcontext="$curcontext" state state_descr line
typeset -A opt_args
local rc=1
_arguments -A '-*' \
'(--name --software)'{--name,--software} \
'1: :_nodes' \
&& rc=0
return rc
Examples:
foo <TAB> #=> GOOD: nodelist
foo -<TAB> #=> GOOD: --name --software
foo --name <TAB> #=> GOOD: nodelist
foo --name -<TAB> #=> GOOD: nothing
foo --software <TAB> #=> GOOD: nodelist
foo --software -<TAB> #=> GOOD: nothing
foo node <TAB> #=> BAD: --name --software, expect nothing
foo node -<TAB> #=> BAD: --name --software, expect nothing
Any assistance to solve this issue would be massively appreciated!
Many thanks,
Mal
Messages sorted by:
Reverse Date,
Date,
Thread,
Author