Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
how to debug completion or: how to change _arguments depending on subcommand (not fixed position)
- X-seq: zsh-users 24282
- From: zsh hh <zshuser1010@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- 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
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=RXplDloXngv+ct2D4E2sqV0D2rU41uSkzsfwX453iq0=; b=Jvcn/tmI8t0x2zRSCuxHZHCKSmw7aODfuAaiuXpUInekG8guNPYUIpDfh91M+Q9nX4 EqtPchOc/a7L89tvb64GLfQrfG54+TlxuHpvYzPHbuMirvjFSAMmikoai8LWyz3V/mdX hIJjCxbM4IiNdZHN7UTXc9xOo8KmAIMs1DPCUqJktKzdrdkjnWW/ukNMo7vHdyhMxKDW 55MnvKmZeb0AHVq8sc1sfleZfqT7s5F85G4bSRqL5RxjvnwaRGwHU5JA/IHDIHdQlb4n A83U3LLG/mCWSCrmad6dTk2SeT6swooHw9lwV4cSLNTo8CFAenEAvb5AZtVPGibQR+jl hPvA==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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...
Messages sorted by:
Reverse Date,
Date,
Thread,
Author