4
local cur cmds cmdIdx cmd cmdOpts fixedWords i globalOpts
9
cur=${COMP_WORDS[COMP_CWORD]}
11
cmds='add-relation add-unit bootstrap debug-hooks debug-log deploy destroy-service expose open-tunnel remove-relation remove-unit resolved set shutdown ssh status terminate-machine unexpose upgrade-formula'
12
globalOpts=( -h --verbose -v --log-file)
14
# do ordinary expansion if we are anywhere after a -- argument
15
for ((i = 1; i < COMP_CWORD; ++i)); do
16
[[ ${COMP_WORDS[i]} == "--" ]] && return 0
19
# find the command; it's the first word not starting in -
21
for ((cmdIdx = 1; cmdIdx < ${#COMP_WORDS[@]}; ++cmdIdx)); do
22
if [[ ${COMP_WORDS[cmdIdx]} != -* ]]; then
23
cmd=${COMP_WORDS[cmdIdx]}
28
# complete command name if we are not already past the command
29
if [[ $COMP_CWORD -le cmdIdx ]]; then
30
COMPREPLY=( $( compgen -W "$cmds ${globalOpts[*]}" -- $cur ) )
34
# find the option for which we want to complete a value
36
if [[ $cur != -* ]] && [[ $COMP_CWORD -gt 1 ]]; then
37
curOpt=${COMP_WORDS[COMP_CWORD - 1]}
38
if [[ $curOpt == = ]]; then
39
curOpt=${COMP_WORDS[COMP_CWORD - 2]}
40
elif [[ $cur == : ]]; then
43
elif [[ $curOpt == : ]]; then
44
curOpt=${COMP_WORDS[COMP_CWORD - 2]}:
52
add-relation|add-unit|debug-hooks|destory-service|expose-service|unexpose-service|open-tunnel|remove-relation|remove-unit|ssh|terminate-machine)
53
cmdOpts=( --environment )
59
cmdOpts=( --environment --repository )
62
cmdOpts=( --environment -e --replay -r -i -x -l -n -o --output)
64
-l) optEnums=( DEBUG INFO ERROR WARNING CRITICAL ) ;;
68
cmdOpts=( --retry --environment )
71
cmdOpts=( --output --format --environment)
73
--format) optEnums=( json yaml png svg dot )
3
local cur cmds cmdIdx cmd cmdOpts fixedWords i globalOpts
8
cur=${COMP_WORDS[COMP_CWORD]}
9
cmds='add-relation add-unit bootstrap debug-hooks debug-log deploy destroy-service expose open-tunnel remove-relation remove-unit resolved set shutdown ssh status terminate-machine unexpose upgrade-formula'
10
globalOpts=( -h --verbose -v --log-file)
12
# do ordinary expansion if we are anywhere after a -- argument
13
for ((i = 1; i < COMP_CWORD; ++i)); do
14
[[ ${COMP_WORDS[i]} == "--" ]] && return 0
17
# find the command; it's the first word not starting in -
19
for ((cmdIdx = 1; cmdIdx < ${#COMP_WORDS[@]}; ++cmdIdx)); do
20
if [[ ${COMP_WORDS[cmdIdx]} != -* ]]; then
21
cmd=${COMP_WORDS[cmdIdx]}
26
# complete command name if we are not already past the command
27
if [[ $COMP_CWORD -le cmdIdx ]]; then
28
COMPREPLY=( $( compgen -W "$cmds ${globalOpts[*]}" -- "$cur" ) )
32
# find the option for which we want to complete a value
34
if [[ $cur != -* ]] && [[ $COMP_CWORD -gt 1 ]]; then
35
curOpt=${COMP_WORDS[COMP_CWORD - 1]}
36
if [[ "$curOpt" == = ]]; then
37
curOpt=${COMP_WORDS[COMP_CWORD - 2]}
38
elif [[ "$cur" == : ]]; then
41
elif [[ "$curOpt" == : ]]; then
42
curOpt=${COMP_WORDS[COMP_CWORD - 2]}:
50
add-relation|add-unit|debug-hooks|destory-service|expose-service|unexpose-service|open-tunnel|remove-relation|remove-unit|ssh|terminate-machine)
51
cmdOpts=( --environment )
57
cmdOpts=( --environment --repository )
60
cmdOpts=( --environment -e --replay -r -i -x -l -n -o --output)
62
-l) optEnums=( DEBUG INFO ERROR WARNING CRITICAL ) ;;
66
cmdOpts=( --retry --environment )
69
cmdOpts=( --output --format --environment)
71
--format) optEnums=( json yaml png svg dot )
77
76
cmdOpts=( --dry-run -n --environment --repository)
85
if [[ $cur == = ]] && [[ ${#optEnums[@]} -gt 0 ]]; then
86
# complete directly after "--option=", list all enum values
87
COMPREPLY=( "${optEnums[@]}" )
90
fixedWords=( "${cmdOpts[@]}"
96
if [[ ${#fixedWords[@]} -gt 0 ]]; then
97
COMPREPLY=( $( compgen -W "${fixedWords[*]}" -- $cur ) )
84
if [[ "$cur" == = ]] && [[ ${#optEnums[@]} -gt 0 ]]; then
85
# complete directly after "--option=", list all enum values
86
COMPREPLY=( "${optEnums[@]}" )
89
fixedWords=( "${cmdOpts[@]}"
95
if [[ ${#fixedWords[@]} -gt 0 ]]; then
96
COMPREPLY=( $( compgen -W "${fixedWords[*]}" -- "$cur" ) )
103
102
complete -F _ensemble -o default ensemble