-
Notifications
You must be signed in to change notification settings - Fork 0
/
subspace-client.sh.bash-completion
262 lines (244 loc) · 9.15 KB
/
subspace-client.sh.bash-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
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
# subspace-client.sh completion -*- shell-script -*-
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !
# ! Note:
# !
# ! THIS SCRIPT HAS BEEN AUTOMATICALLY GENERATED USING
# ! openapi-generator (https://openapi-generator.tech)
# ! FROM OPENAPI SPECIFICATION IN JSON.
# !
# !
# !
# ! System wide installation:
# !
# ! $ sudo cp subspace-client.sh.bash-completion /etc/bash-completion.d/subspace-client.sh
# !
# !
# ! User home installation (add this line to .bash_profile):
# !
# ! [ -r ~/subspace-client.sh.bash-completion ] && source ~/subspace-client.sh.bash-completion
# !
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
declare -A mime_type_abbreviations
# text/*
mime_type_abbreviations["text"]="text/plain"
mime_type_abbreviations["html"]="text/html"
mime_type_abbreviations["md"]="text/x-markdown"
mime_type_abbreviations["csv"]="text/csv"
mime_type_abbreviations["css"]="text/css"
mime_type_abbreviations["rtf"]="text/rtf"
# application/*
mime_type_abbreviations["json"]="application/json"
mime_type_abbreviations["xml"]="application/xml"
mime_type_abbreviations["yaml"]="application/yaml"
mime_type_abbreviations["js"]="application/javascript"
mime_type_abbreviations["bin"]="application/octet-stream"
mime_type_abbreviations["rdf"]="application/rdf+xml"
# image/*
mime_type_abbreviations["jpg"]="image/jpeg"
mime_type_abbreviations["png"]="image/png"
mime_type_abbreviations["gif"]="image/gif"
mime_type_abbreviations["bmp"]="image/bmp"
mime_type_abbreviations["tiff"]="image/tiff"
#
# Check if this is OSX, if so defined custom init_completion
#
if [[ `uname` =~ "Darwin" ]]; then
__osx_init_completion()
{
COMPREPLY=()
_get_comp_words_by_ref cur prev words cword
}
fi
_subspace-client.sh()
{
local cur
local prev
local words
local cword
# The reference of currently selected REST operation
local operation=""
# The list of available operation in the REST service
# It's modelled as an associative array for efficient key lookup
declare -A operations
operations["acceleratorServiceCreate"]=1
operations["acceleratorServiceDelete"]=1
operations["acceleratorServiceGet"]=1
operations["acceleratorServiceList"]=1
operations["acceleratorServiceUpdate"]=1
operations["sipTeleportServiceCreate"]=1
operations["sipTeleportServiceDelete"]=1
operations["sipTeleportServiceGet"]=1
operations["sipTeleportServiceList"]=1
operations["sipTeleportServiceUpdate"]=1
operations["webRtcCdnServiceGetWebRtcCdn"]=1
# An associative array of operations to their parameters
# Only include path, query and header parameters
declare -A operation_parameters
operation_parameters["acceleratorServiceCreate"]="Idempotency-Key: "
operation_parameters["acceleratorServiceDelete"]="id= "
operation_parameters["acceleratorServiceGet"]="id= "
operation_parameters["acceleratorServiceList"]="before= limit= name= "
operation_parameters["acceleratorServiceUpdate"]="id= If-Match: "
operation_parameters["sipTeleportServiceCreate"]="Idempotency-Key: "
operation_parameters["sipTeleportServiceDelete"]="id= "
operation_parameters["sipTeleportServiceGet"]="id= "
operation_parameters["sipTeleportServiceList"]="before= limit= "
operation_parameters["sipTeleportServiceUpdate"]="id= "
operation_parameters["webRtcCdnServiceGetWebRtcCdn"]=""
# An associative array of possible values for enum parameters
declare -A operation_parameters_enum_values
#
# Check if this is OSX and use special __osx_init_completion function
#
if [[ `uname` =~ "Darwin" ]]; then
__osx_init_completion || return
else
_init_completion -s || return
fi
# Check if operation is already in the command line provided
for word in "${words[@]}"; do
if [[ -n $word && ${operations[$word]} ]]; then
operation="${word}"
fi
done
if [[ -z $operation ]]; then
case $prev in
--ciphers|--connect-timeout|-C|--continue-at|-F|--form|--form-string|\
--ftp-account|--ftp-alternative-to-user|-P|--ftp-port|-H|--header|-h|\
--help|--hostpubmd5|--keepalive-time|--krb|--limit-rate|--local-port|\
--mail-from|--mail-rcpt|--max-filesize|--max-redirs|-m|--max-time|\
--pass|--proto|--proto-redir|--proxy-user|--proxy1.0|-Q|--quote|-r|\
--range|-X|--request|--retry|--retry-delay|--retry-max-time|\
--socks5-gssapi-service|-t|--telnet-option|--tftp-blksize|-z|\
--time-cond|--url|-u|--user|-A|--user-agent|-V|--version|-w|\
--write-out|--resolve|--tlsuser|--tlspassword|--about)
return
;;
-K|--config|-b|--cookie|-c|--cookie-jar|-D|--dump-header|--egd-file|\
--key|--libcurl|-o|--output|--random-file|-T|--upload-file|--trace|\
--trace-ascii|--netrc-file)
_filedir
return
;;
--cacert|-E|--cert)
_filedir '@(c?(e)rt|cer|pem|der)'
return
;;
--capath)
_filedir -d
return
;;
--cert-type|--key-type)
COMPREPLY=( $( compgen -W 'DER PEM ENG' -- "$cur" ) )
return
;;
--crlfile)
_filedir crl
return
;;
-d|--data|--data-ascii|--data-binary|--data-urlencode)
if [[ $cur == \@* ]]; then
cur=${cur:1}
_filedir
COMPREPLY=( "${COMPREPLY[@]/#/@}" )
fi
return
;;
--delegation)
COMPREPLY=( $( compgen -W 'none policy always' -- "$cur" ) )
return
;;
--engine)
COMPREPLY=( $( compgen -W 'list' -- "$cur" ) )
return
;;
--ftp-method)
COMPREPLY=( $( compgen -W 'multicwd nocwd singlecwd' -- "$cur" ) )
return
;;
--ftp-ssl-ccc-mode)
COMPREPLY=( $( compgen -W 'active passive' -- "$cur" ) )
return
;;
--interface)
_available_interfaces -a
return
;;
-x|--proxy|--socks4|--socks4a|--socks5|--socks5-hostname)
_known_hosts_real
return
;;
--pubkey)
_filedir pub
return
;;
--stderr)
COMPREPLY=( $( compgen -W '-' -- "$cur" ) )
_filedir
return
;;
--tlsauthtype)
COMPREPLY=( $( compgen -W 'SRP' -- "$cur" ) )
return
;;
--host)
COMPREPLY=( $( compgen -W 'http:// https://' -- "$cur" ) )
return
;;
-ct|--content-type|-ac|--accept)
COMPREPLY=( $( compgen -W '${!mime_type_abbreviations[*]}' -- "$cur" ) )
return
;;
esac
fi
#
# Complete the server address based on ~/.ssh/known_hosts
# and ~/.ssh/config
#
local prefix=${COMP_WORDS[COMP_CWORD-2]}
local colon=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$colon" == ":" && ( $prefix == "https" || $prefix == "http" ) ]]; then
COMPREPLY=()
local comp_ssh_hosts=`[[ -f ~/.ssh/known_hosts ]] && \
( cat ~/.ssh/known_hosts | \
grep '^[a-zA-Z0-9]' | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ) ;
[[ -f ~/.ssh/config ]] && \
( cat ~/.ssh/config | \
grep "^Host " | \
awk '{print $2}' )`
COMPREPLY=( $( compgen -P '//' -W '${comp_ssh_hosts}' -- "${cur:2}") )
return
fi
#
# Complete the subspace-client.sh and cURL's arguments
#
if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '$(_parse_help curl) $(_parse_help $1)' -- "$cur" ) )
return
fi
#
# If the argument starts with a letter this could be either an operation
# or an operation parameter
# When $cur is empty, suggest the list of operations by default
#
if [[ $cur =~ ^[A-Za-z_0-9]* ]]; then
# If operation has not been yet selected, suggest the list of operations
# otherwise suggest arguments of this operation as declared in the
# OpenAPI specification
if [[ -z $operation ]]; then
COMPREPLY=( $(compgen -W '${!operations[*]}' -- ${cur}) )
else
COMPREPLY=( $(compgen -W '${operation_parameters[$operation]}' -- ${cur}) )
compopt -o nospace
fi
return
fi
} &&
complete -F _subspace-client.sh subspace-client.sh
# ex: ts=4 sw=4 et filetype=sh