Skip to content

Commit c1c93d2

Browse files
committed
Merge pull request mbailey#72 from realestate-com-au/fix-bash-completion
_bma_stacks_completion() only gets stack name for first arg
2 parents a02d0bd + af0c60b commit c1c93d2

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

bash_completion.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
_bma_stacks_completion() {
2-
local command="$1"
3-
local word="$2"
4-
COMPREPLY=($(compgen -W "$(stacks)" -- ${word}))
5-
return 0
2+
local command="$1"
3+
local word="$2"
4+
5+
case "" in
6+
1)
7+
COMPREPLY=( $(compgen -W "$(stacks)" -- ${word}) )
8+
return 0
9+
;;
10+
*)
11+
COMPREPLY=( $(compgen -f ${word}) )
12+
return 0
13+
;;
14+
esac
615
}
716

817
_bma_instances_completion() {
@@ -54,6 +63,7 @@ complete -F _bma_stacks_completion stacks
5463
complete -F _bma_stacks_completion stack-cancel-update
5564
complete -F _bma_stacks_completion stack-update
5665
complete -F _bma_stacks_completion stack-delete
66+
complete -F _bma_stacks_completion stack-recreate
5767
complete -F _bma_stacks_completion stack-failure
5868
complete -F _bma_stacks_completion stack-events
5969
complete -F _bma_stacks_completion stack-resources

test/generate_bash_completion

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@ ROOT_DIR="$(dirname $0)/../"
33

44
cat <<EOF
55
_bma_stacks_completion() {
6-
local command="\$1"
7-
local word="\$2"
8-
COMPREPLY=(\$(compgen -W "\$(stacks)" -- \${word}))
9-
return 0
6+
local command="\$1"
7+
local word="\$2"
8+
9+
case "${COMP_CWORD}" in
10+
1)
11+
COMPREPLY=( \$(compgen -W "\$(stacks)" -- \${word}) )
12+
return 0
13+
;;
14+
*)
15+
COMPREPLY=( \$(compgen -f \${word}) )
16+
return 0
17+
;;
18+
esac
1019
}
1120
1221
_bma_instances_completion() {
@@ -42,6 +51,9 @@ for type in instance asg stack; do
4251
for function in ${functions}; do
4352
[[ "${function}" == "stack-validate" ]] && continue
4453
[[ "${function}" == "stack-create" ]] && continue
54+
[[ "${function}" == "asg-desired-size-set" ]] && continue
55+
[[ "${function}" == "asg-min-size-set" ]] && continue
56+
[[ "${function}" == "asg-max-size-set" ]] && continue
4557
echo "complete -F _bma_${type}s_completion ${function}"
4658
done
4759
done

0 commit comments

Comments
 (0)