comparison contrib/bash_completion @ 2034:5e7aff1b6ae1

add --options to debugcomplete and change bash_completion to use it make debugcomplete print one item per line (this is not needed for the bash_completion script, but should be easier to use in other scripts)
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 01 Apr 2006 22:50:12 +0200
parents 283d2ab1e020
children 107dc72880f8
comparison
equal deleted inserted replaced
2033:e3280d350792 2034:5e7aff1b6ae1
1 shopt -s extglob 1 shopt -s extglob
2
3 _hg_option_list()
4 {
5 "$hg" -v help $1 2>/dev/null | \
6 awk '/^ *-/ {
7 for (i = 1; i <= NF; i ++) {
8 if (index($i, "-") != 1)
9 break;
10 print $i;
11 }
12 }'
13 }
14
15 2
16 _hg_commands() 3 _hg_commands()
17 { 4 {
18 local commands 5 local commands
19 commands="$("$hg" debugcomplete "$cur" 2>/dev/null)" || commands="" 6 commands="$("$hg" debugcomplete "$cur" 2>/dev/null)" || commands=""
87 fi 74 fi
88 fi 75 fi
89 done 76 done
90 77
91 if [[ "$cur" == -* ]]; then 78 if [[ "$cur" == -* ]]; then
92 opts=$(_hg_option_list $cmd) 79 opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null)
93 80
94 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) 81 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
95 return 82 return
96 fi 83 fi
97 84