Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completion implementation woes
# okiddle@xxxxxxxxxxx / 2016-10-02 03:31:54 +0200:
> 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.
why does '*::' pop $words?
> 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 (- :)
is there any chance to get the - thing working with chained _arguments
calls? this seems to be the least-clutter notation...
in fact, i'd love to get as close to a grammatic pov as possible,
and the more faithful the representation the better. eg. activate
does not take any operands, so the '*::option or operand:..' rule
rubs me the really wrong way.
_git-dirs = "git" gitopt* "dirs" op
op = help
| cmd
help = "-h" | "--help"
cmd = activate
| active
| clone
| init
| list
activate = "activate" repo
active = "active" o_path?
list = "list" o_path?
clone = "clone" o_N? url repo
init = "init" o_N? repo
o_path = o_f | o_r | o_s
o_N = "-N" | "--no-activate"
o_f = "-f" | "--full"
o_r = "-r" | "--relative"
o_s = "-s" | "--short"
--
roman
Messages sorted by:
Reverse Date,
Date,
Thread,
Author