* How to solve completion of "git command" and "git-command"
@ 2006-03-15 22:06 Nikolai Weibull
0 siblings, 0 replies; only message in thread
From: Nikolai Weibull @ 2006-03-15 22:06 UTC (permalink / raw)
To: Zsh Users
Currently, _git completes both ways of invoking git and it's subcommands:
if [[ $words[1] == git ]]; then
if (( CURRENT == 2 )); then
_git_commands
else
shift words
(( CURRENT-- ))
curcontext="${curcontext%:*:*}:git-$words[1]:"
_call_function ret _git-$words[1]
fi
else
_call_function ret _$words[1]
fi
However, the "git" command now also takes options, not just
subcommands as its argument. How do I best solve this, so that I can
still get the functionality implied in the example above (just calling
the correct function, e.g., _git-commit for both "git commit ..." and
"git-commit ...")?
The "git" command currently takes three options: "--version",
"--help", and "--exec-path[=PATH]".
The _git_commands function currently invokes _describe:
_describe -t commands 'git command' commands && ret=0
on an array of commands-descriptions.
I was thinking that something like
if [[ $words[1] == git ]]; then
local context state line
typeset -A opt_args
_arguments \
'(- :)--version[display version information]' \
'(- :)--help[display help]' \
'--exec-path=-[execution path for git]:directory:_directories' \
':command:->command' \
'*::options:->options' && ret=0
case $state in
(command)
_git_commands
;;
(options)
curcontext="${curcontext%:*:*}:git-$words[1]:"
_call_function ret _git-$words[1]
;;
esac
else
_call_function ret _$words[1]
fi
might work, but I want to make seru that I'm not missing something here?
Any help towards reaching a satisfactory solution will be greatly appreciated.
Thanks.
nikolai
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-03-15 22:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-15 22:06 How to solve completion of "git command" and "git-command" Nikolai Weibull
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).