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

_arguments for non-dashed parameters (or similar)?

Hi all,

I am trying to extend my completion for vcsh[1] before I actually
submit it to this list.

The problem is that this syntax simply ignores completion functions
which would feed data into the completion:

#compdef vcsh
_arguments \	':subcommand:((		clone\:"clone from repo":(1
2)		help\:"display help"		delete\:"delete repo"		enter\:"Enter repo;
spawn new \$SHELL"		init\:"init & clone from repo"		list\:"list all
repos"		list-tracked\:"list all files tracked by
vcsh"		list-tracked-by\:"list files tracked by a
repo"		rename\:"rename repo"		run\:"run command on
repo"		seed-gitignore\:"seed .gitignore.d/foo from git
ls-files"		setup\:"set up repo with recommended
settings"		\<REPO\>\:"Run git command directly"	))'

whereas this syntax does not seem to allow non-dashed parameters:

_arguments \
	'-clone:clone from repo:(1 2)' \
	'help:"display help"' \
	'delete:"delete repo"' \
	'enter:"Enter repo; spawn new \$SHELL"' \
	'init:"init & clone from repo"' \
	'list:"list all repos"' \
	'list-tracked:"list all files tracked by vcsh"' \
	'list-tracked-by:"list files tracked by a repo"' \
	'rename:"rename repo"' \
	'run:"run command on repo"' \
	'seed-gitignore:"seed .gitignore.d/foo from git ls-files":(foo bar)' \
	'setup:"set up repo with recommended settings"' \
	'\<REPO\>:"Run git command directly"' \

% vcsh <tab>
_arguments:comparguments:312: invalid argument: clone:clone from repo:(1 2)

and this approach does not work, either:

clone[:argargs]:(1 2)

_arguments:comparguments:312: invalid argument: clone[clone from repo]:(1 2)

_git, _subversion et all seem to simply check the non-dashed parameter
by hand and then do the rest in custom functions.

Is there any generic and clean way to do this? If there is not, would
it be worthwhile to introduce a new function? Given the fact that more
and more programs use non-dashed prosaic command styles, this
"problem" is becoming worse, not better.


[1] https://github.com/RichiH/vcsh

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