From: "Nikolai Weibull" <now@bitwi.se>
To: "Zsh Users" <zsh-users@sunsite.dk>
Subject: How to solve completion of "git command" and "git-command"
Date: Wed, 15 Mar 2006 23:06:03 +0100 [thread overview]
Message-ID: <dbfc82860603151406k6f0789embf817c6e759536d3@mail.gmail.com> (raw)
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
reply other threads:[~2006-03-15 22:06 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=dbfc82860603151406k6f0789embf817c6e759536d3@mail.gmail.com \
--to=now@bitwi.se \
--cc=zsh-users@sunsite.dk \
/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).