From: Mal Graty <mal@idio.ai>
To: zsh-users@zsh.org
Subject: Fwd: Completion confusion around the _arguments -A flag
Date: Sun, 22 Jul 2018 16:16:23 +0100 [thread overview]
Message-ID: <CAJCae=DDuU=pGpeG7x6L-v5k7ftw0MJbp-CF6_C2E_n4e_fXvg@mail.gmail.com> (raw)
In-Reply-To: <CAJCae=CUioiTBB8wc8vpzYii3_5T3VJjzqAOekKvRs=-=kVLWQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
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
next parent reply other threads:[~2018-07-22 15:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAJCae=CUioiTBB8wc8vpzYii3_5T3VJjzqAOekKvRs=-=kVLWQ@mail.gmail.com>
2018-07-22 15:16 ` Mal Graty [this message]
2018-07-25 16:36 ` dana
2018-07-27 17:05 ` Mal Graty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJCae=DDuU=pGpeG7x6L-v5k7ftw0MJbp-CF6_C2E_n4e_fXvg@mail.gmail.com' \
--to=mal@idio.ai \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).