zsh-users
 help / color / mirror / code / Atom feed
From: zsh hh <zshuser1010@gmail.com>
To: zsh-users@zsh.org
Subject: how to debug completion or: how to change _arguments depending on subcommand (not fixed position)
Date: Tue, 24 Sep 2019 05:51:56 +0000	[thread overview]
Message-ID: <CABSdULyMOdY1qwWq2YEa2Wwnn=xTTyPYrUSuqTLkjKd_VqALhg@mail.gmail.com> (raw)

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

                 reply	other threads:[~2019-09-24  5:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABSdULyMOdY1qwWq2YEa2Wwnn=xTTyPYrUSuqTLkjKd_VqALhg@mail.gmail.com' \
    --to=zshuser1010@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).