Thus spake Thomas Arendsen Hein:
> * TK Soh <teekaysoh@xxxxxxxxx> [20051122 01:47]:
> > I noticed the debug commands are hardcoded somehow, so I thought
> > it can be made more convenient.
>
> This is good
Indeed. I didn't know you could get the list of debug commands in this
way.
> While it is reasonable to assume that debug commands should be even
> more hidden than they are now, I want to hear what others think.
I think TK Soh's point wasn't to hide them more, but to future-proof
against possible future commands that start with "de".
So, what about the patch below? It first tries to generate completions
just with the regular commands. If it doesn't find anything, it tries
again with the debug commands.
This keeps the current behavior of completing the debug commands if you
type "hg de<Tab>" but if somebody creates a "deb" command, it will
require you to type "hg debu<Tab>".
Alexis, preparing another batch of bash completion updates.
# HG changeset patch
# User Alexis S. L. Carvalho <alexis@xxxxxxxxxxx>
# Node ID ec3bdea0c2b847a097c3ca7983d9e0277913e683
# Parent 68ec7b9e09a48d8100cf5394279060cefdda1f82
bash_completion: use hg --debug help to get the list of debug commands.
Also, try completing with the debug commands only when there's no other
candidates.
Based on an idea by TK Soh.
diff -r 68ec7b9e09a4 -r ec3bdea0c2b8 contrib/bash_completion
--- a/contrib/bash_completion Thu Nov 17 19:38:57 2005 +0100
+++ b/contrib/bash_completion Tue Nov 22 20:23:03 2005 -0200
@@ -2,18 +2,25 @@
_hg_commands()
{
- local commands="$(hg -v help | sed -e '1,/^list of commands:/d' \
- -e '/^global options:/,$d' \
- -e '/^ [^ ]/!d; s/[,:]//g;')"
+ local all commands result
+
+ all=($(hg --debug help | sed -e '1,/^list of commands:/d' \
+ -e '/^global options:/,$d' \
+ -e '/^ [^ ]/!d; s/^ //; s/[,:]//g;'))
+
+ commands="${all[*]##debug*}"
+ result=$(compgen -W "${commands[*]}" -- "$cur")
# hide debug commands from users, but complete them if
- # specifically asked for
- if [[ "$cur" == de* ]]; then
- commands="$commands debugcheckstate debugstate debugindex"
- commands="$commands debugindexdot debugwalk debugdata"
- commands="$commands debugancestor debugconfig debugrename"
+ # there is no other possible command
+ if [ "$result" = "" ]; then
+ local debug
+ debug=(${all[*]##!(debug*)})
+ debug="${debug[*]/g/debug}"
+ result=$(compgen -W "$debug" -- "$cur")
fi
- COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$commands" -- "$cur") )
+
+ COMPREPLY=(${COMPREPLY[@]:-} $result)
}
_hg_paths()
|