git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Fonseca <fonseca@diku.dk>
To: Petr Baudis <pasky@ucw.cz>, git@vger.kernel.org
Subject: [PATCH] cg-completion: improve options and command listing
Date: Sun, 11 Dec 2005 20:09:31 +0100	[thread overview]
Message-ID: <20051211190931.GF2960@diku.dk> (raw)

Complete help options and improve filtering for command name completion.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

---

 The current filtering causes all sorts of garbage to be listed in the
 command listing.

commit f0535e9952f1cace89d03649e8238aca69a6df44
tree e05dfadb63bd92ead0dc29d326065b7a797e2109
parent 3c14cded46e110396127fc5b5e65883eb5cd60b9
author Jonas Fonseca <fonseca@diku.dk> Wed, 07 Dec 2005 20:58:50 +0100
committer Jonas Fonseca <fonseca@antimatter.localdomain> Wed, 07 Dec 2005 20:58:50 +0100

 contrib/cg-completion.bash |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/contrib/cg-completion.bash b/contrib/cg-completion.bash
index 428f320..20b758f 100644
--- a/contrib/cg-completion.bash
+++ b/contrib/cg-completion.bash
@@ -23,8 +23,7 @@ __cg_branches()
 
 __cg_cmdlist()
 {
-	(cg help && cg help tag && cg help branch && cg help admin) | grep --regexp "cg-[^ ]* " | sed 's/^.*\cg-\([^ ]*\) .*$/\1/' | grep -v COMMAND
-
+	(cg help && cg help tag && cg help branch && cg help admin) | sed -n 's/.*cg-\([^ ]*\) .*/\1/p' | sort -u
 }
 
 _cg ()
@@ -33,17 +32,17 @@ _cg ()
     cur=${COMP_WORDS[COMP_CWORD]}
     COMPREPLY=()
     if [ $COMP_CWORD -eq 1 ]; then
-	COMPREPLY=( $(compgen -W "$(__cg_cmdlist)" -- $cur) )
+	COMPREPLY=( $(compgen -W "$(__cg_cmdlist) -h --help --version" -- $cur) )
     else
 	local cmd=${COMP_WORDS[1]}
 	local prev=${COMP_WORDS[COMP_CWORD-1]}
-	local o_help="-h --help"
+	local o_help="-h --help --long-help"
 	local o_branch="-b --branch"
 	case $cmd in
 	    add)
 	    # cg-add [-N] [-r] file...
 	    # XXX here could generate list of files and dirs excluding .git
-	    opts="-N -r"
+	    opts="-N -r $o_help"
 	    COMPREPLY=( $(compgen -d -f -W "${opts}" -- $cur ) )
 	    ;;
 
@@ -58,18 +57,18 @@ _cg ()
 
 	    clean)
 	    # Usage: cg-clean [-d] [-D] [-q] [-x]
-	    opts="-d -D -q -x"
+	    opts="-d -D -q -x $o_help"
 	    COMPREPLY=( $(compgen -W "${opts}" -- $cur ) )
 	    ;;
 
 	    help)
-	    opts="-c"
+	    opts="-c $o_help"
 	    COMPREPLY=( $(compgen -W "$(__cg_cmdlist) ${opts}" -- $cur) )
 	    ;;
 
 	    push)
 	    # cg-push [BRANCH_NAME] [-t TAG]
-	    opts="-t" 
+	    opts="-t $o_help" 
 	    if [ "$prev" = "-t" ]; then 
 	        COMPREPLY=( $(compgen -W "$(__git_tags)" -- $cur) )
 	    else
@@ -79,7 +78,7 @@ _cg ()
 
 	    merge)
 	    # cg-merge [-c] [-b BASE_COMMIT] [BRANCH_NAME]
-	    opts="-c -b" 
+	    opts="-c -b $o_help" 
 	    if [ "$prev" = "-b" ]; then 
 	        COMPREPLY=( $(compgen -W "$(__git_refs)" -- $cur) )
 	    else
@@ -89,7 +88,7 @@ _cg ()
 
 	    commit) 
             # cg-commit [-m MESSAGE]... [-C] [-e | -E] [-c COMMIT_ID] [FILE]
-	    opts="-m -C -e -E -c" 
+	    opts="-m -C -e -E -c $o_help" 
 	    if [ "$prev" = "-m" ]; then 
 		COMPREPLY="\"\""
 	    elif [ "$prev" = "-c" ]; then 
@@ -101,7 +100,7 @@ _cg ()
 
 	    diff)
             # cg-diff [-c] [-m] [-s] [-p] [-r FROM_ID[:TO_ID]] [FILE]...
-            opts="-c -m -s -p -r"
+            opts="-c -m -s -p -r $o_help"
 	    if [ "$prev" = "-r" ]; then 
             # TODO need some kinkiness to handle -r FROM:TO completion
 		COMPREPLY=( $(compgen -W "$(__git_refs)" -- $cur) )
@@ -111,7 +110,7 @@ _cg ()
 	    ;;
 
 	    log)
-            opts="-c -f -r -d -m -s -u --summary"
+            opts="-c -f -r -d -m -s -u --summary $o_help"
 	    if [ "$prev" = "-r" ]; then 
             # TODO need some kinkiness to handle -r FROM:TO completion
 		COMPREPLY=( $(compgen -W "$(__git_refs)" -- $cur) )
@@ -131,7 +130,7 @@ _cg ()
 	    ;;
 	    switch)
 	    # Usage: cg-switch [-f] [-n] [-r COMMIT_ID] BRANCH
-	    opts="-f -n -r"  # TODO -r 
+	    opts="-f -n -r $o_help"  # TODO -r 
 	    COMPREPLY=( $(compgen -W "${opts} $(__git_heads)" -- $cur) )
 	    ;;
 

-- 
Jonas Fonseca

             reply	other threads:[~2005-12-11 19:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-11 19:09 Jonas Fonseca [this message]
2005-12-17 23:25 ` [PATCH] cg-completion: improve options and command listing Ben Clifford
2005-12-18 14:34   ` Jonas Fonseca
2005-12-19  1:03     ` Ben Clifford
2005-12-20  2:13     ` Ben Clifford

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=20051211190931.GF2960@diku.dk \
    --to=fonseca@diku.dk \
    --cc=git@vger.kernel.org \
    --cc=pasky@ucw.cz \
    /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.
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).