* Fwd: Completion confusion around the _arguments -A flag [not found] <CAJCae=CUioiTBB8wc8vpzYii3_5T3VJjzqAOekKvRs=-=kVLWQ@mail.gmail.com> @ 2018-07-22 15:16 ` Mal Graty 2018-07-25 16:36 ` dana 0 siblings, 1 reply; 3+ messages in thread From: Mal Graty @ 2018-07-22 15:16 UTC (permalink / raw) To: zsh-users [-- 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Completion confusion around the _arguments -A flag 2018-07-22 15:16 ` Fwd: Completion confusion around the _arguments -A flag Mal Graty @ 2018-07-25 16:36 ` dana 2018-07-27 17:05 ` Mal Graty 0 siblings, 1 reply; 3+ messages in thread From: dana @ 2018-07-25 16:36 UTC (permalink / raw) To: Mal Graty; +Cc: zsh-users On 22 Jul 2018, at 10:16, Mal Graty <mal@idio.ai> wrote: >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. For whatever it's worth, i don't see anything obviously wrong with your function, and it works fine when i test it on 5.5. Maybe you have an option enabled that changes the behaviour, idk dana ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Completion confusion around the _arguments -A flag 2018-07-25 16:36 ` dana @ 2018-07-27 17:05 ` Mal Graty 0 siblings, 0 replies; 3+ messages in thread From: Mal Graty @ 2018-07-27 17:05 UTC (permalink / raw) To: dana; +Cc: zsh-users [-- Attachment #1: Type: text/plain, Size: 1056 bytes --] Thanks Dana For reference, in case it rings a bell for anyone, I'm seeing this on a vanilla Ubuntu 18.04 install. I'll have a poke around for anything that might be altering default behaviour though, thanks for confirming I'm not mad :) On 25 July 2018 at 17:36, dana <dana@dana.is> wrote: > On 22 Jul 2018, at 10:16, Mal Graty <mal@idio.ai> wrote: > >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. > > For whatever it's worth, i don't see anything obviously wrong with your > function, and it works fine when i test it on 5.5. Maybe you have an option > enabled that changes the behaviour, idk > > dana > > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-27 17:05 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CAJCae=CUioiTBB8wc8vpzYii3_5T3VJjzqAOekKvRs=-=kVLWQ@mail.gmail.com> 2018-07-22 15:16 ` Fwd: Completion confusion around the _arguments -A flag Mal Graty 2018-07-25 16:36 ` dana 2018-07-27 17:05 ` Mal Graty
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).