forked from bash-my-aws/bash-my-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_completion.sh
216 lines (208 loc) · 7.43 KB
/
bash_completion.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
bma_path="${HOME}/.bash-my-aws"
_bma_asgs_completion() {
local command="$1"
local word="$2"
local options=$(bma asgs | awk '{ print $1 }')
COMPREPLY=($(compgen -W "${options}" -- ${word}))
return 0
}
_bma_aws-accounts_completion() {
local command="$1"
local word="$2"
local options=$(bma aws-accounts | awk '{ print $1 }')
COMPREPLY=($(compgen -W "${options}" -- ${word}))
return 0
}
_bma_buckets_completion() {
local command="$1"
local word="$2"
local options=$(bma buckets | awk '{ print $1 }')
COMPREPLY=( $(compgen -W "${options}" -- ${word}) )
return 0
}
_bma_certs_completion() {
local command="$1"
local word="$2"
local options=$(bma certs-arn | awk '{ print $1 }')
COMPREPLY=($(compgen -W "${options}" -- ${word}))
return 0
}
_bma_elbs_completion() {
local command="$1"
local word="$2"
local options=$(bma elbs | awk '{ print $1 }')
COMPREPLY=($(compgen -W "${options}" -- ${word}))
return 0
}
_bma_elbv2s_completion() {
local command="$1"
local word="$2"
local options=$(bma elbv2s | awk '{ print $1 }')
COMPREPLY=($(compgen -W "${options}" -- ${word}))
return 0
}
_bma_instances_completion() {
local command="$1"
local word="$2"
local options="i-a i-b"
if [[ $word != "--" ]] && [[ $word != "" ]]; then
options=$(bma instances)
fi
COMPREPLY=($(compgen -W "${options}" -- ${word}))
return 0
}
_bma_keypairs_completion() {
local command="$1"
local word="$2"
local options=$(bma keypairs | awk '{ print $1 }')
COMPREPLY=($(compgen -W "${options}" -- ${word}))
return 0
}
_bma_regions_completion() {
local command="$1"
local word="$2"
local options=$(bma regions)
COMPREPLY=($(compgen -W "${options}" -- ${word}))
return 0
}
_bma_stacks_completion() {
local command="$1"
local word="$2"
if [ "${COMP_CWORD}" -eq 1 ]; then
COMPREPLY=($(compgen -W "$(bma stacks | awk '{ print $1 }')" -- "${word}"))
elif [ "${COMP_CWORD}" -eq 2 ] && [ "${command}" = 'bma' ]; then
COMPREPLY=($(compgen -W "$(bma stacks | awk '{ print $1 }')" -- "${word}"))
else
COMPREPLY=($(compgen -f "${word}"))
fi
return 0
}
_bma_vpcs_completion() {
local command="$1"
local word="$2"
local options=$(bma vpcs | awk '{ print $1 }')
COMPREPLY=($(compgen -W "${options}" -- ${word}))
return 0
}
_bma_completion() {
local word
word="$2"
if [ "${COMP_CWORD}" -eq 1 ]; then
_bma_functions_completion "$word"
elif [ "${COMP_CWORD}" -eq 2 ] && [ "$3" = "type" ]; then
_bma_functions_completion "$word"
else
_bma_subcommands_completion "${COMP_WORDS[1]}" "$word"
fi
}
_bma_functions_completion() {
local word all_funcs
word="$1"
all_funcs=$(echo "type" && cat "${bma_path}/functions")
COMPREPLY=($(compgen -W "${all_funcs}" -- ${word}))
return
}
_bma_subcommands_completion() {
local subcommand word subcommand_completion
subcommand="$1"
word="$2"
subcommand_completion=$(
complete -p |
command grep "_bma_" |
command grep "\s${subcommand:-}$" |
command awk '{print $3}'
)
if [ -n "${subcommand_completion}" ]; then
$subcommand_completion "bma" "${word:-}"
fi
return 0
}
complete -F _bma_asgs_completion asg-capacity
complete -F _bma_asgs_completion asg-instances
complete -F _bma_asgs_completion asg-launch-configuration
complete -F _bma_asgs_completion asg-processes_suspended
complete -F _bma_asgs_completion asg-resume
complete -F _bma_asgs_completion asg-scaling-activities
complete -F _bma_asgs_completion asg-stack
complete -F _bma_asgs_completion asg-suspend
complete -F _bma_asgs_completion asgs
complete -F _bma_aws-accounts_completion aws-account-cost-explorer
complete -F _bma_aws-accounts_completion aws-account-cost-recommendations
complete -F _bma_aws-accounts_completion aws-accounts
complete -F _bma_buckets_completion bucket-acls
complete -F _bma_buckets_completion bucket-remove
complete -F _bma_buckets_completion bucket-remove-force
complete -F _bma_buckets_completion buckets
complete -F _bma_certs_completion cert-delete
complete -F _bma_certs_completion cert-users
complete -F _bma_certs_completion certs
complete -F _bma_certs_completion certs-arn
complete -F _bma_elbs_completion elb-azs
complete -F _bma_elbs_completion elb-dnsname
complete -F _bma_elbs_completion elb-instances
complete -F _bma_elbs_completion elb-stack
complete -F _bma_elbs_completion elb-subnets
complete -F _bma_elbs_completion elbs
complete -F _bma_elbv2s_completion elbv2-azs
complete -F _bma_elbv2s_completion elbv2-dnsname
complete -F _bma_elbv2s_completion elbv2-subnets
complete -F _bma_elbv2s_completion elbv2s
complete -F _bma_instances_completion instance-asg
complete -F _bma_instances_completion instance-az
complete -F _bma_instances_completion instance-console
complete -F _bma_instances_completion instance-dns
complete -F _bma_instances_completion instance-health-set-unhealthy
complete -F _bma_instances_completion instance-iam-profile
complete -F _bma_instances_completion instance-ip
complete -F _bma_instances_completion instance-ssh
complete -F _bma_instances_completion instance-ssh-details
complete -F _bma_instances_completion instance-stack
complete -F _bma_instances_completion instance-start
complete -F _bma_instances_completion instance-state
complete -F _bma_instances_completion instance-stop
complete -F _bma_instances_completion instance-tags
complete -F _bma_instances_completion instance-terminate
complete -F _bma_instances_completion instance-termination-protection
complete -F _bma_instances_completion instance-termination-protection-disable
complete -F _bma_instances_completion instance-termination-protection-enable
complete -F _bma_instances_completion instance-type
complete -F _bma_instances_completion instance-userdata
complete -F _bma_instances_completion instance-volumes
complete -F _bma_instances_completion instance-vpc
complete -F _bma_instances_completion instances
complete -F _bma_keypairs_completion keypair-delete
complete -F _bma_keypairs_completion keypairs
complete -F _bma_regions_completion region
complete -F _bma_stacks_completion stack-arn
complete -F _bma_stacks_completion stack-asg-instances
complete -F _bma_stacks_completion stack-asgs
complete -F _bma_stacks_completion stack-cancel-update
complete -F _bma_stacks_completion stack-delete
complete -F _bma_stacks_completion stack-diff
complete -F _bma_stacks_completion stack-elbs
complete -F _bma_stacks_completion stack-events
complete -F _bma_stacks_completion stack-exports
complete -F _bma_stacks_completion stack-failure
complete -F _bma_stacks_completion stack-instances
complete -F _bma_stacks_completion stack-outputs
complete -F _bma_stacks_completion stack-parameters
complete -F _bma_stacks_completion stack-recreate
complete -F _bma_stacks_completion stack-resources
complete -F _bma_stacks_completion stack-status
complete -F _bma_stacks_completion stack-tail
complete -F _bma_stacks_completion stack-template
complete -F _bma_stacks_completion stack-update
complete -F _bma_stacks_completion stacks
complete -F _bma_vpcs_completion vpc-az-count
complete -F _bma_vpcs_completion vpc-azs
complete -F _bma_vpcs_completion vpc-endpoints
complete -F _bma_vpcs_completion vpc-igw
complete -F _bma_vpcs_completion vpc-lambda-functions
complete -F _bma_vpcs_completion vpc-nat-gateways
complete -F _bma_vpcs_completion vpc-network-acls
complete -F _bma_vpcs_completion vpc-rds
complete -F _bma_vpcs_completion vpc-route-tables
complete -F _bma_vpcs_completion vpc-subnets
complete -F _bma_vpcs_completion vpcs
complete -f stack-validate
complete -F _bma_completion bma