-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathbash_completion.sh
274 lines (263 loc) · 9.95 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# DO NOT MANUALLY MODIFY THIS FILE.
# Use 'scripts/build' to regenerate if required.
bma_path="${BMA_HOME:-$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_target-groups_completion() {
local command="$1"
local word="$2"
local options=$(bma target-groups | awk '{ print $1 }')
COMPREPLY=($(compgen -W "${options}" -- ${word}))
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" | command grep -v "^#")
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
}
_cachews_completion() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ $COMP_CWORD -eq 1 ]]; then
local services=$(ls ${CACHEWS_DIR}/${AWS_PROFILE/-admin}/${AWS_DEFAULT_REGION}/ | sed 's/\/.*//')
COMPREPLY=( $(compgen -W "$services" -- $cur) )
return 0
elif [[ $COMP_CWORD -eq 2 ]]; then
local api_calls=$(ls ${CACHEWS_DIR}/${AWS_PROFILE/-admin}/${AWS_DEFAULT_REGION}/$prev | sed 's/\.json//')
COMPREPLY=( $(compgen -W "$api_calls" -- $cur) )
return 0
elif [[ $COMP_CWORD -ge 3 && $prev == '--output' ]]; then
COMPREPLY=( $(compgen -W "json text table" -- $cur) )
return 0
elif [[ $COMP_CWORD -ge 3 && $prev != '--query' ]]; then
COMPREPLY=( $(compgen -W "--output --query" -- $cur) )
return 0
fi
}
complete -F _cachews_completion cachews
complete -F _bma_asgs_completion asg-capacity
complete -F _bma_asgs_completion asg-detach-instances
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-chain
complete -F _bma_certs_completion cert-delete
complete -F _bma_certs_completion cert-ificate
complete -F _bma_certs_completion cert-resource-record-valid
complete -F _bma_certs_completion cert-users
complete -F _bma_certs_completion cert-verify
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 elb-tag
complete -F _bma_elbs_completion elb-tags
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 elbv2-target-groups
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-profile
complete -F _bma_instances_completion instance-profile-role
complete -F _bma_instances_completion instance-rdp
complete -F _bma_instances_completion instance-ssh
complete -F _bma_instances_completion instance-ssh-details
complete -F _bma_instances_completion instance-ssm
complete -F _bma_instances_completion instance-ssm-platform-type
complete -F _bma_instances_completion instance-ssm-port-forward
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-stop-protection
complete -F _bma_instances_completion instance-stop-protection-disable
complete -F _bma_instances_completion instance-stop-protection-enable
complete -F _bma_instances_completion instance-subnet
complete -F _bma_instances_completion instance-tag
complete -F _bma_instances_completion instance-tag-create
complete -F _bma_instances_completion instance-tag-delete
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-template-changeset-latest
complete -F _bma_stacks_completion stack-update
complete -F _bma_stacks_completion stacks
complete -F _bma_target-groups_completion target-group-targets
complete -F _bma_target-groups_completion target-groups
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