Skip to content

Commit 47ca924

Browse files
authored
Merge pull request #311 from Mashimiao/completions-cleanup-and-fix
completions: cleanup and fix
2 parents b219244 + 9bd216e commit 47ca924

File tree

1 file changed

+12
-31
lines changed

1 file changed

+12
-31
lines changed

completions/bash/oci-runtime-tool

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ __oci-runtime-tool_subcommands() {
9494

9595
# List groups
9696
__oci-runtime-tool_groups() {
97-
cat /etc/group | cut -d: -f 1
97+
cat /etc/group | cut -d: -f 1
9898
}
9999

100100
# List installed hooks
101101
__oci-runtime-tool_hooks() {
102-
ls /usr/libexec/oci/hooks.d/*
102+
ls /usr/libexec/oci/hooks.d/*
103103
}
104104

105105
# suppress trailing whitespace
@@ -227,32 +227,26 @@ _oci-runtime-tool_oci-runtime-tool() {
227227
"
228228

229229
local boolean_options="
230-
$global_boolean_options
231-
--help
230+
--help -h
232231
--host-specific
233232
--version -v
234233
"
235234

236235
local all_options="$options_with_args $boolean_options"
237236

238237
case "$prev" in
239-
$(__oci-runtime-tool_to_extglob "$global_options_with_args") )
240-
return
241-
;;
242-
243238
--log-level)
244239
__oci-runtime-tool_complete_log_level
245240
return
246241
;;
247-
248242
esac
249243

250244
case "$cur" in
251245
-*)
252-
COMPREPLY=( $( compgen -W "$all_options $global_options_with_args" -- "$cur" ) )
246+
COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
253247
;;
254248
*)
255-
local counter=$( __oci-runtime-tool_pos_first_nonflag $(__oci-runtime-tool_to_extglob "$global_options_with_args") )
249+
local counter=$( __oci-runtime-tool_pos_first_nonflag $(__oci-runtime-tool_to_extglob "$options_with_args") )
256250
if [ $cword -eq $counter ]; then
257251
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
258252
fi
@@ -282,7 +276,7 @@ _oci-runtime-tool_validate() {
282276

283277
case "$cur" in
284278
-*)
285-
COMPREPLY=( $( compgen -W "--path --help" -- "$cur" ) )
279+
COMPREPLY=( $( compgen -W "--path --help -h" -- "$cur" ) )
286280
;;
287281
esac
288282

@@ -334,7 +328,6 @@ _oci-runtime-tool_generate() {
334328
--masked-paths
335329
--mount-cgroups
336330
--mount-label
337-
--oom-score-adj
338331
--os
339332
--output
340333
--poststart
@@ -364,8 +357,10 @@ _oci-runtime-tool_generate() {
364357

365358
local boolean_options="
366359
--disable-oom-kill
360+
--help -h
367361
--linux-namespace-remove-all
368362
--no-new-privileges
363+
--oom-score-adj
369364
--privileged
370365
--rlimits-remove-all
371366
--rootfs-readonly
@@ -378,12 +373,12 @@ _oci-runtime-tool_generate() {
378373

379374
case "$prev" in
380375
--seccomp-arch)
381-
__oci-runtime-tool_complete_seccomp_arches
376+
__oci-runtime-tool_complete_seccomp_arches
382377
return
383378
;;
384379

385380
--arch)
386-
__oci-runtime-tool_complete_arches
381+
__oci-runtime-tool_complete_arches
387382
return
388383
;;
389384

@@ -403,7 +398,7 @@ _oci-runtime-tool_generate() {
403398
;;
404399

405400
--mount-cgroups)
406-
COMPREPLY=( $( compgen -W "ro" -- "$cur" ) )
401+
COMPREPLY=( $( compgen -W "no ro rw" -- "$cur" ) )
407402
return
408403
;;
409404

@@ -446,11 +441,8 @@ _oci-runtime-tool_generate() {
446441
return
447442
;;
448443
--env-file)
449-
_filedir
444+
_filedir
450445
__oci-runtime-tool_nospace
451-
return
452-
;;
453-
$(__oci-runtime-tool_to_extglob "$options_with_args") )
454446
return
455447
;;
456448
esac
@@ -471,17 +463,6 @@ _oci-runtime-tool() {
471463
generate
472464
)
473465

474-
# These options are valid as global options for all client commands
475-
# and valid as command options for `oci-runtime-tool daemon`
476-
local global_boolean_options="
477-
--help -h
478-
--version -v
479-
"
480-
481-
local global_options_with_args="
482-
--help
483-
"
484-
485466
COMPREPLY=()
486467
local cur prev words cword
487468
_get_comp_words_by_ref -n : cur prev words cword

0 commit comments

Comments
 (0)