* [PATCH] cg-completion: improve options and command listing
@ 2005-12-11 19:09 Jonas Fonseca
2005-12-17 23:25 ` Ben Clifford
0 siblings, 1 reply; 5+ messages in thread
From: Jonas Fonseca @ 2005-12-11 19:09 UTC (permalink / raw)
To: Petr Baudis, git
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
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] cg-completion: improve options and command listing
2005-12-11 19:09 [PATCH] cg-completion: improve options and command listing Jonas Fonseca
@ 2005-12-17 23:25 ` Ben Clifford
2005-12-18 14:34 ` Jonas Fonseca
0 siblings, 1 reply; 5+ messages in thread
From: Ben Clifford @ 2005-12-17 23:25 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: Git List, Petr Baudis
On 12 Dec 2005, at 04:39, Jonas Fonseca wrote:
> Complete help options and improve filtering for command name
> completion.
>
> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
>
Hi. I've applied this patch to the dev branch cg-compl in my
gitcompletion repo.
I'm interested by what you mean by 'all sorts of garbage' - it seems
ok on my machine.
Ben
> ---
>
> 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
--
Ben • ベン • Бэн • 벤 • 班明
http://www.hawaga.org.uk/ben/
My email is high latency but best way to contact me. Alternatively,
SMS number(s) at above URL.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cg-completion: improve options and command listing
2005-12-17 23:25 ` Ben Clifford
@ 2005-12-18 14:34 ` Jonas Fonseca
2005-12-19 1:03 ` Ben Clifford
2005-12-20 2:13 ` Ben Clifford
0 siblings, 2 replies; 5+ messages in thread
From: Jonas Fonseca @ 2005-12-18 14:34 UTC (permalink / raw)
To: Ben Clifford; +Cc: Git List, Petr Baudis
Ben Clifford <benc@hawaga.org.uk> wrote Sun, Dec 18, 2005:
>
> On 12 Dec 2005, at 04:39, Jonas Fonseca wrote:
>
> >Complete help options and improve filtering for command name
> >completion.
> >
> >Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
> >
>
> Hi. I've applied this patch to the dev branch cg-compl in my
> gitcompletion repo.
>
> I'm interested by what you mean by 'all sorts of garbage' - it seems
> ok on my machine.
~/src/cogito/cogito > __cg_cmdlist | head
cg-add Add files to the GIT repository.
cg-clean Clean unknown files from the working tree.
cg-clone Clone a remote GIT repository.
cg-commit Commit into a GIT repository.
cg-diff Make a diff between two GIT trees.
cg-export Exports a particular revision from a GIT repository.
cg-fetch Fetch changes from a remote branch to the local GIT repository.
cg-help Show help for Cogito commands.
cg-init Initialize a GIT repository.
cg-log Make a log of changes in a GIT branch.
Else I was thinking of maybe adding --list parameter to cg-help to have
it list all known commands.
--
Jonas Fonseca
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] cg-completion: improve options and command listing
2005-12-18 14:34 ` Jonas Fonseca
@ 2005-12-19 1:03 ` Ben Clifford
2005-12-20 2:13 ` Ben Clifford
1 sibling, 0 replies; 5+ messages in thread
From: Ben Clifford @ 2005-12-19 1:03 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: Git List, Petr Baudis
On Sun, 18 Dec 2005, Jonas Fonseca wrote:
> Else I was thinking of maybe adding --list parameter to cg-help to have
> it list all known commands.
yeah, that would be nice.
--
http://www.hawaga.org.uk/ben/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cg-completion: improve options and command listing
2005-12-18 14:34 ` Jonas Fonseca
2005-12-19 1:03 ` Ben Clifford
@ 2005-12-20 2:13 ` Ben Clifford
1 sibling, 0 replies; 5+ messages in thread
From: Ben Clifford @ 2005-12-20 2:13 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: Git List
On 19 Dec 2005, at 00:04, Jonas Fonseca wrote:
>>
>> I'm interested by what you mean by 'all sorts of garbage' - it seems
>> ok on my machine.
>
> ~/src/cogito/cogito > __cg_cmdlist | head
> cg-add Add files to the GIT repository.
> cg-clean Clean unknown files from the working tree.
> cg-clone Clone a remote GIT repository.
I definitely don't get that here. Bleugh!
> Else I was thinking of maybe adding --list parameter to cg-help to
> have
> it list all known commands.
One thing that seemed kinda neat that I saw somewhere (perhaps in
darcs?) is that it will tab complete only commands that would make
sense in the present location (so cg <tab> would perhaps only bring
up 'init' and 'help' in a non-git directory) - that would be rather
more invasive to implement, I expect.
Another thing that has been mooted is autogenerating the completion
code based on USAGE info - I've had a hack about in the past with
that (its in the autogen branch in the gitcompletion repo on
hawaga.org.uk) but then I reached the point where it seemed too icky
for my tastes...
--
Ben • ベン • Бэн • 벤 • 班明
http://www.hawaga.org.uk/ben/
My email is high latency but best way to contact me. Alternatively,
SMS number(s) at above URL.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-12-22 0:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-11 19:09 [PATCH] cg-completion: improve options and command listing Jonas Fonseca
2005-12-17 23:25 ` Ben Clifford
2005-12-18 14:34 ` Jonas Fonseca
2005-12-19 1:03 ` Ben Clifford
2005-12-20 2:13 ` Ben Clifford
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).