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

Re: completion implementation woes



Roman Neuhauser wrote:
> i have difficult time with completion for a git subcommand i wrote,
> and would appreciate a little help.

>     _git-dirs-_args \
>       - '(help)' \
>         '-h[display usage]' \
>         '--help[display man page]' \
>       - 'command' \
>         ":command:_git-dirs-_verb" \
>         "*:option or operand:_git-dirs-_verb-arg"

You'll find it solves quite a few of your issues if you change this to
the two colon form:

      "*::option or operand:_git-dirs-_verb-arg"

When handling subcommands, it is important to drop initial arguments
from the beginning of $words to avoid confusing later calls to
_arguments. If $words contains ( git dirs init ), _arguments sees a
command and two arguments. That's what _arguments called from _git
wants but not good from _git_dirs-init.

Getting rid of the sets in _git-dirs fixes completion after git
dirs init -N. Somehow it isn't getting past the first _arguments. --help
style options can usually just be given an exclusion list of (- :)

Oliver



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