zsh-users
 help / color / mirror / code / Atom feed
* how to debug completion or: how to change _arguments depending on subcommand (not fixed position)
@ 2019-09-24  5:51 zsh hh
  0 siblings, 0 replies; only message in thread
From: zsh hh @ 2019-09-24  5:51 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 945 bytes --]

I want to create a completion script for:

> program [OPTS] SUBCOMMAND [SUBCOMMAND-OPTS] [ARGS]

A common approach is:
  _arguments -C \
    '1: :cmds' \
    '*::arg:->args' \
  && ret=0

  case $state in
    (args)
       case $line[1] in
         (subcmd1|subcmd2)
           _message 'no more arguments' && ret=0
         ;;
         (subwithextraopts)
           _arguments ...
             && ret=0
         ;;
         (othersubwithextraopts)
           _arguments ...
             && ret=0
         ;;
 esac

esac

But that relies on subcommand being at $line[1] which is rarely the
case (at least in my application)


git is actually a good example:

git -TAB #tabs git options

git add -TAB #tabs git-add options

git --bare log -TAB #tabs git-log options (but log is not $line[1]

That leads to the idea using git completion as reference, which in
turn leads to the question: how to debug such a completion?

It is a very extensive...

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-24  5:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24  5:51 how to debug completion or: how to change _arguments depending on subcommand (not fixed position) zsh hh

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).