-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommander_completion
69 lines (60 loc) · 1.34 KB
/
commander_completion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/bash
# Bash completion scripts for commander.
#
# _commander() {
# declare cur prev count
# cur="${COMP_WORDS[COMP_CWORD]}"
# prev="${COMP_WORDS[COMP_CWORD-1]}"
# count=${#COMP_WORDS[@]}
# if ((count==2)) && [[ "$prev" == "commander" ]]; then
# COMPREPLY=( $(compgen -W "help sample set-args -h --help" -- $cur) )
# fi
# return
# }
_commander() {
declare cur prev count
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
count=${#COMP_WORDS[@]}
if ((count==2)) && [[ "$prev" -eq "commander" ]]; then
COMPREPLY+=( $(compgen -W "help sample set-args -h --help" -- $cur) )
return
fi
if [[ "$prev" -eq "set-args" ]]; then
COMPREPLY+=( $(compgen -W "-h -A --help --args --add-args" -- $cur) )
return
fi
if ((count==3)); then
declare words
case "$prev" in
sample)
words="set-args -s -v -h --help --string-value --verbose"
;;
set-args)
set_args
;;
*)
words=""
;;
esac
COMPREPLY+=( $(compgen -W "$words" -- $cur) )
return
fi
if ((count==4)); then
declare words
case "$prev" in
set-args)
set_args
;;
*)
words=""
;;
esac
COMPREPLY+=( $(compgen -W "$words" -- $cur) )
return
fi
}
set_args() {
words="-h -A --help --args --add-args"
}
complete -F _commander commander