MuranoCLI 2.2.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.agignore +3 -0
  3. data/.gitignore +18 -1
  4. data/.rubocop.yml +222 -0
  5. data/.trustme.sh +185 -0
  6. data/.trustme.vim +24 -0
  7. data/Gemfile +23 -4
  8. data/LICENSE.txt +1 -1
  9. data/MuranoCLI.gemspec +43 -8
  10. data/README.markdown +9 -11
  11. data/Rakefile +187 -143
  12. data/TODO.taskpaper +2 -2
  13. data/bin/murano +51 -52
  14. data/docs/basic_example.rst +436 -0
  15. data/docs/completions/murano_completion-bash +3484 -0
  16. data/docs/demo.md +32 -32
  17. data/docs/develop.rst +391 -0
  18. data/lib/MrMurano.rb +21 -7
  19. data/lib/MrMurano/Account.rb +159 -174
  20. data/lib/MrMurano/Business.rb +381 -0
  21. data/lib/MrMurano/Config-Migrate.rb +32 -26
  22. data/lib/MrMurano/Config.rb +407 -128
  23. data/lib/MrMurano/Content.rb +191 -0
  24. data/lib/MrMurano/Gateway.rb +489 -0
  25. data/lib/MrMurano/Keystore.rb +48 -0
  26. data/lib/MrMurano/Passwords.rb +103 -0
  27. data/lib/MrMurano/ProjectFile.rb +121 -79
  28. data/lib/MrMurano/ReCommander.rb +114 -10
  29. data/lib/MrMurano/Setting.rb +90 -0
  30. data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
  31. data/lib/MrMurano/Solution-Services.rb +461 -166
  32. data/lib/MrMurano/Solution-Users.rb +70 -31
  33. data/lib/MrMurano/Solution.rb +372 -13
  34. data/lib/MrMurano/SolutionId.rb +73 -0
  35. data/lib/MrMurano/SyncRoot.rb +137 -0
  36. data/lib/MrMurano/SyncUpDown.rb +594 -284
  37. data/lib/MrMurano/Webservice-Cors.rb +71 -0
  38. data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
  39. data/lib/MrMurano/Webservice-File.rb +193 -0
  40. data/lib/MrMurano/Webservice.rb +51 -0
  41. data/lib/MrMurano/commands.rb +18 -15
  42. data/lib/MrMurano/commands/business.rb +300 -6
  43. data/lib/MrMurano/commands/completion-bash.erb +166 -0
  44. data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
  45. data/lib/MrMurano/commands/completion.rb +76 -39
  46. data/lib/MrMurano/commands/config.rb +108 -44
  47. data/lib/MrMurano/commands/content.rb +115 -72
  48. data/lib/MrMurano/commands/cors.rb +29 -14
  49. data/lib/MrMurano/commands/devices.rb +286 -0
  50. data/lib/MrMurano/commands/domain.rb +52 -12
  51. data/lib/MrMurano/commands/gb.rb +24 -9
  52. data/lib/MrMurano/commands/globals.rb +64 -0
  53. data/lib/MrMurano/commands/init.rb +377 -155
  54. data/lib/MrMurano/commands/keystore.rb +92 -82
  55. data/lib/MrMurano/commands/link.rb +300 -0
  56. data/lib/MrMurano/commands/login.rb +74 -11
  57. data/lib/MrMurano/commands/logs.rb +63 -32
  58. data/lib/MrMurano/commands/mock.rb +57 -29
  59. data/lib/MrMurano/commands/password.rb +57 -39
  60. data/lib/MrMurano/commands/postgresql.rb +127 -94
  61. data/lib/MrMurano/commands/settings.rb +203 -0
  62. data/lib/MrMurano/commands/show.rb +79 -38
  63. data/lib/MrMurano/commands/solution.rb +423 -5
  64. data/lib/MrMurano/commands/solution_picker.rb +547 -0
  65. data/lib/MrMurano/commands/status.rb +195 -61
  66. data/lib/MrMurano/commands/sync.rb +78 -39
  67. data/lib/MrMurano/commands/timeseries.rb +71 -55
  68. data/lib/MrMurano/commands/tsdb.rb +113 -87
  69. data/lib/MrMurano/commands/usage.rb +57 -15
  70. data/lib/MrMurano/hash.rb +100 -10
  71. data/lib/MrMurano/http.rb +187 -43
  72. data/lib/MrMurano/makePretty.rb +16 -14
  73. data/lib/MrMurano/optparse.rb +2178 -0
  74. data/lib/MrMurano/progress.rb +138 -0
  75. data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
  76. data/lib/MrMurano/template/projectFile.murano.erb +16 -13
  77. data/lib/MrMurano/verbosing.rb +166 -29
  78. data/lib/MrMurano/version.rb +30 -1
  79. data/spec/Account-Passwords_spec.rb +21 -4
  80. data/spec/Account_spec.rb +69 -146
  81. data/spec/Business_spec.rb +290 -0
  82. data/spec/ConfigFile_spec.rb +1 -0
  83. data/spec/ConfigMigrate_spec.rb +12 -8
  84. data/spec/Config_spec.rb +40 -34
  85. data/spec/Content_spec.rb +363 -0
  86. data/spec/GatewayBase_spec.rb +54 -0
  87. data/spec/GatewayDevice_spec.rb +321 -0
  88. data/spec/GatewayResource_spec.rb +266 -0
  89. data/spec/GatewaySettings_spec.rb +120 -0
  90. data/spec/Http_spec.rb +18 -8
  91. data/spec/Mock_spec.rb +2 -2
  92. data/spec/ProjectFile_spec.rb +25 -14
  93. data/spec/Setting_spec.rb +110 -0
  94. data/spec/Solution-ServiceConfig_spec.rb +44 -5
  95. data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
  96. data/spec/Solution-ServiceModules_spec.rb +47 -37
  97. data/spec/Solution-UsersRoles_spec.rb +10 -8
  98. data/spec/Solution_spec.rb +17 -8
  99. data/spec/SyncRoot_spec.rb +46 -20
  100. data/spec/SyncUpDown_spec.rb +437 -201
  101. data/spec/Verbosing_spec.rb +12 -4
  102. data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
  103. data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
  104. data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
  105. data/spec/Webservice-Setting_spec.rb +89 -0
  106. data/spec/_workspace.rb +4 -4
  107. data/spec/cmd_business_spec.rb +9 -4
  108. data/spec/cmd_common.rb +44 -1
  109. data/spec/cmd_content_spec.rb +43 -17
  110. data/spec/cmd_cors_spec.rb +4 -4
  111. data/spec/cmd_device_spec.rb +61 -16
  112. data/spec/cmd_domain_spec.rb +29 -6
  113. data/spec/cmd_init_spec.rb +281 -126
  114. data/spec/cmd_keystore_spec.rb +3 -3
  115. data/spec/cmd_link_spec.rb +98 -0
  116. data/spec/cmd_password_spec.rb +1 -1
  117. data/spec/cmd_setting_application_spec.rb +260 -0
  118. data/spec/cmd_setting_product_spec.rb +220 -0
  119. data/spec/cmd_status_spec.rb +223 -114
  120. data/spec/cmd_syncdown_spec.rb +115 -35
  121. data/spec/cmd_syncup_spec.rb +68 -15
  122. data/spec/cmd_usage_spec.rb +35 -8
  123. data/spec/fixtures/dumped_config +6 -4
  124. data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
  125. data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
  126. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
  127. data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
  128. data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
  129. data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
  130. data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
  131. data/spec/spec_helper.rb +5 -0
  132. metadata +262 -171
  133. data/bin/mr +0 -8
  134. data/lib/MrMurano/Product-1P-Device.rb +0 -145
  135. data/lib/MrMurano/Product-Resources.rb +0 -205
  136. data/lib/MrMurano/Product.rb +0 -358
  137. data/lib/MrMurano/Solution-Cors.rb +0 -47
  138. data/lib/MrMurano/Solution-Endpoint.rb +0 -191
  139. data/lib/MrMurano/Solution-File.rb +0 -166
  140. data/lib/MrMurano/commands/assign.rb +0 -57
  141. data/lib/MrMurano/commands/businessList.rb +0 -45
  142. data/lib/MrMurano/commands/product.rb +0 -14
  143. data/lib/MrMurano/commands/productCreate.rb +0 -39
  144. data/lib/MrMurano/commands/productDelete.rb +0 -33
  145. data/lib/MrMurano/commands/productDevice.rb +0 -87
  146. data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
  147. data/lib/MrMurano/commands/productList.rb +0 -45
  148. data/lib/MrMurano/commands/productWrite.rb +0 -27
  149. data/lib/MrMurano/commands/solutionCreate.rb +0 -41
  150. data/lib/MrMurano/commands/solutionDelete.rb +0 -34
  151. data/lib/MrMurano/commands/solutionList.rb +0 -45
  152. data/spec/ProductBase_spec.rb +0 -113
  153. data/spec/ProductContent_spec.rb +0 -162
  154. data/spec/ProductResources_spec.rb +0 -329
  155. data/spec/Product_1P_Device_spec.rb +0 -202
  156. data/spec/Product_1P_RPC_spec.rb +0 -175
  157. data/spec/Product_spec.rb +0 -153
  158. data/spec/Solution-ServiceDevice_spec.rb +0 -176
  159. data/spec/cmd_assign_spec.rb +0 -51
@@ -0,0 +1,3484 @@
1
+ #!/bin/bash
2
+ # Bash completion (compspec) for murano.
3
+ # vim: set ai et sw=2 ts=2 ft=bash
4
+ # #ft=eruby
5
+
6
+ #__murano_common_options=(
7
+ __app_switches=(
8
+ --no-color
9
+ --config
10
+ --configfile
11
+ --curl
12
+ --dry
13
+ --exclude-scopes
14
+ --no-page
15
+ --no-plugins
16
+ --no-progress
17
+ --verbose
18
+ --help
19
+ --version
20
+ --trace
21
+ )
22
+
23
+ # Util. fcn.
24
+ function contains_element () {
25
+ local e
26
+ for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
27
+ return 1
28
+ }
29
+
30
+ # Completion "main".
31
+ function _murano () {
32
+ #local cmd0="${1##*/}"
33
+ local cmd0=""
34
+ local cmd1=""
35
+ local cmd2=""
36
+ #local -a cmdn
37
+ local last="${COMP_WORDS[COMP_CWORD]}"
38
+ local line="${COMP_LINE}"
39
+ local -a used_switches
40
+
41
+ local len=$(($COMP_CWORD - 1))
42
+ local idx
43
+ for ((idx=1; idx<=len; idx++)); do
44
+ local cur="${COMP_WORDS[$idx]}"
45
+ # If positional argument is not a flag, it's the command or subcommand.
46
+ if [[ $cur != -* ]]; then
47
+ if [[ -z $cmd0 ]]; then
48
+ cmd0="$cur"
49
+ elif [[ -z $cmd1 ]]; then
50
+ cmd1="$cur"
51
+ elif [[ -z $cmd2 ]]; then
52
+ cmd2="$cur"
53
+ #else
54
+ # cmdn+=("$cur")
55
+ fi
56
+ else
57
+ used_switches+=("$cur")
58
+ fi
59
+ done
60
+ #>&2 echo -e "\ncmd0=$cmd0 / cmd1=$cmd1 / cmd2=$cmd2 / len=$len"
61
+
62
+ if [[ -z $cmd0 ]]; then
63
+ local -a comp_list
64
+ comp_list=(
65
+ application
66
+ applications
67
+ assign
68
+ business
69
+ businesses
70
+ completion
71
+ config
72
+ content
73
+ cors
74
+ create
75
+ delete
76
+ device
77
+ devices
78
+ diff
79
+ domain
80
+ find
81
+ help
82
+ init
83
+ keystore
84
+ link
85
+ links
86
+ list
87
+ login
88
+ logout
89
+ logs
90
+ mock
91
+ password
92
+ passwords
93
+ postgresql
94
+ product
95
+ products
96
+ pull
97
+ push
98
+ setting
99
+ settings
100
+ show
101
+ solution
102
+ solutions
103
+ status
104
+ syncdown
105
+ syncup
106
+ tsdb
107
+ usage
108
+ )
109
+
110
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
111
+ local switch=${__app_switches[$idx]}
112
+ if ! contains_element "$switch" "${used_switches[@]}"; then
113
+ comp_list+=("$switch")
114
+ fi
115
+ done
116
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "$last"))
117
+ else
118
+ case $cmd0 in
119
+ (application)
120
+ __murano-application "$cmd1" "$cmd2" "${used_switches[@]}"
121
+ ;;
122
+ (applications)
123
+ __murano-applications "$cmd1" "$cmd2" "${used_switches[@]}"
124
+ ;;
125
+ (assign)
126
+ __murano-assign "$cmd1" "$cmd2" "${used_switches[@]}"
127
+ ;;
128
+ (business)
129
+ __murano-business "$cmd1" "$cmd2" "${used_switches[@]}"
130
+ ;;
131
+ (businesses)
132
+ __murano-businesses "$cmd1" "$cmd2" "${used_switches[@]}"
133
+ ;;
134
+ (completion)
135
+ __murano-completion "$cmd1" "$cmd2" "${used_switches[@]}"
136
+ ;;
137
+ (config)
138
+ __murano-config "$cmd1" "$cmd2" "${used_switches[@]}"
139
+ ;;
140
+ (content)
141
+ __murano-content "$cmd1" "$cmd2" "${used_switches[@]}"
142
+ ;;
143
+ (cors)
144
+ __murano-cors "$cmd1" "$cmd2" "${used_switches[@]}"
145
+ ;;
146
+ (create)
147
+ __murano-create "$cmd1" "$cmd2" "${used_switches[@]}"
148
+ ;;
149
+ (delete)
150
+ __murano-delete "$cmd1" "$cmd2" "${used_switches[@]}"
151
+ ;;
152
+ (device)
153
+ __murano-device "$cmd1" "$cmd2" "${used_switches[@]}"
154
+ ;;
155
+ (devices)
156
+ __murano-devices "$cmd1" "$cmd2" "${used_switches[@]}"
157
+ ;;
158
+ (diff)
159
+ __murano-diff "$cmd1" "$cmd2" "${used_switches[@]}"
160
+ ;;
161
+ (domain)
162
+ __murano-domain "$cmd1" "$cmd2" "${used_switches[@]}"
163
+ ;;
164
+ (find)
165
+ __murano-find "$cmd1" "$cmd2" "${used_switches[@]}"
166
+ ;;
167
+ (help)
168
+ __murano-help "$cmd1" "$cmd2" "${used_switches[@]}"
169
+ ;;
170
+ (init)
171
+ __murano-init "$cmd1" "$cmd2" "${used_switches[@]}"
172
+ ;;
173
+ (keystore)
174
+ __murano-keystore "$cmd1" "$cmd2" "${used_switches[@]}"
175
+ ;;
176
+ (link)
177
+ __murano-link "$cmd1" "$cmd2" "${used_switches[@]}"
178
+ ;;
179
+ (links)
180
+ __murano-links "$cmd1" "$cmd2" "${used_switches[@]}"
181
+ ;;
182
+ (list)
183
+ __murano-list "$cmd1" "$cmd2" "${used_switches[@]}"
184
+ ;;
185
+ (login)
186
+ __murano-login "$cmd1" "$cmd2" "${used_switches[@]}"
187
+ ;;
188
+ (logout)
189
+ __murano-logout "$cmd1" "$cmd2" "${used_switches[@]}"
190
+ ;;
191
+ (logs)
192
+ __murano-logs "$cmd1" "$cmd2" "${used_switches[@]}"
193
+ ;;
194
+ (mock)
195
+ __murano-mock "$cmd1" "$cmd2" "${used_switches[@]}"
196
+ ;;
197
+ (password)
198
+ __murano-password "$cmd1" "$cmd2" "${used_switches[@]}"
199
+ ;;
200
+ (passwords)
201
+ __murano-passwords "$cmd1" "$cmd2" "${used_switches[@]}"
202
+ ;;
203
+ (postgresql)
204
+ __murano-postgresql "$cmd1" "$cmd2" "${used_switches[@]}"
205
+ ;;
206
+ (product)
207
+ __murano-product "$cmd1" "$cmd2" "${used_switches[@]}"
208
+ ;;
209
+ (products)
210
+ __murano-products "$cmd1" "$cmd2" "${used_switches[@]}"
211
+ ;;
212
+ (pull)
213
+ __murano-pull "$cmd1" "$cmd2" "${used_switches[@]}"
214
+ ;;
215
+ (push)
216
+ __murano-push "$cmd1" "$cmd2" "${used_switches[@]}"
217
+ ;;
218
+ (setting)
219
+ __murano-setting "$cmd1" "$cmd2" "${used_switches[@]}"
220
+ ;;
221
+ (settings)
222
+ __murano-settings "$cmd1" "$cmd2" "${used_switches[@]}"
223
+ ;;
224
+ (show)
225
+ __murano-show "$cmd1" "$cmd2" "${used_switches[@]}"
226
+ ;;
227
+ (solution)
228
+ __murano-solution "$cmd1" "$cmd2" "${used_switches[@]}"
229
+ ;;
230
+ (solutions)
231
+ __murano-solutions "$cmd1" "$cmd2" "${used_switches[@]}"
232
+ ;;
233
+ (status)
234
+ __murano-status "$cmd1" "$cmd2" "${used_switches[@]}"
235
+ ;;
236
+ (syncdown)
237
+ __murano-syncdown "$cmd1" "$cmd2" "${used_switches[@]}"
238
+ ;;
239
+ (syncup)
240
+ __murano-syncup "$cmd1" "$cmd2" "${used_switches[@]}"
241
+ ;;
242
+ (tsdb)
243
+ __murano-tsdb "$cmd1" "$cmd2" "${used_switches[@]}"
244
+ ;;
245
+ (usage)
246
+ __murano-usage "$cmd1" "$cmd2" "${used_switches[@]}"
247
+ ;;
248
+ esac
249
+ fi
250
+ }
251
+
252
+ # Completion for subcommand: "application".
253
+ function __murano-application () {
254
+ local subcmd1="$1"
255
+ local subcmd2="$2"
256
+ #local subcmdn="$3"
257
+ local used_switches="${@:3}"
258
+ local last="${COMP_WORDS[COMP_CWORD]}"
259
+ local len=$(($COMP_CWORD - 1))
260
+
261
+ local -a more_switches
262
+
263
+ local -a comp_list
264
+
265
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
266
+ #>&2 echo "used_switches=$used_switches"
267
+ #>&2 echo "more_switches=$more_switches"
268
+
269
+ # NOTE: Not doing anything special for ${subcmd2}.
270
+ # Are there sub-sub-commands we shoud list?
271
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
272
+ comp_list=(
273
+ create
274
+ delete
275
+ diff
276
+ domain
277
+ find
278
+ list
279
+ logs
280
+ pull
281
+ push
282
+ usage
283
+ )
284
+ else
285
+ case $subcmd1 in
286
+ (create)
287
+ more_switches=(
288
+ {--trace}
289
+ )
290
+ ;;
291
+ (delete)
292
+ more_switches=(
293
+ {--trace}
294
+ )
295
+ ;;
296
+ (diff)
297
+ more_switches=(
298
+ {--trace}
299
+ )
300
+ ;;
301
+ (domain)
302
+ more_switches=(
303
+ {--trace}
304
+ )
305
+ ;;
306
+ (find)
307
+ more_switches=(
308
+ {--trace}
309
+ )
310
+ ;;
311
+ (list)
312
+ more_switches=(
313
+ {--trace}
314
+ )
315
+ ;;
316
+ (logs)
317
+ more_switches=(
318
+ {--trace}
319
+ )
320
+ ;;
321
+ (pull)
322
+ more_switches=(
323
+ {--trace}
324
+ )
325
+ ;;
326
+ (push)
327
+ more_switches=(
328
+ {--trace}
329
+ )
330
+ ;;
331
+ (usage)
332
+ more_switches=(
333
+ {--trace}
334
+ )
335
+ ;;
336
+ esac
337
+ fi
338
+
339
+ # Add unused application-wide flags.
340
+ local idx
341
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
342
+ local switch=${__app_switches[$idx]}
343
+ if ! contains_element "$switch" "${used_switches[@]}"; then
344
+ comp_list+=("$switch")
345
+ fi
346
+ done
347
+ # Add unused subcommand flags.
348
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
349
+ local switch=${more_switches[$idx]}
350
+ comp_list+=("$switch")
351
+ done
352
+
353
+ # If there are only --flags, <TAB> will put the common prefix,
354
+ # "--", but maybe the user doesn't want to add a flag after all.
355
+ if [[ -z ${last} ]]; then
356
+ local flags_only=true
357
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
358
+ local switch=${comp_list[$idx]}
359
+ if [[ ${switch} != --* ]]; then
360
+ flags_only=false
361
+ break
362
+ fi
363
+ done
364
+ if ${flags_only}; then
365
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
366
+ comp_list+=("  ")
367
+ fi
368
+ fi
369
+
370
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
371
+ }
372
+
373
+ # Completion for subcommand: "applications".
374
+ function __murano-applications () {
375
+ local subcmd1="$1"
376
+ local subcmd2="$2"
377
+ #local subcmdn="$3"
378
+ local used_switches="${@:3}"
379
+ local last="${COMP_WORDS[COMP_CWORD]}"
380
+ local len=$(($COMP_CWORD - 1))
381
+
382
+ local -a more_switches
383
+
384
+ local -a comp_list
385
+
386
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
387
+ #>&2 echo "used_switches=$used_switches"
388
+ #>&2 echo "more_switches=$more_switches"
389
+
390
+ # NOTE: Not doing anything special for ${subcmd2}.
391
+ # Are there sub-sub-commands we shoud list?
392
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
393
+ comp_list=(
394
+ list
395
+ )
396
+ else
397
+ case $subcmd1 in
398
+ (list)
399
+ more_switches=(
400
+ {--trace}
401
+ )
402
+ ;;
403
+ esac
404
+ fi
405
+
406
+ # Add unused application-wide flags.
407
+ local idx
408
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
409
+ local switch=${__app_switches[$idx]}
410
+ if ! contains_element "$switch" "${used_switches[@]}"; then
411
+ comp_list+=("$switch")
412
+ fi
413
+ done
414
+ # Add unused subcommand flags.
415
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
416
+ local switch=${more_switches[$idx]}
417
+ comp_list+=("$switch")
418
+ done
419
+
420
+ # If there are only --flags, <TAB> will put the common prefix,
421
+ # "--", but maybe the user doesn't want to add a flag after all.
422
+ if [[ -z ${last} ]]; then
423
+ local flags_only=true
424
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
425
+ local switch=${comp_list[$idx]}
426
+ if [[ ${switch} != --* ]]; then
427
+ flags_only=false
428
+ break
429
+ fi
430
+ done
431
+ if ${flags_only}; then
432
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
433
+ comp_list+=("  ")
434
+ fi
435
+ fi
436
+
437
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
438
+ }
439
+
440
+ # Completion for subcommand: "assign".
441
+ function __murano-assign () {
442
+ local subcmd1="$1"
443
+ local subcmd2="$2"
444
+ #local subcmdn="$3"
445
+ local used_switches="${@:3}"
446
+ local last="${COMP_WORDS[COMP_CWORD]}"
447
+ local len=$(($COMP_CWORD - 1))
448
+
449
+ local -a more_switches
450
+
451
+ local -a comp_list
452
+
453
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
454
+ #>&2 echo "used_switches=$used_switches"
455
+ #>&2 echo "more_switches=$more_switches"
456
+
457
+ # NOTE: Not doing anything special for ${subcmd2}.
458
+ # Are there sub-sub-commands we shoud list?
459
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
460
+ comp_list=(
461
+ list
462
+ set
463
+ unset
464
+ )
465
+ else
466
+ case $subcmd1 in
467
+ (list)
468
+ more_switches=(
469
+ {--trace}
470
+ )
471
+ ;;
472
+ (set)
473
+ more_switches=(
474
+ {--trace}
475
+ )
476
+ ;;
477
+ (unset)
478
+ more_switches=(
479
+ {--trace}
480
+ )
481
+ ;;
482
+ esac
483
+ fi
484
+
485
+ # Add unused application-wide flags.
486
+ local idx
487
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
488
+ local switch=${__app_switches[$idx]}
489
+ if ! contains_element "$switch" "${used_switches[@]}"; then
490
+ comp_list+=("$switch")
491
+ fi
492
+ done
493
+ # Add unused subcommand flags.
494
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
495
+ local switch=${more_switches[$idx]}
496
+ comp_list+=("$switch")
497
+ done
498
+
499
+ # If there are only --flags, <TAB> will put the common prefix,
500
+ # "--", but maybe the user doesn't want to add a flag after all.
501
+ if [[ -z ${last} ]]; then
502
+ local flags_only=true
503
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
504
+ local switch=${comp_list[$idx]}
505
+ if [[ ${switch} != --* ]]; then
506
+ flags_only=false
507
+ break
508
+ fi
509
+ done
510
+ if ${flags_only}; then
511
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
512
+ comp_list+=("  ")
513
+ fi
514
+ fi
515
+
516
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
517
+ }
518
+
519
+ # Completion for subcommand: "business".
520
+ function __murano-business () {
521
+ local subcmd1="$1"
522
+ local subcmd2="$2"
523
+ #local subcmdn="$3"
524
+ local used_switches="${@:3}"
525
+ local last="${COMP_WORDS[COMP_CWORD]}"
526
+ local len=$(($COMP_CWORD - 1))
527
+
528
+ local -a more_switches
529
+
530
+ local -a comp_list
531
+
532
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
533
+ #>&2 echo "used_switches=$used_switches"
534
+ #>&2 echo "more_switches=$more_switches"
535
+
536
+ # NOTE: Not doing anything special for ${subcmd2}.
537
+ # Are there sub-sub-commands we shoud list?
538
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
539
+ comp_list=(
540
+ find
541
+ list
542
+ )
543
+ else
544
+ case $subcmd1 in
545
+ (find)
546
+ more_switches=(
547
+ {--trace}
548
+ )
549
+ ;;
550
+ (list)
551
+ more_switches=(
552
+ {--trace}
553
+ )
554
+ ;;
555
+ esac
556
+ fi
557
+
558
+ # Add unused application-wide flags.
559
+ local idx
560
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
561
+ local switch=${__app_switches[$idx]}
562
+ if ! contains_element "$switch" "${used_switches[@]}"; then
563
+ comp_list+=("$switch")
564
+ fi
565
+ done
566
+ # Add unused subcommand flags.
567
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
568
+ local switch=${more_switches[$idx]}
569
+ comp_list+=("$switch")
570
+ done
571
+
572
+ # If there are only --flags, <TAB> will put the common prefix,
573
+ # "--", but maybe the user doesn't want to add a flag after all.
574
+ if [[ -z ${last} ]]; then
575
+ local flags_only=true
576
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
577
+ local switch=${comp_list[$idx]}
578
+ if [[ ${switch} != --* ]]; then
579
+ flags_only=false
580
+ break
581
+ fi
582
+ done
583
+ if ${flags_only}; then
584
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
585
+ comp_list+=("  ")
586
+ fi
587
+ fi
588
+
589
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
590
+ }
591
+
592
+ # Completion for subcommand: "businesses".
593
+ function __murano-businesses () {
594
+ local subcmd1="$1"
595
+ local subcmd2="$2"
596
+ #local subcmdn="$3"
597
+ local used_switches="${@:3}"
598
+ local last="${COMP_WORDS[COMP_CWORD]}"
599
+ local len=$(($COMP_CWORD - 1))
600
+
601
+ local -a more_switches
602
+
603
+ local -a comp_list
604
+
605
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
606
+ #>&2 echo "used_switches=$used_switches"
607
+ #>&2 echo "more_switches=$more_switches"
608
+
609
+ # NOTE: Not doing anything special for ${subcmd2}.
610
+ # Are there sub-sub-commands we shoud list?
611
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
612
+ comp_list=(
613
+ list
614
+ )
615
+ else
616
+ case $subcmd1 in
617
+ (list)
618
+ more_switches=(
619
+ {--trace}
620
+ )
621
+ ;;
622
+ esac
623
+ fi
624
+
625
+ # Add unused application-wide flags.
626
+ local idx
627
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
628
+ local switch=${__app_switches[$idx]}
629
+ if ! contains_element "$switch" "${used_switches[@]}"; then
630
+ comp_list+=("$switch")
631
+ fi
632
+ done
633
+ # Add unused subcommand flags.
634
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
635
+ local switch=${more_switches[$idx]}
636
+ comp_list+=("$switch")
637
+ done
638
+
639
+ # If there are only --flags, <TAB> will put the common prefix,
640
+ # "--", but maybe the user doesn't want to add a flag after all.
641
+ if [[ -z ${last} ]]; then
642
+ local flags_only=true
643
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
644
+ local switch=${comp_list[$idx]}
645
+ if [[ ${switch} != --* ]]; then
646
+ flags_only=false
647
+ break
648
+ fi
649
+ done
650
+ if ${flags_only}; then
651
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
652
+ comp_list+=("  ")
653
+ fi
654
+ fi
655
+
656
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
657
+ }
658
+
659
+ # Completion for subcommand: "completion".
660
+ function __murano-completion () {
661
+ local subcmd1="$1"
662
+ local subcmd2="$2"
663
+ #local subcmdn="$3"
664
+ local used_switches="${@:3}"
665
+ local last="${COMP_WORDS[COMP_CWORD]}"
666
+ local len=$(($COMP_CWORD - 1))
667
+
668
+ local -a more_switches
669
+
670
+ local -a comp_list
671
+
672
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
673
+ #>&2 echo "used_switches=$used_switches"
674
+ #>&2 echo "more_switches=$more_switches"
675
+
676
+ # NOTE: Not doing anything special for ${subcmd2}.
677
+ # Are there sub-sub-commands we shoud list?
678
+
679
+ # Add unused application-wide flags.
680
+ local idx
681
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
682
+ local switch=${__app_switches[$idx]}
683
+ if ! contains_element "$switch" "${used_switches[@]}"; then
684
+ comp_list+=("$switch")
685
+ fi
686
+ done
687
+ # Add unused subcommand flags.
688
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
689
+ local switch=${more_switches[$idx]}
690
+ comp_list+=("$switch")
691
+ done
692
+
693
+ # If there are only --flags, <TAB> will put the common prefix,
694
+ # "--", but maybe the user doesn't want to add a flag after all.
695
+ if [[ -z ${last} ]]; then
696
+ local flags_only=true
697
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
698
+ local switch=${comp_list[$idx]}
699
+ if [[ ${switch} != --* ]]; then
700
+ flags_only=false
701
+ break
702
+ fi
703
+ done
704
+ if ${flags_only}; then
705
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
706
+ comp_list+=("  ")
707
+ fi
708
+ fi
709
+
710
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
711
+ }
712
+
713
+ # Completion for subcommand: "config".
714
+ function __murano-config () {
715
+ local subcmd1="$1"
716
+ local subcmd2="$2"
717
+ #local subcmdn="$3"
718
+ local used_switches="${@:3}"
719
+ local last="${COMP_WORDS[COMP_CWORD]}"
720
+ local len=$(($COMP_CWORD - 1))
721
+
722
+ local -a more_switches
723
+
724
+ local -a comp_list
725
+
726
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
727
+ #>&2 echo "used_switches=$used_switches"
728
+ #>&2 echo "more_switches=$more_switches"
729
+
730
+ # NOTE: Not doing anything special for ${subcmd2}.
731
+ # Are there sub-sub-commands we shoud list?
732
+
733
+ # Add unused application-wide flags.
734
+ local idx
735
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
736
+ local switch=${__app_switches[$idx]}
737
+ if ! contains_element "$switch" "${used_switches[@]}"; then
738
+ comp_list+=("$switch")
739
+ fi
740
+ done
741
+ # Add unused subcommand flags.
742
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
743
+ local switch=${more_switches[$idx]}
744
+ comp_list+=("$switch")
745
+ done
746
+
747
+ # If there are only --flags, <TAB> will put the common prefix,
748
+ # "--", but maybe the user doesn't want to add a flag after all.
749
+ if [[ -z ${last} ]]; then
750
+ local flags_only=true
751
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
752
+ local switch=${comp_list[$idx]}
753
+ if [[ ${switch} != --* ]]; then
754
+ flags_only=false
755
+ break
756
+ fi
757
+ done
758
+ if ${flags_only}; then
759
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
760
+ comp_list+=("  ")
761
+ fi
762
+ fi
763
+
764
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
765
+ }
766
+
767
+ # Completion for subcommand: "content".
768
+ function __murano-content () {
769
+ local subcmd1="$1"
770
+ local subcmd2="$2"
771
+ #local subcmdn="$3"
772
+ local used_switches="${@:3}"
773
+ local last="${COMP_WORDS[COMP_CWORD]}"
774
+ local len=$(($COMP_CWORD - 1))
775
+
776
+ local -a more_switches
777
+
778
+ local -a comp_list
779
+
780
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
781
+ #>&2 echo "used_switches=$used_switches"
782
+ #>&2 echo "more_switches=$more_switches"
783
+
784
+ # NOTE: Not doing anything special for ${subcmd2}.
785
+ # Are there sub-sub-commands we shoud list?
786
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
787
+ comp_list=(
788
+ delete
789
+ download
790
+ info
791
+ list
792
+ upload
793
+ )
794
+ else
795
+ case $subcmd1 in
796
+ (delete)
797
+ more_switches=(
798
+ )
799
+ ;;
800
+ (download)
801
+ more_switches=(
802
+ {--trace}
803
+ )
804
+ ;;
805
+ (info)
806
+ more_switches=(
807
+ )
808
+ ;;
809
+ (list)
810
+ more_switches=(
811
+ {--trace}
812
+ )
813
+ ;;
814
+ (upload)
815
+ more_switches=(
816
+ {--trace}
817
+ )
818
+ ;;
819
+ esac
820
+ fi
821
+
822
+ # Add unused application-wide flags.
823
+ local idx
824
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
825
+ local switch=${__app_switches[$idx]}
826
+ if ! contains_element "$switch" "${used_switches[@]}"; then
827
+ comp_list+=("$switch")
828
+ fi
829
+ done
830
+ # Add unused subcommand flags.
831
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
832
+ local switch=${more_switches[$idx]}
833
+ comp_list+=("$switch")
834
+ done
835
+
836
+ # If there are only --flags, <TAB> will put the common prefix,
837
+ # "--", but maybe the user doesn't want to add a flag after all.
838
+ if [[ -z ${last} ]]; then
839
+ local flags_only=true
840
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
841
+ local switch=${comp_list[$idx]}
842
+ if [[ ${switch} != --* ]]; then
843
+ flags_only=false
844
+ break
845
+ fi
846
+ done
847
+ if ${flags_only}; then
848
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
849
+ comp_list+=("  ")
850
+ fi
851
+ fi
852
+
853
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
854
+ }
855
+
856
+ # Completion for subcommand: "cors".
857
+ function __murano-cors () {
858
+ local subcmd1="$1"
859
+ local subcmd2="$2"
860
+ #local subcmdn="$3"
861
+ local used_switches="${@:3}"
862
+ local last="${COMP_WORDS[COMP_CWORD]}"
863
+ local len=$(($COMP_CWORD - 1))
864
+
865
+ local -a more_switches
866
+
867
+ local -a comp_list
868
+
869
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
870
+ #>&2 echo "used_switches=$used_switches"
871
+ #>&2 echo "more_switches=$more_switches"
872
+
873
+ # NOTE: Not doing anything special for ${subcmd2}.
874
+ # Are there sub-sub-commands we shoud list?
875
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
876
+ comp_list=(
877
+ set
878
+ )
879
+ else
880
+ case $subcmd1 in
881
+ (set)
882
+ more_switches=(
883
+ )
884
+ ;;
885
+ esac
886
+ fi
887
+
888
+ # Add unused application-wide flags.
889
+ local idx
890
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
891
+ local switch=${__app_switches[$idx]}
892
+ if ! contains_element "$switch" "${used_switches[@]}"; then
893
+ comp_list+=("$switch")
894
+ fi
895
+ done
896
+ # Add unused subcommand flags.
897
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
898
+ local switch=${more_switches[$idx]}
899
+ comp_list+=("$switch")
900
+ done
901
+
902
+ # If there are only --flags, <TAB> will put the common prefix,
903
+ # "--", but maybe the user doesn't want to add a flag after all.
904
+ if [[ -z ${last} ]]; then
905
+ local flags_only=true
906
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
907
+ local switch=${comp_list[$idx]}
908
+ if [[ ${switch} != --* ]]; then
909
+ flags_only=false
910
+ break
911
+ fi
912
+ done
913
+ if ${flags_only}; then
914
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
915
+ comp_list+=("  ")
916
+ fi
917
+ fi
918
+
919
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
920
+ }
921
+
922
+ # Completion for subcommand: "create".
923
+ function __murano-create () {
924
+ local subcmd1="$1"
925
+ local subcmd2="$2"
926
+ #local subcmdn="$3"
927
+ local used_switches="${@:3}"
928
+ local last="${COMP_WORDS[COMP_CWORD]}"
929
+ local len=$(($COMP_CWORD - 1))
930
+
931
+ local -a more_switches
932
+
933
+ local -a comp_list
934
+
935
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
936
+ #>&2 echo "used_switches=$used_switches"
937
+ #>&2 echo "more_switches=$more_switches"
938
+
939
+ # NOTE: Not doing anything special for ${subcmd2}.
940
+ # Are there sub-sub-commands we shoud list?
941
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
942
+ comp_list=(
943
+ application
944
+ product
945
+ )
946
+ else
947
+ case $subcmd1 in
948
+ (application)
949
+ more_switches=(
950
+ {--trace}
951
+ )
952
+ ;;
953
+ (product)
954
+ more_switches=(
955
+ {--trace}
956
+ )
957
+ ;;
958
+ esac
959
+ fi
960
+
961
+ # Add unused application-wide flags.
962
+ local idx
963
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
964
+ local switch=${__app_switches[$idx]}
965
+ if ! contains_element "$switch" "${used_switches[@]}"; then
966
+ comp_list+=("$switch")
967
+ fi
968
+ done
969
+ # Add unused subcommand flags.
970
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
971
+ local switch=${more_switches[$idx]}
972
+ comp_list+=("$switch")
973
+ done
974
+
975
+ # If there are only --flags, <TAB> will put the common prefix,
976
+ # "--", but maybe the user doesn't want to add a flag after all.
977
+ if [[ -z ${last} ]]; then
978
+ local flags_only=true
979
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
980
+ local switch=${comp_list[$idx]}
981
+ if [[ ${switch} != --* ]]; then
982
+ flags_only=false
983
+ break
984
+ fi
985
+ done
986
+ if ${flags_only}; then
987
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
988
+ comp_list+=("  ")
989
+ fi
990
+ fi
991
+
992
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
993
+ }
994
+
995
+ # Completion for subcommand: "delete".
996
+ function __murano-delete () {
997
+ local subcmd1="$1"
998
+ local subcmd2="$2"
999
+ #local subcmdn="$3"
1000
+ local used_switches="${@:3}"
1001
+ local last="${COMP_WORDS[COMP_CWORD]}"
1002
+ local len=$(($COMP_CWORD - 1))
1003
+
1004
+ local -a more_switches
1005
+
1006
+ local -a comp_list
1007
+
1008
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1009
+ #>&2 echo "used_switches=$used_switches"
1010
+ #>&2 echo "more_switches=$more_switches"
1011
+
1012
+ # NOTE: Not doing anything special for ${subcmd2}.
1013
+ # Are there sub-sub-commands we shoud list?
1014
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1015
+ comp_list=(
1016
+ application
1017
+ product
1018
+ )
1019
+ else
1020
+ case $subcmd1 in
1021
+ (application)
1022
+ more_switches=(
1023
+ {--trace}
1024
+ )
1025
+ ;;
1026
+ (product)
1027
+ more_switches=(
1028
+ {--trace}
1029
+ )
1030
+ ;;
1031
+ esac
1032
+ fi
1033
+
1034
+ # Add unused application-wide flags.
1035
+ local idx
1036
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1037
+ local switch=${__app_switches[$idx]}
1038
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1039
+ comp_list+=("$switch")
1040
+ fi
1041
+ done
1042
+ # Add unused subcommand flags.
1043
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1044
+ local switch=${more_switches[$idx]}
1045
+ comp_list+=("$switch")
1046
+ done
1047
+
1048
+ # If there are only --flags, <TAB> will put the common prefix,
1049
+ # "--", but maybe the user doesn't want to add a flag after all.
1050
+ if [[ -z ${last} ]]; then
1051
+ local flags_only=true
1052
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1053
+ local switch=${comp_list[$idx]}
1054
+ if [[ ${switch} != --* ]]; then
1055
+ flags_only=false
1056
+ break
1057
+ fi
1058
+ done
1059
+ if ${flags_only}; then
1060
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1061
+ comp_list+=("  ")
1062
+ fi
1063
+ fi
1064
+
1065
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1066
+ }
1067
+
1068
+ # Completion for subcommand: "device".
1069
+ function __murano-device () {
1070
+ local subcmd1="$1"
1071
+ local subcmd2="$2"
1072
+ #local subcmdn="$3"
1073
+ local used_switches="${@:3}"
1074
+ local last="${COMP_WORDS[COMP_CWORD]}"
1075
+ local len=$(($COMP_CWORD - 1))
1076
+
1077
+ local -a more_switches
1078
+
1079
+ local -a comp_list
1080
+
1081
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1082
+ #>&2 echo "used_switches=$used_switches"
1083
+ #>&2 echo "more_switches=$more_switches"
1084
+
1085
+ # NOTE: Not doing anything special for ${subcmd2}.
1086
+ # Are there sub-sub-commands we shoud list?
1087
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1088
+ comp_list=(
1089
+ activate
1090
+ delete
1091
+ enable
1092
+ httpurl
1093
+ list
1094
+ read
1095
+ write
1096
+ )
1097
+ else
1098
+ case $subcmd1 in
1099
+ (activate)
1100
+ more_switches=(
1101
+ )
1102
+ ;;
1103
+ (delete)
1104
+ more_switches=(
1105
+ )
1106
+ ;;
1107
+ (enable)
1108
+ more_switches=(
1109
+ {--trace}
1110
+ )
1111
+ ;;
1112
+ (httpurl)
1113
+ more_switches=(
1114
+ )
1115
+ ;;
1116
+ (list)
1117
+ more_switches=(
1118
+ {--trace}
1119
+ )
1120
+ ;;
1121
+ (read)
1122
+ more_switches=(
1123
+ {--trace}
1124
+ )
1125
+ ;;
1126
+ (write)
1127
+ more_switches=(
1128
+ )
1129
+ ;;
1130
+ esac
1131
+ fi
1132
+
1133
+ # Add unused application-wide flags.
1134
+ local idx
1135
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1136
+ local switch=${__app_switches[$idx]}
1137
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1138
+ comp_list+=("$switch")
1139
+ fi
1140
+ done
1141
+ # Add unused subcommand flags.
1142
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1143
+ local switch=${more_switches[$idx]}
1144
+ comp_list+=("$switch")
1145
+ done
1146
+
1147
+ # If there are only --flags, <TAB> will put the common prefix,
1148
+ # "--", but maybe the user doesn't want to add a flag after all.
1149
+ if [[ -z ${last} ]]; then
1150
+ local flags_only=true
1151
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1152
+ local switch=${comp_list[$idx]}
1153
+ if [[ ${switch} != --* ]]; then
1154
+ flags_only=false
1155
+ break
1156
+ fi
1157
+ done
1158
+ if ${flags_only}; then
1159
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1160
+ comp_list+=("  ")
1161
+ fi
1162
+ fi
1163
+
1164
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1165
+ }
1166
+
1167
+ # Completion for subcommand: "devices".
1168
+ function __murano-devices () {
1169
+ local subcmd1="$1"
1170
+ local subcmd2="$2"
1171
+ #local subcmdn="$3"
1172
+ local used_switches="${@:3}"
1173
+ local last="${COMP_WORDS[COMP_CWORD]}"
1174
+ local len=$(($COMP_CWORD - 1))
1175
+
1176
+ local -a more_switches
1177
+
1178
+ local -a comp_list
1179
+
1180
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1181
+ #>&2 echo "used_switches=$used_switches"
1182
+ #>&2 echo "more_switches=$more_switches"
1183
+
1184
+ # NOTE: Not doing anything special for ${subcmd2}.
1185
+ # Are there sub-sub-commands we shoud list?
1186
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1187
+ comp_list=(
1188
+ list
1189
+ )
1190
+ else
1191
+ case $subcmd1 in
1192
+ (list)
1193
+ more_switches=(
1194
+ {--trace}
1195
+ )
1196
+ ;;
1197
+ esac
1198
+ fi
1199
+
1200
+ # Add unused application-wide flags.
1201
+ local idx
1202
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1203
+ local switch=${__app_switches[$idx]}
1204
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1205
+ comp_list+=("$switch")
1206
+ fi
1207
+ done
1208
+ # Add unused subcommand flags.
1209
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1210
+ local switch=${more_switches[$idx]}
1211
+ comp_list+=("$switch")
1212
+ done
1213
+
1214
+ # If there are only --flags, <TAB> will put the common prefix,
1215
+ # "--", but maybe the user doesn't want to add a flag after all.
1216
+ if [[ -z ${last} ]]; then
1217
+ local flags_only=true
1218
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1219
+ local switch=${comp_list[$idx]}
1220
+ if [[ ${switch} != --* ]]; then
1221
+ flags_only=false
1222
+ break
1223
+ fi
1224
+ done
1225
+ if ${flags_only}; then
1226
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1227
+ comp_list+=("  ")
1228
+ fi
1229
+ fi
1230
+
1231
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1232
+ }
1233
+
1234
+ # Completion for subcommand: "diff".
1235
+ function __murano-diff () {
1236
+ local subcmd1="$1"
1237
+ local subcmd2="$2"
1238
+ #local subcmdn="$3"
1239
+ local used_switches="${@:3}"
1240
+ local last="${COMP_WORDS[COMP_CWORD]}"
1241
+ local len=$(($COMP_CWORD - 1))
1242
+
1243
+ local -a more_switches
1244
+
1245
+ local -a comp_list
1246
+
1247
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1248
+ #>&2 echo "used_switches=$used_switches"
1249
+ #>&2 echo "more_switches=$more_switches"
1250
+
1251
+ # NOTE: Not doing anything special for ${subcmd2}.
1252
+ # Are there sub-sub-commands we shoud list?
1253
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1254
+ comp_list=(
1255
+ application
1256
+ product
1257
+ )
1258
+ else
1259
+ case $subcmd1 in
1260
+ (application)
1261
+ more_switches=(
1262
+ {--trace}
1263
+ )
1264
+ ;;
1265
+ (product)
1266
+ more_switches=(
1267
+ {--trace}
1268
+ )
1269
+ ;;
1270
+ esac
1271
+ fi
1272
+
1273
+ # Add unused application-wide flags.
1274
+ local idx
1275
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1276
+ local switch=${__app_switches[$idx]}
1277
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1278
+ comp_list+=("$switch")
1279
+ fi
1280
+ done
1281
+ # Add unused subcommand flags.
1282
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1283
+ local switch=${more_switches[$idx]}
1284
+ comp_list+=("$switch")
1285
+ done
1286
+
1287
+ # If there are only --flags, <TAB> will put the common prefix,
1288
+ # "--", but maybe the user doesn't want to add a flag after all.
1289
+ if [[ -z ${last} ]]; then
1290
+ local flags_only=true
1291
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1292
+ local switch=${comp_list[$idx]}
1293
+ if [[ ${switch} != --* ]]; then
1294
+ flags_only=false
1295
+ break
1296
+ fi
1297
+ done
1298
+ if ${flags_only}; then
1299
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1300
+ comp_list+=("  ")
1301
+ fi
1302
+ fi
1303
+
1304
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1305
+ }
1306
+
1307
+ # Completion for subcommand: "domain".
1308
+ function __murano-domain () {
1309
+ local subcmd1="$1"
1310
+ local subcmd2="$2"
1311
+ #local subcmdn="$3"
1312
+ local used_switches="${@:3}"
1313
+ local last="${COMP_WORDS[COMP_CWORD]}"
1314
+ local len=$(($COMP_CWORD - 1))
1315
+
1316
+ local -a more_switches
1317
+
1318
+ local -a comp_list
1319
+
1320
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1321
+ #>&2 echo "used_switches=$used_switches"
1322
+ #>&2 echo "more_switches=$more_switches"
1323
+
1324
+ # NOTE: Not doing anything special for ${subcmd2}.
1325
+ # Are there sub-sub-commands we shoud list?
1326
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1327
+ comp_list=(
1328
+ application
1329
+ product
1330
+ )
1331
+ else
1332
+ case $subcmd1 in
1333
+ (application)
1334
+ more_switches=(
1335
+ {--trace}
1336
+ )
1337
+ ;;
1338
+ (product)
1339
+ more_switches=(
1340
+ {--trace}
1341
+ )
1342
+ ;;
1343
+ esac
1344
+ fi
1345
+
1346
+ # Add unused application-wide flags.
1347
+ local idx
1348
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1349
+ local switch=${__app_switches[$idx]}
1350
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1351
+ comp_list+=("$switch")
1352
+ fi
1353
+ done
1354
+ # Add unused subcommand flags.
1355
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1356
+ local switch=${more_switches[$idx]}
1357
+ comp_list+=("$switch")
1358
+ done
1359
+
1360
+ # If there are only --flags, <TAB> will put the common prefix,
1361
+ # "--", but maybe the user doesn't want to add a flag after all.
1362
+ if [[ -z ${last} ]]; then
1363
+ local flags_only=true
1364
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1365
+ local switch=${comp_list[$idx]}
1366
+ if [[ ${switch} != --* ]]; then
1367
+ flags_only=false
1368
+ break
1369
+ fi
1370
+ done
1371
+ if ${flags_only}; then
1372
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1373
+ comp_list+=("  ")
1374
+ fi
1375
+ fi
1376
+
1377
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1378
+ }
1379
+
1380
+ # Completion for subcommand: "find".
1381
+ function __murano-find () {
1382
+ local subcmd1="$1"
1383
+ local subcmd2="$2"
1384
+ #local subcmdn="$3"
1385
+ local used_switches="${@:3}"
1386
+ local last="${COMP_WORDS[COMP_CWORD]}"
1387
+ local len=$(($COMP_CWORD - 1))
1388
+
1389
+ local -a more_switches
1390
+
1391
+ local -a comp_list
1392
+
1393
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1394
+ #>&2 echo "used_switches=$used_switches"
1395
+ #>&2 echo "more_switches=$more_switches"
1396
+
1397
+ # NOTE: Not doing anything special for ${subcmd2}.
1398
+ # Are there sub-sub-commands we shoud list?
1399
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1400
+ comp_list=(
1401
+ application
1402
+ product
1403
+ )
1404
+ else
1405
+ case $subcmd1 in
1406
+ (application)
1407
+ more_switches=(
1408
+ {--trace}
1409
+ )
1410
+ ;;
1411
+ (product)
1412
+ more_switches=(
1413
+ {--trace}
1414
+ )
1415
+ ;;
1416
+ esac
1417
+ fi
1418
+
1419
+ # Add unused application-wide flags.
1420
+ local idx
1421
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1422
+ local switch=${__app_switches[$idx]}
1423
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1424
+ comp_list+=("$switch")
1425
+ fi
1426
+ done
1427
+ # Add unused subcommand flags.
1428
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1429
+ local switch=${more_switches[$idx]}
1430
+ comp_list+=("$switch")
1431
+ done
1432
+
1433
+ # If there are only --flags, <TAB> will put the common prefix,
1434
+ # "--", but maybe the user doesn't want to add a flag after all.
1435
+ if [[ -z ${last} ]]; then
1436
+ local flags_only=true
1437
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1438
+ local switch=${comp_list[$idx]}
1439
+ if [[ ${switch} != --* ]]; then
1440
+ flags_only=false
1441
+ break
1442
+ fi
1443
+ done
1444
+ if ${flags_only}; then
1445
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1446
+ comp_list+=("  ")
1447
+ fi
1448
+ fi
1449
+
1450
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1451
+ }
1452
+
1453
+ # Completion for subcommand: "help".
1454
+ function __murano-help () {
1455
+ local subcmd1="$1"
1456
+ local subcmd2="$2"
1457
+ #local subcmdn="$3"
1458
+ local used_switches="${@:3}"
1459
+ local last="${COMP_WORDS[COMP_CWORD]}"
1460
+ local len=$(($COMP_CWORD - 1))
1461
+
1462
+ local -a more_switches
1463
+
1464
+ local -a comp_list
1465
+
1466
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1467
+ #>&2 echo "used_switches=$used_switches"
1468
+ #>&2 echo "more_switches=$more_switches"
1469
+
1470
+ # NOTE: Not doing anything special for ${subcmd2}.
1471
+ # Are there sub-sub-commands we shoud list?
1472
+
1473
+ # Add unused application-wide flags.
1474
+ local idx
1475
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1476
+ local switch=${__app_switches[$idx]}
1477
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1478
+ comp_list+=("$switch")
1479
+ fi
1480
+ done
1481
+ # Add unused subcommand flags.
1482
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1483
+ local switch=${more_switches[$idx]}
1484
+ comp_list+=("$switch")
1485
+ done
1486
+
1487
+ # If there are only --flags, <TAB> will put the common prefix,
1488
+ # "--", but maybe the user doesn't want to add a flag after all.
1489
+ if [[ -z ${last} ]]; then
1490
+ local flags_only=true
1491
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1492
+ local switch=${comp_list[$idx]}
1493
+ if [[ ${switch} != --* ]]; then
1494
+ flags_only=false
1495
+ break
1496
+ fi
1497
+ done
1498
+ if ${flags_only}; then
1499
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1500
+ comp_list+=("  ")
1501
+ fi
1502
+ fi
1503
+
1504
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1505
+ }
1506
+
1507
+ # Completion for subcommand: "init".
1508
+ function __murano-init () {
1509
+ local subcmd1="$1"
1510
+ local subcmd2="$2"
1511
+ #local subcmdn="$3"
1512
+ local used_switches="${@:3}"
1513
+ local last="${COMP_WORDS[COMP_CWORD]}"
1514
+ local len=$(($COMP_CWORD - 1))
1515
+
1516
+ local -a more_switches
1517
+
1518
+ local -a comp_list
1519
+
1520
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1521
+ #>&2 echo "used_switches=$used_switches"
1522
+ #>&2 echo "more_switches=$more_switches"
1523
+
1524
+ # NOTE: Not doing anything special for ${subcmd2}.
1525
+ # Are there sub-sub-commands we shoud list?
1526
+
1527
+ # Add unused application-wide flags.
1528
+ local idx
1529
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1530
+ local switch=${__app_switches[$idx]}
1531
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1532
+ comp_list+=("$switch")
1533
+ fi
1534
+ done
1535
+ # Add unused subcommand flags.
1536
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1537
+ local switch=${more_switches[$idx]}
1538
+ comp_list+=("$switch")
1539
+ done
1540
+
1541
+ # If there are only --flags, <TAB> will put the common prefix,
1542
+ # "--", but maybe the user doesn't want to add a flag after all.
1543
+ if [[ -z ${last} ]]; then
1544
+ local flags_only=true
1545
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1546
+ local switch=${comp_list[$idx]}
1547
+ if [[ ${switch} != --* ]]; then
1548
+ flags_only=false
1549
+ break
1550
+ fi
1551
+ done
1552
+ if ${flags_only}; then
1553
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1554
+ comp_list+=("  ")
1555
+ fi
1556
+ fi
1557
+
1558
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1559
+ }
1560
+
1561
+ # Completion for subcommand: "keystore".
1562
+ function __murano-keystore () {
1563
+ local subcmd1="$1"
1564
+ local subcmd2="$2"
1565
+ #local subcmdn="$3"
1566
+ local used_switches="${@:3}"
1567
+ local last="${COMP_WORDS[COMP_CWORD]}"
1568
+ local len=$(($COMP_CWORD - 1))
1569
+
1570
+ local -a more_switches
1571
+
1572
+ local -a comp_list
1573
+
1574
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1575
+ #>&2 echo "used_switches=$used_switches"
1576
+ #>&2 echo "more_switches=$more_switches"
1577
+
1578
+ # NOTE: Not doing anything special for ${subcmd2}.
1579
+ # Are there sub-sub-commands we shoud list?
1580
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1581
+ comp_list=(
1582
+ clearAll
1583
+ cmd
1584
+ command
1585
+ del
1586
+ delete
1587
+ get
1588
+ info
1589
+ lindex
1590
+ linsert
1591
+ list
1592
+ llen
1593
+ lpush
1594
+ lrange
1595
+ lrem
1596
+ lset
1597
+ ltrim
1598
+ rm
1599
+ rpop
1600
+ rpush
1601
+ sadd
1602
+ scard
1603
+ set
1604
+ smembers
1605
+ spop
1606
+ srem
1607
+ )
1608
+ else
1609
+ case $subcmd1 in
1610
+ (clearAll)
1611
+ more_switches=(
1612
+ )
1613
+ ;;
1614
+ (cmd)
1615
+ more_switches=(
1616
+ )
1617
+ ;;
1618
+ (command)
1619
+ more_switches=(
1620
+ )
1621
+ ;;
1622
+ (del)
1623
+ more_switches=(
1624
+ )
1625
+ ;;
1626
+ (delete)
1627
+ more_switches=(
1628
+ )
1629
+ ;;
1630
+ (get)
1631
+ more_switches=(
1632
+ )
1633
+ ;;
1634
+ (info)
1635
+ more_switches=(
1636
+ )
1637
+ ;;
1638
+ (lindex)
1639
+ more_switches=(
1640
+ )
1641
+ ;;
1642
+ (linsert)
1643
+ more_switches=(
1644
+ )
1645
+ ;;
1646
+ (list)
1647
+ more_switches=(
1648
+ )
1649
+ ;;
1650
+ (llen)
1651
+ more_switches=(
1652
+ )
1653
+ ;;
1654
+ (lpush)
1655
+ more_switches=(
1656
+ )
1657
+ ;;
1658
+ (lrange)
1659
+ more_switches=(
1660
+ )
1661
+ ;;
1662
+ (lrem)
1663
+ more_switches=(
1664
+ )
1665
+ ;;
1666
+ (lset)
1667
+ more_switches=(
1668
+ )
1669
+ ;;
1670
+ (ltrim)
1671
+ more_switches=(
1672
+ )
1673
+ ;;
1674
+ (rm)
1675
+ more_switches=(
1676
+ )
1677
+ ;;
1678
+ (rpop)
1679
+ more_switches=(
1680
+ )
1681
+ ;;
1682
+ (rpush)
1683
+ more_switches=(
1684
+ )
1685
+ ;;
1686
+ (sadd)
1687
+ more_switches=(
1688
+ )
1689
+ ;;
1690
+ (scard)
1691
+ more_switches=(
1692
+ )
1693
+ ;;
1694
+ (set)
1695
+ more_switches=(
1696
+ )
1697
+ ;;
1698
+ (smembers)
1699
+ more_switches=(
1700
+ )
1701
+ ;;
1702
+ (spop)
1703
+ more_switches=(
1704
+ )
1705
+ ;;
1706
+ (srem)
1707
+ more_switches=(
1708
+ )
1709
+ ;;
1710
+ esac
1711
+ fi
1712
+
1713
+ # Add unused application-wide flags.
1714
+ local idx
1715
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1716
+ local switch=${__app_switches[$idx]}
1717
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1718
+ comp_list+=("$switch")
1719
+ fi
1720
+ done
1721
+ # Add unused subcommand flags.
1722
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1723
+ local switch=${more_switches[$idx]}
1724
+ comp_list+=("$switch")
1725
+ done
1726
+
1727
+ # If there are only --flags, <TAB> will put the common prefix,
1728
+ # "--", but maybe the user doesn't want to add a flag after all.
1729
+ if [[ -z ${last} ]]; then
1730
+ local flags_only=true
1731
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1732
+ local switch=${comp_list[$idx]}
1733
+ if [[ ${switch} != --* ]]; then
1734
+ flags_only=false
1735
+ break
1736
+ fi
1737
+ done
1738
+ if ${flags_only}; then
1739
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1740
+ comp_list+=("  ")
1741
+ fi
1742
+ fi
1743
+
1744
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1745
+ }
1746
+
1747
+ # Completion for subcommand: "link".
1748
+ function __murano-link () {
1749
+ local subcmd1="$1"
1750
+ local subcmd2="$2"
1751
+ #local subcmdn="$3"
1752
+ local used_switches="${@:3}"
1753
+ local last="${COMP_WORDS[COMP_CWORD]}"
1754
+ local len=$(($COMP_CWORD - 1))
1755
+
1756
+ local -a more_switches
1757
+
1758
+ local -a comp_list
1759
+
1760
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1761
+ #>&2 echo "used_switches=$used_switches"
1762
+ #>&2 echo "more_switches=$more_switches"
1763
+
1764
+ # NOTE: Not doing anything special for ${subcmd2}.
1765
+ # Are there sub-sub-commands we shoud list?
1766
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1767
+ comp_list=(
1768
+ list
1769
+ set
1770
+ unset
1771
+ )
1772
+ else
1773
+ case $subcmd1 in
1774
+ (list)
1775
+ more_switches=(
1776
+ {--trace}
1777
+ )
1778
+ ;;
1779
+ (set)
1780
+ more_switches=(
1781
+ {--trace}
1782
+ )
1783
+ ;;
1784
+ (unset)
1785
+ more_switches=(
1786
+ {--trace}
1787
+ )
1788
+ ;;
1789
+ esac
1790
+ fi
1791
+
1792
+ # Add unused application-wide flags.
1793
+ local idx
1794
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1795
+ local switch=${__app_switches[$idx]}
1796
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1797
+ comp_list+=("$switch")
1798
+ fi
1799
+ done
1800
+ # Add unused subcommand flags.
1801
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1802
+ local switch=${more_switches[$idx]}
1803
+ comp_list+=("$switch")
1804
+ done
1805
+
1806
+ # If there are only --flags, <TAB> will put the common prefix,
1807
+ # "--", but maybe the user doesn't want to add a flag after all.
1808
+ if [[ -z ${last} ]]; then
1809
+ local flags_only=true
1810
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1811
+ local switch=${comp_list[$idx]}
1812
+ if [[ ${switch} != --* ]]; then
1813
+ flags_only=false
1814
+ break
1815
+ fi
1816
+ done
1817
+ if ${flags_only}; then
1818
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1819
+ comp_list+=("  ")
1820
+ fi
1821
+ fi
1822
+
1823
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1824
+ }
1825
+
1826
+ # Completion for subcommand: "links".
1827
+ function __murano-links () {
1828
+ local subcmd1="$1"
1829
+ local subcmd2="$2"
1830
+ #local subcmdn="$3"
1831
+ local used_switches="${@:3}"
1832
+ local last="${COMP_WORDS[COMP_CWORD]}"
1833
+ local len=$(($COMP_CWORD - 1))
1834
+
1835
+ local -a more_switches
1836
+
1837
+ local -a comp_list
1838
+
1839
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1840
+ #>&2 echo "used_switches=$used_switches"
1841
+ #>&2 echo "more_switches=$more_switches"
1842
+
1843
+ # NOTE: Not doing anything special for ${subcmd2}.
1844
+ # Are there sub-sub-commands we shoud list?
1845
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1846
+ comp_list=(
1847
+ list
1848
+ )
1849
+ else
1850
+ case $subcmd1 in
1851
+ (list)
1852
+ more_switches=(
1853
+ {--trace}
1854
+ )
1855
+ ;;
1856
+ esac
1857
+ fi
1858
+
1859
+ # Add unused application-wide flags.
1860
+ local idx
1861
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1862
+ local switch=${__app_switches[$idx]}
1863
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1864
+ comp_list+=("$switch")
1865
+ fi
1866
+ done
1867
+ # Add unused subcommand flags.
1868
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1869
+ local switch=${more_switches[$idx]}
1870
+ comp_list+=("$switch")
1871
+ done
1872
+
1873
+ # If there are only --flags, <TAB> will put the common prefix,
1874
+ # "--", but maybe the user doesn't want to add a flag after all.
1875
+ if [[ -z ${last} ]]; then
1876
+ local flags_only=true
1877
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1878
+ local switch=${comp_list[$idx]}
1879
+ if [[ ${switch} != --* ]]; then
1880
+ flags_only=false
1881
+ break
1882
+ fi
1883
+ done
1884
+ if ${flags_only}; then
1885
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1886
+ comp_list+=("  ")
1887
+ fi
1888
+ fi
1889
+
1890
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1891
+ }
1892
+
1893
+ # Completion for subcommand: "list".
1894
+ function __murano-list () {
1895
+ local subcmd1="$1"
1896
+ local subcmd2="$2"
1897
+ #local subcmdn="$3"
1898
+ local used_switches="${@:3}"
1899
+ local last="${COMP_WORDS[COMP_CWORD]}"
1900
+ local len=$(($COMP_CWORD - 1))
1901
+
1902
+ local -a more_switches
1903
+
1904
+ local -a comp_list
1905
+
1906
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1907
+ #>&2 echo "used_switches=$used_switches"
1908
+ #>&2 echo "more_switches=$more_switches"
1909
+
1910
+ # NOTE: Not doing anything special for ${subcmd2}.
1911
+ # Are there sub-sub-commands we shoud list?
1912
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
1913
+ comp_list=(
1914
+ application
1915
+ applications
1916
+ product
1917
+ products
1918
+ solutions
1919
+ )
1920
+ else
1921
+ case $subcmd1 in
1922
+ (application)
1923
+ more_switches=(
1924
+ {--trace}
1925
+ )
1926
+ ;;
1927
+ (applications)
1928
+ more_switches=(
1929
+ {--trace}
1930
+ )
1931
+ ;;
1932
+ (product)
1933
+ more_switches=(
1934
+ {--trace}
1935
+ )
1936
+ ;;
1937
+ (products)
1938
+ more_switches=(
1939
+ {--trace}
1940
+ )
1941
+ ;;
1942
+ (solutions)
1943
+ more_switches=(
1944
+ {--trace}
1945
+ )
1946
+ ;;
1947
+ esac
1948
+ fi
1949
+
1950
+ # Add unused application-wide flags.
1951
+ local idx
1952
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
1953
+ local switch=${__app_switches[$idx]}
1954
+ if ! contains_element "$switch" "${used_switches[@]}"; then
1955
+ comp_list+=("$switch")
1956
+ fi
1957
+ done
1958
+ # Add unused subcommand flags.
1959
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
1960
+ local switch=${more_switches[$idx]}
1961
+ comp_list+=("$switch")
1962
+ done
1963
+
1964
+ # If there are only --flags, <TAB> will put the common prefix,
1965
+ # "--", but maybe the user doesn't want to add a flag after all.
1966
+ if [[ -z ${last} ]]; then
1967
+ local flags_only=true
1968
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
1969
+ local switch=${comp_list[$idx]}
1970
+ if [[ ${switch} != --* ]]; then
1971
+ flags_only=false
1972
+ break
1973
+ fi
1974
+ done
1975
+ if ${flags_only}; then
1976
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
1977
+ comp_list+=("  ")
1978
+ fi
1979
+ fi
1980
+
1981
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
1982
+ }
1983
+
1984
+ # Completion for subcommand: "login".
1985
+ function __murano-login () {
1986
+ local subcmd1="$1"
1987
+ local subcmd2="$2"
1988
+ #local subcmdn="$3"
1989
+ local used_switches="${@:3}"
1990
+ local last="${COMP_WORDS[COMP_CWORD]}"
1991
+ local len=$(($COMP_CWORD - 1))
1992
+
1993
+ local -a more_switches
1994
+
1995
+ local -a comp_list
1996
+
1997
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
1998
+ #>&2 echo "used_switches=$used_switches"
1999
+ #>&2 echo "more_switches=$more_switches"
2000
+
2001
+ # NOTE: Not doing anything special for ${subcmd2}.
2002
+ # Are there sub-sub-commands we shoud list?
2003
+
2004
+ # Add unused application-wide flags.
2005
+ local idx
2006
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2007
+ local switch=${__app_switches[$idx]}
2008
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2009
+ comp_list+=("$switch")
2010
+ fi
2011
+ done
2012
+ # Add unused subcommand flags.
2013
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2014
+ local switch=${more_switches[$idx]}
2015
+ comp_list+=("$switch")
2016
+ done
2017
+
2018
+ # If there are only --flags, <TAB> will put the common prefix,
2019
+ # "--", but maybe the user doesn't want to add a flag after all.
2020
+ if [[ -z ${last} ]]; then
2021
+ local flags_only=true
2022
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2023
+ local switch=${comp_list[$idx]}
2024
+ if [[ ${switch} != --* ]]; then
2025
+ flags_only=false
2026
+ break
2027
+ fi
2028
+ done
2029
+ if ${flags_only}; then
2030
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2031
+ comp_list+=("  ")
2032
+ fi
2033
+ fi
2034
+
2035
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2036
+ }
2037
+
2038
+ # Completion for subcommand: "logout".
2039
+ function __murano-logout () {
2040
+ local subcmd1="$1"
2041
+ local subcmd2="$2"
2042
+ #local subcmdn="$3"
2043
+ local used_switches="${@:3}"
2044
+ local last="${COMP_WORDS[COMP_CWORD]}"
2045
+ local len=$(($COMP_CWORD - 1))
2046
+
2047
+ local -a more_switches
2048
+
2049
+ local -a comp_list
2050
+
2051
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2052
+ #>&2 echo "used_switches=$used_switches"
2053
+ #>&2 echo "more_switches=$more_switches"
2054
+
2055
+ # NOTE: Not doing anything special for ${subcmd2}.
2056
+ # Are there sub-sub-commands we shoud list?
2057
+
2058
+ # Add unused application-wide flags.
2059
+ local idx
2060
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2061
+ local switch=${__app_switches[$idx]}
2062
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2063
+ comp_list+=("$switch")
2064
+ fi
2065
+ done
2066
+ # Add unused subcommand flags.
2067
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2068
+ local switch=${more_switches[$idx]}
2069
+ comp_list+=("$switch")
2070
+ done
2071
+
2072
+ # If there are only --flags, <TAB> will put the common prefix,
2073
+ # "--", but maybe the user doesn't want to add a flag after all.
2074
+ if [[ -z ${last} ]]; then
2075
+ local flags_only=true
2076
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2077
+ local switch=${comp_list[$idx]}
2078
+ if [[ ${switch} != --* ]]; then
2079
+ flags_only=false
2080
+ break
2081
+ fi
2082
+ done
2083
+ if ${flags_only}; then
2084
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2085
+ comp_list+=("  ")
2086
+ fi
2087
+ fi
2088
+
2089
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2090
+ }
2091
+
2092
+ # Completion for subcommand: "logs".
2093
+ function __murano-logs () {
2094
+ local subcmd1="$1"
2095
+ local subcmd2="$2"
2096
+ #local subcmdn="$3"
2097
+ local used_switches="${@:3}"
2098
+ local last="${COMP_WORDS[COMP_CWORD]}"
2099
+ local len=$(($COMP_CWORD - 1))
2100
+
2101
+ local -a more_switches
2102
+
2103
+ local -a comp_list
2104
+
2105
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2106
+ #>&2 echo "used_switches=$used_switches"
2107
+ #>&2 echo "more_switches=$more_switches"
2108
+
2109
+ # NOTE: Not doing anything special for ${subcmd2}.
2110
+ # Are there sub-sub-commands we shoud list?
2111
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2112
+ comp_list=(
2113
+ application
2114
+ product
2115
+ )
2116
+ else
2117
+ case $subcmd1 in
2118
+ (application)
2119
+ more_switches=(
2120
+ {--trace}
2121
+ )
2122
+ ;;
2123
+ (product)
2124
+ more_switches=(
2125
+ {--trace}
2126
+ )
2127
+ ;;
2128
+ esac
2129
+ fi
2130
+
2131
+ # Add unused application-wide flags.
2132
+ local idx
2133
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2134
+ local switch=${__app_switches[$idx]}
2135
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2136
+ comp_list+=("$switch")
2137
+ fi
2138
+ done
2139
+ # Add unused subcommand flags.
2140
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2141
+ local switch=${more_switches[$idx]}
2142
+ comp_list+=("$switch")
2143
+ done
2144
+
2145
+ # If there are only --flags, <TAB> will put the common prefix,
2146
+ # "--", but maybe the user doesn't want to add a flag after all.
2147
+ if [[ -z ${last} ]]; then
2148
+ local flags_only=true
2149
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2150
+ local switch=${comp_list[$idx]}
2151
+ if [[ ${switch} != --* ]]; then
2152
+ flags_only=false
2153
+ break
2154
+ fi
2155
+ done
2156
+ if ${flags_only}; then
2157
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2158
+ comp_list+=("  ")
2159
+ fi
2160
+ fi
2161
+
2162
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2163
+ }
2164
+
2165
+ # Completion for subcommand: "mock".
2166
+ function __murano-mock () {
2167
+ local subcmd1="$1"
2168
+ local subcmd2="$2"
2169
+ #local subcmdn="$3"
2170
+ local used_switches="${@:3}"
2171
+ local last="${COMP_WORDS[COMP_CWORD]}"
2172
+ local len=$(($COMP_CWORD - 1))
2173
+
2174
+ local -a more_switches
2175
+
2176
+ local -a comp_list
2177
+
2178
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2179
+ #>&2 echo "used_switches=$used_switches"
2180
+ #>&2 echo "more_switches=$more_switches"
2181
+
2182
+ # NOTE: Not doing anything special for ${subcmd2}.
2183
+ # Are there sub-sub-commands we shoud list?
2184
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2185
+ comp_list=(
2186
+ disable
2187
+ enable
2188
+ show
2189
+ )
2190
+ else
2191
+ case $subcmd1 in
2192
+ (disable)
2193
+ more_switches=(
2194
+ )
2195
+ ;;
2196
+ (enable)
2197
+ more_switches=(
2198
+ {--trace}
2199
+ )
2200
+ ;;
2201
+ (show)
2202
+ more_switches=(
2203
+ )
2204
+ ;;
2205
+ esac
2206
+ fi
2207
+
2208
+ # Add unused application-wide flags.
2209
+ local idx
2210
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2211
+ local switch=${__app_switches[$idx]}
2212
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2213
+ comp_list+=("$switch")
2214
+ fi
2215
+ done
2216
+ # Add unused subcommand flags.
2217
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2218
+ local switch=${more_switches[$idx]}
2219
+ comp_list+=("$switch")
2220
+ done
2221
+
2222
+ # If there are only --flags, <TAB> will put the common prefix,
2223
+ # "--", but maybe the user doesn't want to add a flag after all.
2224
+ if [[ -z ${last} ]]; then
2225
+ local flags_only=true
2226
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2227
+ local switch=${comp_list[$idx]}
2228
+ if [[ ${switch} != --* ]]; then
2229
+ flags_only=false
2230
+ break
2231
+ fi
2232
+ done
2233
+ if ${flags_only}; then
2234
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2235
+ comp_list+=("  ")
2236
+ fi
2237
+ fi
2238
+
2239
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2240
+ }
2241
+
2242
+ # Completion for subcommand: "password".
2243
+ function __murano-password () {
2244
+ local subcmd1="$1"
2245
+ local subcmd2="$2"
2246
+ #local subcmdn="$3"
2247
+ local used_switches="${@:3}"
2248
+ local last="${COMP_WORDS[COMP_CWORD]}"
2249
+ local len=$(($COMP_CWORD - 1))
2250
+
2251
+ local -a more_switches
2252
+
2253
+ local -a comp_list
2254
+
2255
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2256
+ #>&2 echo "used_switches=$used_switches"
2257
+ #>&2 echo "more_switches=$more_switches"
2258
+
2259
+ # NOTE: Not doing anything special for ${subcmd2}.
2260
+ # Are there sub-sub-commands we shoud list?
2261
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2262
+ comp_list=(
2263
+ current
2264
+ delete
2265
+ list
2266
+ set
2267
+ )
2268
+ else
2269
+ case $subcmd1 in
2270
+ (current)
2271
+ more_switches=(
2272
+ {--trace}
2273
+ )
2274
+ ;;
2275
+ (delete)
2276
+ more_switches=(
2277
+ )
2278
+ ;;
2279
+ (list)
2280
+ more_switches=(
2281
+ )
2282
+ ;;
2283
+ (set)
2284
+ more_switches=(
2285
+ {--trace}
2286
+ )
2287
+ ;;
2288
+ esac
2289
+ fi
2290
+
2291
+ # Add unused application-wide flags.
2292
+ local idx
2293
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2294
+ local switch=${__app_switches[$idx]}
2295
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2296
+ comp_list+=("$switch")
2297
+ fi
2298
+ done
2299
+ # Add unused subcommand flags.
2300
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2301
+ local switch=${more_switches[$idx]}
2302
+ comp_list+=("$switch")
2303
+ done
2304
+
2305
+ # If there are only --flags, <TAB> will put the common prefix,
2306
+ # "--", but maybe the user doesn't want to add a flag after all.
2307
+ if [[ -z ${last} ]]; then
2308
+ local flags_only=true
2309
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2310
+ local switch=${comp_list[$idx]}
2311
+ if [[ ${switch} != --* ]]; then
2312
+ flags_only=false
2313
+ break
2314
+ fi
2315
+ done
2316
+ if ${flags_only}; then
2317
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2318
+ comp_list+=("  ")
2319
+ fi
2320
+ fi
2321
+
2322
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2323
+ }
2324
+
2325
+ # Completion for subcommand: "passwords".
2326
+ function __murano-passwords () {
2327
+ local subcmd1="$1"
2328
+ local subcmd2="$2"
2329
+ #local subcmdn="$3"
2330
+ local used_switches="${@:3}"
2331
+ local last="${COMP_WORDS[COMP_CWORD]}"
2332
+ local len=$(($COMP_CWORD - 1))
2333
+
2334
+ local -a more_switches
2335
+
2336
+ local -a comp_list
2337
+
2338
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2339
+ #>&2 echo "used_switches=$used_switches"
2340
+ #>&2 echo "more_switches=$more_switches"
2341
+
2342
+ # NOTE: Not doing anything special for ${subcmd2}.
2343
+ # Are there sub-sub-commands we shoud list?
2344
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2345
+ comp_list=(
2346
+ list
2347
+ )
2348
+ else
2349
+ case $subcmd1 in
2350
+ (list)
2351
+ more_switches=(
2352
+ )
2353
+ ;;
2354
+ esac
2355
+ fi
2356
+
2357
+ # Add unused application-wide flags.
2358
+ local idx
2359
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2360
+ local switch=${__app_switches[$idx]}
2361
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2362
+ comp_list+=("$switch")
2363
+ fi
2364
+ done
2365
+ # Add unused subcommand flags.
2366
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2367
+ local switch=${more_switches[$idx]}
2368
+ comp_list+=("$switch")
2369
+ done
2370
+
2371
+ # If there are only --flags, <TAB> will put the common prefix,
2372
+ # "--", but maybe the user doesn't want to add a flag after all.
2373
+ if [[ -z ${last} ]]; then
2374
+ local flags_only=true
2375
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2376
+ local switch=${comp_list[$idx]}
2377
+ if [[ ${switch} != --* ]]; then
2378
+ flags_only=false
2379
+ break
2380
+ fi
2381
+ done
2382
+ if ${flags_only}; then
2383
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2384
+ comp_list+=("  ")
2385
+ fi
2386
+ fi
2387
+
2388
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2389
+ }
2390
+
2391
+ # Completion for subcommand: "postgresql".
2392
+ function __murano-postgresql () {
2393
+ local subcmd1="$1"
2394
+ local subcmd2="$2"
2395
+ #local subcmdn="$3"
2396
+ local used_switches="${@:3}"
2397
+ local last="${COMP_WORDS[COMP_CWORD]}"
2398
+ local len=$(($COMP_CWORD - 1))
2399
+
2400
+ local -a more_switches
2401
+
2402
+ local -a comp_list
2403
+
2404
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2405
+ #>&2 echo "used_switches=$used_switches"
2406
+ #>&2 echo "more_switches=$more_switches"
2407
+
2408
+ # NOTE: Not doing anything special for ${subcmd2}.
2409
+ # Are there sub-sub-commands we shoud list?
2410
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2411
+ comp_list=(
2412
+ migrate
2413
+ )
2414
+ else
2415
+ case $subcmd1 in
2416
+ (migrate)
2417
+ more_switches=(
2418
+ {--trace}
2419
+ )
2420
+ ;;
2421
+ esac
2422
+ fi
2423
+
2424
+ # Add unused application-wide flags.
2425
+ local idx
2426
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2427
+ local switch=${__app_switches[$idx]}
2428
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2429
+ comp_list+=("$switch")
2430
+ fi
2431
+ done
2432
+ # Add unused subcommand flags.
2433
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2434
+ local switch=${more_switches[$idx]}
2435
+ comp_list+=("$switch")
2436
+ done
2437
+
2438
+ # If there are only --flags, <TAB> will put the common prefix,
2439
+ # "--", but maybe the user doesn't want to add a flag after all.
2440
+ if [[ -z ${last} ]]; then
2441
+ local flags_only=true
2442
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2443
+ local switch=${comp_list[$idx]}
2444
+ if [[ ${switch} != --* ]]; then
2445
+ flags_only=false
2446
+ break
2447
+ fi
2448
+ done
2449
+ if ${flags_only}; then
2450
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2451
+ comp_list+=("  ")
2452
+ fi
2453
+ fi
2454
+
2455
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2456
+ }
2457
+
2458
+ # Completion for subcommand: "product".
2459
+ function __murano-product () {
2460
+ local subcmd1="$1"
2461
+ local subcmd2="$2"
2462
+ #local subcmdn="$3"
2463
+ local used_switches="${@:3}"
2464
+ local last="${COMP_WORDS[COMP_CWORD]}"
2465
+ local len=$(($COMP_CWORD - 1))
2466
+
2467
+ local -a more_switches
2468
+
2469
+ local -a comp_list
2470
+
2471
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2472
+ #>&2 echo "used_switches=$used_switches"
2473
+ #>&2 echo "more_switches=$more_switches"
2474
+
2475
+ # NOTE: Not doing anything special for ${subcmd2}.
2476
+ # Are there sub-sub-commands we shoud list?
2477
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2478
+ comp_list=(
2479
+ create
2480
+ delete
2481
+ device
2482
+ devices
2483
+ diff
2484
+ domain
2485
+ find
2486
+ list
2487
+ logs
2488
+ pull
2489
+ push
2490
+ usage
2491
+ )
2492
+ else
2493
+ case $subcmd1 in
2494
+ (create)
2495
+ more_switches=(
2496
+ {--trace}
2497
+ )
2498
+ ;;
2499
+ (delete)
2500
+ more_switches=(
2501
+ {--trace}
2502
+ )
2503
+ ;;
2504
+ (device)
2505
+ more_switches=(
2506
+ )
2507
+ ;;
2508
+ (devices)
2509
+ more_switches=(
2510
+ )
2511
+ ;;
2512
+ (diff)
2513
+ more_switches=(
2514
+ {--trace}
2515
+ )
2516
+ ;;
2517
+ (domain)
2518
+ more_switches=(
2519
+ {--trace}
2520
+ )
2521
+ ;;
2522
+ (find)
2523
+ more_switches=(
2524
+ {--trace}
2525
+ )
2526
+ ;;
2527
+ (list)
2528
+ more_switches=(
2529
+ {--trace}
2530
+ )
2531
+ ;;
2532
+ (logs)
2533
+ more_switches=(
2534
+ {--trace}
2535
+ )
2536
+ ;;
2537
+ (pull)
2538
+ more_switches=(
2539
+ {--trace}
2540
+ )
2541
+ ;;
2542
+ (push)
2543
+ more_switches=(
2544
+ {--trace}
2545
+ )
2546
+ ;;
2547
+ (usage)
2548
+ more_switches=(
2549
+ {--trace}
2550
+ )
2551
+ ;;
2552
+ esac
2553
+ fi
2554
+
2555
+ # Add unused application-wide flags.
2556
+ local idx
2557
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2558
+ local switch=${__app_switches[$idx]}
2559
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2560
+ comp_list+=("$switch")
2561
+ fi
2562
+ done
2563
+ # Add unused subcommand flags.
2564
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2565
+ local switch=${more_switches[$idx]}
2566
+ comp_list+=("$switch")
2567
+ done
2568
+
2569
+ # If there are only --flags, <TAB> will put the common prefix,
2570
+ # "--", but maybe the user doesn't want to add a flag after all.
2571
+ if [[ -z ${last} ]]; then
2572
+ local flags_only=true
2573
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2574
+ local switch=${comp_list[$idx]}
2575
+ if [[ ${switch} != --* ]]; then
2576
+ flags_only=false
2577
+ break
2578
+ fi
2579
+ done
2580
+ if ${flags_only}; then
2581
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2582
+ comp_list+=("  ")
2583
+ fi
2584
+ fi
2585
+
2586
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2587
+ }
2588
+
2589
+ # Completion for subcommand: "products".
2590
+ function __murano-products () {
2591
+ local subcmd1="$1"
2592
+ local subcmd2="$2"
2593
+ #local subcmdn="$3"
2594
+ local used_switches="${@:3}"
2595
+ local last="${COMP_WORDS[COMP_CWORD]}"
2596
+ local len=$(($COMP_CWORD - 1))
2597
+
2598
+ local -a more_switches
2599
+
2600
+ local -a comp_list
2601
+
2602
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2603
+ #>&2 echo "used_switches=$used_switches"
2604
+ #>&2 echo "more_switches=$more_switches"
2605
+
2606
+ # NOTE: Not doing anything special for ${subcmd2}.
2607
+ # Are there sub-sub-commands we shoud list?
2608
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2609
+ comp_list=(
2610
+ list
2611
+ )
2612
+ else
2613
+ case $subcmd1 in
2614
+ (list)
2615
+ more_switches=(
2616
+ {--trace}
2617
+ )
2618
+ ;;
2619
+ esac
2620
+ fi
2621
+
2622
+ # Add unused application-wide flags.
2623
+ local idx
2624
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2625
+ local switch=${__app_switches[$idx]}
2626
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2627
+ comp_list+=("$switch")
2628
+ fi
2629
+ done
2630
+ # Add unused subcommand flags.
2631
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2632
+ local switch=${more_switches[$idx]}
2633
+ comp_list+=("$switch")
2634
+ done
2635
+
2636
+ # If there are only --flags, <TAB> will put the common prefix,
2637
+ # "--", but maybe the user doesn't want to add a flag after all.
2638
+ if [[ -z ${last} ]]; then
2639
+ local flags_only=true
2640
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2641
+ local switch=${comp_list[$idx]}
2642
+ if [[ ${switch} != --* ]]; then
2643
+ flags_only=false
2644
+ break
2645
+ fi
2646
+ done
2647
+ if ${flags_only}; then
2648
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2649
+ comp_list+=("  ")
2650
+ fi
2651
+ fi
2652
+
2653
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2654
+ }
2655
+
2656
+ # Completion for subcommand: "pull".
2657
+ function __murano-pull () {
2658
+ local subcmd1="$1"
2659
+ local subcmd2="$2"
2660
+ #local subcmdn="$3"
2661
+ local used_switches="${@:3}"
2662
+ local last="${COMP_WORDS[COMP_CWORD]}"
2663
+ local len=$(($COMP_CWORD - 1))
2664
+
2665
+ local -a more_switches
2666
+
2667
+ local -a comp_list
2668
+
2669
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2670
+ #>&2 echo "used_switches=$used_switches"
2671
+ #>&2 echo "more_switches=$more_switches"
2672
+
2673
+ # NOTE: Not doing anything special for ${subcmd2}.
2674
+ # Are there sub-sub-commands we shoud list?
2675
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2676
+ comp_list=(
2677
+ application
2678
+ product
2679
+ )
2680
+ else
2681
+ case $subcmd1 in
2682
+ (application)
2683
+ more_switches=(
2684
+ {--trace}
2685
+ )
2686
+ ;;
2687
+ (product)
2688
+ more_switches=(
2689
+ {--trace}
2690
+ )
2691
+ ;;
2692
+ esac
2693
+ fi
2694
+
2695
+ # Add unused application-wide flags.
2696
+ local idx
2697
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2698
+ local switch=${__app_switches[$idx]}
2699
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2700
+ comp_list+=("$switch")
2701
+ fi
2702
+ done
2703
+ # Add unused subcommand flags.
2704
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2705
+ local switch=${more_switches[$idx]}
2706
+ comp_list+=("$switch")
2707
+ done
2708
+
2709
+ # If there are only --flags, <TAB> will put the common prefix,
2710
+ # "--", but maybe the user doesn't want to add a flag after all.
2711
+ if [[ -z ${last} ]]; then
2712
+ local flags_only=true
2713
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2714
+ local switch=${comp_list[$idx]}
2715
+ if [[ ${switch} != --* ]]; then
2716
+ flags_only=false
2717
+ break
2718
+ fi
2719
+ done
2720
+ if ${flags_only}; then
2721
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2722
+ comp_list+=("  ")
2723
+ fi
2724
+ fi
2725
+
2726
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2727
+ }
2728
+
2729
+ # Completion for subcommand: "push".
2730
+ function __murano-push () {
2731
+ local subcmd1="$1"
2732
+ local subcmd2="$2"
2733
+ #local subcmdn="$3"
2734
+ local used_switches="${@:3}"
2735
+ local last="${COMP_WORDS[COMP_CWORD]}"
2736
+ local len=$(($COMP_CWORD - 1))
2737
+
2738
+ local -a more_switches
2739
+
2740
+ local -a comp_list
2741
+
2742
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2743
+ #>&2 echo "used_switches=$used_switches"
2744
+ #>&2 echo "more_switches=$more_switches"
2745
+
2746
+ # NOTE: Not doing anything special for ${subcmd2}.
2747
+ # Are there sub-sub-commands we shoud list?
2748
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2749
+ comp_list=(
2750
+ application
2751
+ product
2752
+ )
2753
+ else
2754
+ case $subcmd1 in
2755
+ (application)
2756
+ more_switches=(
2757
+ {--trace}
2758
+ )
2759
+ ;;
2760
+ (product)
2761
+ more_switches=(
2762
+ {--trace}
2763
+ )
2764
+ ;;
2765
+ esac
2766
+ fi
2767
+
2768
+ # Add unused application-wide flags.
2769
+ local idx
2770
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2771
+ local switch=${__app_switches[$idx]}
2772
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2773
+ comp_list+=("$switch")
2774
+ fi
2775
+ done
2776
+ # Add unused subcommand flags.
2777
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2778
+ local switch=${more_switches[$idx]}
2779
+ comp_list+=("$switch")
2780
+ done
2781
+
2782
+ # If there are only --flags, <TAB> will put the common prefix,
2783
+ # "--", but maybe the user doesn't want to add a flag after all.
2784
+ if [[ -z ${last} ]]; then
2785
+ local flags_only=true
2786
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2787
+ local switch=${comp_list[$idx]}
2788
+ if [[ ${switch} != --* ]]; then
2789
+ flags_only=false
2790
+ break
2791
+ fi
2792
+ done
2793
+ if ${flags_only}; then
2794
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2795
+ comp_list+=("  ")
2796
+ fi
2797
+ fi
2798
+
2799
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2800
+ }
2801
+
2802
+ # Completion for subcommand: "setting".
2803
+ function __murano-setting () {
2804
+ local subcmd1="$1"
2805
+ local subcmd2="$2"
2806
+ #local subcmdn="$3"
2807
+ local used_switches="${@:3}"
2808
+ local last="${COMP_WORDS[COMP_CWORD]}"
2809
+ local len=$(($COMP_CWORD - 1))
2810
+
2811
+ local -a more_switches
2812
+
2813
+ local -a comp_list
2814
+
2815
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2816
+ #>&2 echo "used_switches=$used_switches"
2817
+ #>&2 echo "more_switches=$more_switches"
2818
+
2819
+ # NOTE: Not doing anything special for ${subcmd2}.
2820
+ # Are there sub-sub-commands we shoud list?
2821
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2822
+ comp_list=(
2823
+ list
2824
+ read
2825
+ write
2826
+ )
2827
+ else
2828
+ case $subcmd1 in
2829
+ (list)
2830
+ more_switches=(
2831
+ )
2832
+ ;;
2833
+ (read)
2834
+ more_switches=(
2835
+ {--trace}
2836
+ )
2837
+ ;;
2838
+ (write)
2839
+ more_switches=(
2840
+ {--trace}
2841
+ )
2842
+ ;;
2843
+ esac
2844
+ fi
2845
+
2846
+ # Add unused application-wide flags.
2847
+ local idx
2848
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2849
+ local switch=${__app_switches[$idx]}
2850
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2851
+ comp_list+=("$switch")
2852
+ fi
2853
+ done
2854
+ # Add unused subcommand flags.
2855
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2856
+ local switch=${more_switches[$idx]}
2857
+ comp_list+=("$switch")
2858
+ done
2859
+
2860
+ # If there are only --flags, <TAB> will put the common prefix,
2861
+ # "--", but maybe the user doesn't want to add a flag after all.
2862
+ if [[ -z ${last} ]]; then
2863
+ local flags_only=true
2864
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2865
+ local switch=${comp_list[$idx]}
2866
+ if [[ ${switch} != --* ]]; then
2867
+ flags_only=false
2868
+ break
2869
+ fi
2870
+ done
2871
+ if ${flags_only}; then
2872
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2873
+ comp_list+=("  ")
2874
+ fi
2875
+ fi
2876
+
2877
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2878
+ }
2879
+
2880
+ # Completion for subcommand: "settings".
2881
+ function __murano-settings () {
2882
+ local subcmd1="$1"
2883
+ local subcmd2="$2"
2884
+ #local subcmdn="$3"
2885
+ local used_switches="${@:3}"
2886
+ local last="${COMP_WORDS[COMP_CWORD]}"
2887
+ local len=$(($COMP_CWORD - 1))
2888
+
2889
+ local -a more_switches
2890
+
2891
+ local -a comp_list
2892
+
2893
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2894
+ #>&2 echo "used_switches=$used_switches"
2895
+ #>&2 echo "more_switches=$more_switches"
2896
+
2897
+ # NOTE: Not doing anything special for ${subcmd2}.
2898
+ # Are there sub-sub-commands we shoud list?
2899
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2900
+ comp_list=(
2901
+ list
2902
+ )
2903
+ else
2904
+ case $subcmd1 in
2905
+ (list)
2906
+ more_switches=(
2907
+ )
2908
+ ;;
2909
+ esac
2910
+ fi
2911
+
2912
+ # Add unused application-wide flags.
2913
+ local idx
2914
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2915
+ local switch=${__app_switches[$idx]}
2916
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2917
+ comp_list+=("$switch")
2918
+ fi
2919
+ done
2920
+ # Add unused subcommand flags.
2921
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2922
+ local switch=${more_switches[$idx]}
2923
+ comp_list+=("$switch")
2924
+ done
2925
+
2926
+ # If there are only --flags, <TAB> will put the common prefix,
2927
+ # "--", but maybe the user doesn't want to add a flag after all.
2928
+ if [[ -z ${last} ]]; then
2929
+ local flags_only=true
2930
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2931
+ local switch=${comp_list[$idx]}
2932
+ if [[ ${switch} != --* ]]; then
2933
+ flags_only=false
2934
+ break
2935
+ fi
2936
+ done
2937
+ if ${flags_only}; then
2938
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
2939
+ comp_list+=("  ")
2940
+ fi
2941
+ fi
2942
+
2943
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
2944
+ }
2945
+
2946
+ # Completion for subcommand: "show".
2947
+ function __murano-show () {
2948
+ local subcmd1="$1"
2949
+ local subcmd2="$2"
2950
+ #local subcmdn="$3"
2951
+ local used_switches="${@:3}"
2952
+ local last="${COMP_WORDS[COMP_CWORD]}"
2953
+ local len=$(($COMP_CWORD - 1))
2954
+
2955
+ local -a more_switches
2956
+
2957
+ local -a comp_list
2958
+
2959
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
2960
+ #>&2 echo "used_switches=$used_switches"
2961
+ #>&2 echo "more_switches=$more_switches"
2962
+
2963
+ # NOTE: Not doing anything special for ${subcmd2}.
2964
+ # Are there sub-sub-commands we shoud list?
2965
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
2966
+ comp_list=(
2967
+ location
2968
+ )
2969
+ else
2970
+ case $subcmd1 in
2971
+ (location)
2972
+ more_switches=(
2973
+ )
2974
+ ;;
2975
+ esac
2976
+ fi
2977
+
2978
+ # Add unused application-wide flags.
2979
+ local idx
2980
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
2981
+ local switch=${__app_switches[$idx]}
2982
+ if ! contains_element "$switch" "${used_switches[@]}"; then
2983
+ comp_list+=("$switch")
2984
+ fi
2985
+ done
2986
+ # Add unused subcommand flags.
2987
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
2988
+ local switch=${more_switches[$idx]}
2989
+ comp_list+=("$switch")
2990
+ done
2991
+
2992
+ # If there are only --flags, <TAB> will put the common prefix,
2993
+ # "--", but maybe the user doesn't want to add a flag after all.
2994
+ if [[ -z ${last} ]]; then
2995
+ local flags_only=true
2996
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
2997
+ local switch=${comp_list[$idx]}
2998
+ if [[ ${switch} != --* ]]; then
2999
+ flags_only=false
3000
+ break
3001
+ fi
3002
+ done
3003
+ if ${flags_only}; then
3004
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
3005
+ comp_list+=("  ")
3006
+ fi
3007
+ fi
3008
+
3009
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
3010
+ }
3011
+
3012
+ # Completion for subcommand: "solution".
3013
+ function __murano-solution () {
3014
+ local subcmd1="$1"
3015
+ local subcmd2="$2"
3016
+ #local subcmdn="$3"
3017
+ local used_switches="${@:3}"
3018
+ local last="${COMP_WORDS[COMP_CWORD]}"
3019
+ local len=$(($COMP_CWORD - 1))
3020
+
3021
+ local -a more_switches
3022
+
3023
+ local -a comp_list
3024
+
3025
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
3026
+ #>&2 echo "used_switches=$used_switches"
3027
+ #>&2 echo "more_switches=$more_switches"
3028
+
3029
+ # NOTE: Not doing anything special for ${subcmd2}.
3030
+ # Are there sub-sub-commands we shoud list?
3031
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
3032
+ comp_list=(
3033
+ create
3034
+ delete
3035
+ find
3036
+ list
3037
+ )
3038
+ else
3039
+ case $subcmd1 in
3040
+ (create)
3041
+ more_switches=(
3042
+ {--trace}
3043
+ )
3044
+ ;;
3045
+ (delete)
3046
+ more_switches=(
3047
+ {--trace}
3048
+ )
3049
+ ;;
3050
+ (find)
3051
+ more_switches=(
3052
+ {--trace}
3053
+ )
3054
+ ;;
3055
+ (list)
3056
+ more_switches=(
3057
+ {--trace}
3058
+ )
3059
+ ;;
3060
+ esac
3061
+ fi
3062
+
3063
+ # Add unused application-wide flags.
3064
+ local idx
3065
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
3066
+ local switch=${__app_switches[$idx]}
3067
+ if ! contains_element "$switch" "${used_switches[@]}"; then
3068
+ comp_list+=("$switch")
3069
+ fi
3070
+ done
3071
+ # Add unused subcommand flags.
3072
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
3073
+ local switch=${more_switches[$idx]}
3074
+ comp_list+=("$switch")
3075
+ done
3076
+
3077
+ # If there are only --flags, <TAB> will put the common prefix,
3078
+ # "--", but maybe the user doesn't want to add a flag after all.
3079
+ if [[ -z ${last} ]]; then
3080
+ local flags_only=true
3081
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
3082
+ local switch=${comp_list[$idx]}
3083
+ if [[ ${switch} != --* ]]; then
3084
+ flags_only=false
3085
+ break
3086
+ fi
3087
+ done
3088
+ if ${flags_only}; then
3089
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
3090
+ comp_list+=("  ")
3091
+ fi
3092
+ fi
3093
+
3094
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
3095
+ }
3096
+
3097
+ # Completion for subcommand: "solutions".
3098
+ function __murano-solutions () {
3099
+ local subcmd1="$1"
3100
+ local subcmd2="$2"
3101
+ #local subcmdn="$3"
3102
+ local used_switches="${@:3}"
3103
+ local last="${COMP_WORDS[COMP_CWORD]}"
3104
+ local len=$(($COMP_CWORD - 1))
3105
+
3106
+ local -a more_switches
3107
+
3108
+ local -a comp_list
3109
+
3110
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
3111
+ #>&2 echo "used_switches=$used_switches"
3112
+ #>&2 echo "more_switches=$more_switches"
3113
+
3114
+ # NOTE: Not doing anything special for ${subcmd2}.
3115
+ # Are there sub-sub-commands we shoud list?
3116
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
3117
+ comp_list=(
3118
+ expunge
3119
+ list
3120
+ )
3121
+ else
3122
+ case $subcmd1 in
3123
+ (expunge)
3124
+ more_switches=(
3125
+ {--trace}
3126
+ )
3127
+ ;;
3128
+ (list)
3129
+ more_switches=(
3130
+ {--trace}
3131
+ )
3132
+ ;;
3133
+ esac
3134
+ fi
3135
+
3136
+ # Add unused application-wide flags.
3137
+ local idx
3138
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
3139
+ local switch=${__app_switches[$idx]}
3140
+ if ! contains_element "$switch" "${used_switches[@]}"; then
3141
+ comp_list+=("$switch")
3142
+ fi
3143
+ done
3144
+ # Add unused subcommand flags.
3145
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
3146
+ local switch=${more_switches[$idx]}
3147
+ comp_list+=("$switch")
3148
+ done
3149
+
3150
+ # If there are only --flags, <TAB> will put the common prefix,
3151
+ # "--", but maybe the user doesn't want to add a flag after all.
3152
+ if [[ -z ${last} ]]; then
3153
+ local flags_only=true
3154
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
3155
+ local switch=${comp_list[$idx]}
3156
+ if [[ ${switch} != --* ]]; then
3157
+ flags_only=false
3158
+ break
3159
+ fi
3160
+ done
3161
+ if ${flags_only}; then
3162
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
3163
+ comp_list+=("  ")
3164
+ fi
3165
+ fi
3166
+
3167
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
3168
+ }
3169
+
3170
+ # Completion for subcommand: "status".
3171
+ function __murano-status () {
3172
+ local subcmd1="$1"
3173
+ local subcmd2="$2"
3174
+ #local subcmdn="$3"
3175
+ local used_switches="${@:3}"
3176
+ local last="${COMP_WORDS[COMP_CWORD]}"
3177
+ local len=$(($COMP_CWORD - 1))
3178
+
3179
+ local -a more_switches
3180
+
3181
+ local -a comp_list
3182
+
3183
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
3184
+ #>&2 echo "used_switches=$used_switches"
3185
+ #>&2 echo "more_switches=$more_switches"
3186
+
3187
+ # NOTE: Not doing anything special for ${subcmd2}.
3188
+ # Are there sub-sub-commands we shoud list?
3189
+
3190
+ # Add unused application-wide flags.
3191
+ local idx
3192
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
3193
+ local switch=${__app_switches[$idx]}
3194
+ if ! contains_element "$switch" "${used_switches[@]}"; then
3195
+ comp_list+=("$switch")
3196
+ fi
3197
+ done
3198
+ # Add unused subcommand flags.
3199
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
3200
+ local switch=${more_switches[$idx]}
3201
+ comp_list+=("$switch")
3202
+ done
3203
+
3204
+ # If there are only --flags, <TAB> will put the common prefix,
3205
+ # "--", but maybe the user doesn't want to add a flag after all.
3206
+ if [[ -z ${last} ]]; then
3207
+ local flags_only=true
3208
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
3209
+ local switch=${comp_list[$idx]}
3210
+ if [[ ${switch} != --* ]]; then
3211
+ flags_only=false
3212
+ break
3213
+ fi
3214
+ done
3215
+ if ${flags_only}; then
3216
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
3217
+ comp_list+=("  ")
3218
+ fi
3219
+ fi
3220
+
3221
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
3222
+ }
3223
+
3224
+ # Completion for subcommand: "syncdown".
3225
+ function __murano-syncdown () {
3226
+ local subcmd1="$1"
3227
+ local subcmd2="$2"
3228
+ #local subcmdn="$3"
3229
+ local used_switches="${@:3}"
3230
+ local last="${COMP_WORDS[COMP_CWORD]}"
3231
+ local len=$(($COMP_CWORD - 1))
3232
+
3233
+ local -a more_switches
3234
+
3235
+ local -a comp_list
3236
+
3237
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
3238
+ #>&2 echo "used_switches=$used_switches"
3239
+ #>&2 echo "more_switches=$more_switches"
3240
+
3241
+ # NOTE: Not doing anything special for ${subcmd2}.
3242
+ # Are there sub-sub-commands we shoud list?
3243
+
3244
+ # Add unused application-wide flags.
3245
+ local idx
3246
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
3247
+ local switch=${__app_switches[$idx]}
3248
+ if ! contains_element "$switch" "${used_switches[@]}"; then
3249
+ comp_list+=("$switch")
3250
+ fi
3251
+ done
3252
+ # Add unused subcommand flags.
3253
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
3254
+ local switch=${more_switches[$idx]}
3255
+ comp_list+=("$switch")
3256
+ done
3257
+
3258
+ # If there are only --flags, <TAB> will put the common prefix,
3259
+ # "--", but maybe the user doesn't want to add a flag after all.
3260
+ if [[ -z ${last} ]]; then
3261
+ local flags_only=true
3262
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
3263
+ local switch=${comp_list[$idx]}
3264
+ if [[ ${switch} != --* ]]; then
3265
+ flags_only=false
3266
+ break
3267
+ fi
3268
+ done
3269
+ if ${flags_only}; then
3270
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
3271
+ comp_list+=("  ")
3272
+ fi
3273
+ fi
3274
+
3275
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
3276
+ }
3277
+
3278
+ # Completion for subcommand: "syncup".
3279
+ function __murano-syncup () {
3280
+ local subcmd1="$1"
3281
+ local subcmd2="$2"
3282
+ #local subcmdn="$3"
3283
+ local used_switches="${@:3}"
3284
+ local last="${COMP_WORDS[COMP_CWORD]}"
3285
+ local len=$(($COMP_CWORD - 1))
3286
+
3287
+ local -a more_switches
3288
+
3289
+ local -a comp_list
3290
+
3291
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
3292
+ #>&2 echo "used_switches=$used_switches"
3293
+ #>&2 echo "more_switches=$more_switches"
3294
+
3295
+ # NOTE: Not doing anything special for ${subcmd2}.
3296
+ # Are there sub-sub-commands we shoud list?
3297
+
3298
+ # Add unused application-wide flags.
3299
+ local idx
3300
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
3301
+ local switch=${__app_switches[$idx]}
3302
+ if ! contains_element "$switch" "${used_switches[@]}"; then
3303
+ comp_list+=("$switch")
3304
+ fi
3305
+ done
3306
+ # Add unused subcommand flags.
3307
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
3308
+ local switch=${more_switches[$idx]}
3309
+ comp_list+=("$switch")
3310
+ done
3311
+
3312
+ # If there are only --flags, <TAB> will put the common prefix,
3313
+ # "--", but maybe the user doesn't want to add a flag after all.
3314
+ if [[ -z ${last} ]]; then
3315
+ local flags_only=true
3316
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
3317
+ local switch=${comp_list[$idx]}
3318
+ if [[ ${switch} != --* ]]; then
3319
+ flags_only=false
3320
+ break
3321
+ fi
3322
+ done
3323
+ if ${flags_only}; then
3324
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
3325
+ comp_list+=("  ")
3326
+ fi
3327
+ fi
3328
+
3329
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
3330
+ }
3331
+
3332
+ # Completion for subcommand: "tsdb".
3333
+ function __murano-tsdb () {
3334
+ local subcmd1="$1"
3335
+ local subcmd2="$2"
3336
+ #local subcmdn="$3"
3337
+ local used_switches="${@:3}"
3338
+ local last="${COMP_WORDS[COMP_CWORD]}"
3339
+ local len=$(($COMP_CWORD - 1))
3340
+
3341
+ local -a more_switches
3342
+
3343
+ local -a comp_list
3344
+
3345
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
3346
+ #>&2 echo "used_switches=$used_switches"
3347
+ #>&2 echo "more_switches=$more_switches"
3348
+
3349
+ # NOTE: Not doing anything special for ${subcmd2}.
3350
+ # Are there sub-sub-commands we shoud list?
3351
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
3352
+ comp_list=(
3353
+ list
3354
+ query
3355
+ write
3356
+ )
3357
+ else
3358
+ case $subcmd1 in
3359
+ (list)
3360
+ more_switches=(
3361
+ )
3362
+ ;;
3363
+ (query)
3364
+ more_switches=(
3365
+ {--trace}
3366
+ )
3367
+ ;;
3368
+ (write)
3369
+ more_switches=(
3370
+ {--trace}
3371
+ )
3372
+ ;;
3373
+ esac
3374
+ fi
3375
+
3376
+ # Add unused application-wide flags.
3377
+ local idx
3378
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
3379
+ local switch=${__app_switches[$idx]}
3380
+ if ! contains_element "$switch" "${used_switches[@]}"; then
3381
+ comp_list+=("$switch")
3382
+ fi
3383
+ done
3384
+ # Add unused subcommand flags.
3385
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
3386
+ local switch=${more_switches[$idx]}
3387
+ comp_list+=("$switch")
3388
+ done
3389
+
3390
+ # If there are only --flags, <TAB> will put the common prefix,
3391
+ # "--", but maybe the user doesn't want to add a flag after all.
3392
+ if [[ -z ${last} ]]; then
3393
+ local flags_only=true
3394
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
3395
+ local switch=${comp_list[$idx]}
3396
+ if [[ ${switch} != --* ]]; then
3397
+ flags_only=false
3398
+ break
3399
+ fi
3400
+ done
3401
+ if ${flags_only}; then
3402
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
3403
+ comp_list+=("  ")
3404
+ fi
3405
+ fi
3406
+
3407
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
3408
+ }
3409
+
3410
+ # Completion for subcommand: "usage".
3411
+ function __murano-usage () {
3412
+ local subcmd1="$1"
3413
+ local subcmd2="$2"
3414
+ #local subcmdn="$3"
3415
+ local used_switches="${@:3}"
3416
+ local last="${COMP_WORDS[COMP_CWORD]}"
3417
+ local len=$(($COMP_CWORD - 1))
3418
+
3419
+ local -a more_switches
3420
+
3421
+ local -a comp_list
3422
+
3423
+ #>&2 echo -e "\nsubcmd1=$subcmd1 / subcmd2=$subcmd2 / last=$last / len=$len"
3424
+ #>&2 echo "used_switches=$used_switches"
3425
+ #>&2 echo "more_switches=$more_switches"
3426
+
3427
+ # NOTE: Not doing anything special for ${subcmd2}.
3428
+ # Are there sub-sub-commands we shoud list?
3429
+ if [[ -z ${subcmd1} || ${len} -eq 1 ]]; then
3430
+ comp_list=(
3431
+ application
3432
+ product
3433
+ )
3434
+ else
3435
+ case $subcmd1 in
3436
+ (application)
3437
+ more_switches=(
3438
+ {--trace}
3439
+ )
3440
+ ;;
3441
+ (product)
3442
+ more_switches=(
3443
+ {--trace}
3444
+ )
3445
+ ;;
3446
+ esac
3447
+ fi
3448
+
3449
+ # Add unused application-wide flags.
3450
+ local idx
3451
+ for ((idx = 0; idx < ${#__app_switches[@]}; idx++)); do
3452
+ local switch=${__app_switches[$idx]}
3453
+ if ! contains_element "$switch" "${used_switches[@]}"; then
3454
+ comp_list+=("$switch")
3455
+ fi
3456
+ done
3457
+ # Add unused subcommand flags.
3458
+ for ((idx = 0; idx < ${#more_switches[@]}; idx++)); do
3459
+ local switch=${more_switches[$idx]}
3460
+ comp_list+=("$switch")
3461
+ done
3462
+
3463
+ # If there are only --flags, <TAB> will put the common prefix,
3464
+ # "--", but maybe the user doesn't want to add a flag after all.
3465
+ if [[ -z ${last} ]]; then
3466
+ local flags_only=true
3467
+ for ((idx = 0; idx < ${#comp_list[@]}; idx++)); do
3468
+ local switch=${comp_list[$idx]}
3469
+ if [[ ${switch} != --* ]]; then
3470
+ flags_only=false
3471
+ break
3472
+ fi
3473
+ done
3474
+ if ${flags_only}; then
3475
+ # Use two Unicode en spaces to prevent compgen from prefixing "--".
3476
+ comp_list+=("  ")
3477
+ fi
3478
+ fi
3479
+
3480
+ COMPREPLY=($(compgen -W '${comp_list[@]}' -- "${last}"))
3481
+ }
3482
+
3483
+ complete -F _murano murano
3484
+