Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug-or-feature - different completion context after "--option VALUE" vs "--option=VALUE"



On Wed, Jul 20, 2022 at 9:19 PM Pavol Juhas <pavol.juhas@xxxxxxxxx> wrote:
>
> _arguments : \
>     - name \
>     '--name=[name of a person]:person-name:()' \
>     '1:letters:(a b c)' \
>     - without-name \
>     '*:digits:(1 2 3)' \
>     ;

The "sets of arguments" notation has always been a bit tricky.  Oliver
may have some insight here.  I think the problem is that because the
without-name set has ONLY a catch-all, it is always the preferred
context, that is, when parsing the command line to see which set is
present, the without-name set is always chosen.  The sets aren't
necessarily matched and made mutually exclusive in the order they
appear.

I would suggest instead that you use the explicit exclusion notation:

_arguments : \
  '(*)--name=[name of a person]:person-name' \
  '1:letters:(a b c)' \
  '*:digits:(1 2 3)'

Something interesting is going on when you append ':()' to the --name
spec, and I don't know if that's intentional on your part.  What that
says, if I read things correctly, is that the mandatory argument to
--name can be the empty string, which effectively makes it an optional
argument, so there are some puzzling side-effects.  I've dropped ':()'
from my example to avoid that.




Messages sorted by: Reverse Date, Date, Thread, Author