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

Re: _git: Add completion for help subcommand



At 10:29 +0200 27 Aug 2010, Nikolai Weibull <now@xxxxxxxx> wrote:
Actually, why not use

- '(formats)' \,

explicitly making the formats mutually exclusive?

I hadn't done that previously because as I was conceiving the issue, I saw the argument to specifyg the command for which help was desired as part of that set as well, and using that syntax would make that part of the mutually exclusive set. I've now rethought that, and have moved the command argument into the common options, allowing use of that syntax.

Here's a revised version of the patch.

---
 Completion/Unix/Command/_git |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index c394e08..5fc0765 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -190,6 +190,7 @@ _git_commands () {
     'fetch:download objects and a head from another repository'
     'gc:cleanup unnecessary files and optimize the local repository'
     'grep:print lines matching a pattern'
+    'help:display help information about git subcommands'
     'init:create empty git object database'
     'log:show commit logs'
     'merge:grand unified merge driver'
@@ -490,6 +491,19 @@ _git-hash-object () {
     '(--stdin):file:_files' && ret=0
 }
+(( $+functions[_git-help] )) ||
+_git-help () {
+  _arguments -S \
+    ':command:_git_commands' \
+    - '(all)' \
+    '(*)'{--all,-a}'[List all available commands]' \
+    - '(format)' \
+    {--man,-m}'[Display help in man page format]' \
+    {--info,-i}'[Display help in info format]' \
+    {--web,-w}'[Display help in web browser]' \
+    && ret=0
+}
+
 (( $+functions[_git-index-pack] )) ||
 _git-index-pack () {
   local -a stdin_arguments
--
1.7.0.4



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