Merge pull request #611 from eramoto/completions-global-option

completions: Fix completions with a global option and indentation
This commit is contained in:
Valentin Rothberg 2019-03-06 11:04:11 +01:00 committed by GitHub
commit 0490018903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,9 +17,9 @@ _complete_() {
done done
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
;; ;;
*) *)
if [ -n "$transports" ] if [ -n "$transports" ]
then then
@ -84,7 +84,7 @@ _skopeo_inspect() {
_skopeo_standalone_sign() { _skopeo_standalone_sign() {
local options_with_args=" local options_with_args="
-o --output -o --output
" "
local boolean_options=" local boolean_options="
" "
@ -126,44 +126,44 @@ _skopeo_delete() {
_skopeo_layers() { _skopeo_layers() {
local options_with_args=" local options_with_args="
--creds --creds
--cert-dir --cert-dir
" "
local boolean_options=" local boolean_options="
--tls-verify --tls-verify
" "
_complete_ "$options_with_args" "$boolean_options" _complete_ "$options_with_args" "$boolean_options"
} }
_skopeo_skopeo() { _skopeo_skopeo() {
local options_with_args=" local options_with_args="
--policy --policy
--registries.d --registries.d
--override-arch --override-arch
--override-os --override-os
--command-timeout --command-timeout
" "
local boolean_options=" local boolean_options="
--insecure-policy --insecure-policy
--debug --debug
--version -v --version -v
--help -h --help -h
" "
commands=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) commands=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
case "$prev" in case "$prev" in
$main_options_with_args_glob ) $main_options_with_args_glob )
return return
;; ;;
esac esac
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
;; ;;
*) *)
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
;; ;;
esac esac
} }
@ -181,15 +181,17 @@ _cli_bash_autocomplete() {
local counter=1 local counter=1
counter=1 counter=1
while [ $counter -lt $cword ]; do while [ $counter -lt $cword ]; do
case "!${words[$counter]}" in case "${words[$counter]}" in
*) -*)
command=$(echo "${words[$counter]}" | sed 's/-/_/g') ;;
cpos=$counter *)
(( cpos++ )) command=$(echo "${words[$counter]}" | sed 's/-/_/g')
break cpos=$counter
;; (( cpos++ ))
esac break
(( counter++ )) ;;
esac
(( counter++ ))
done done
local completions_func=_skopeo_${command} local completions_func=_skopeo_${command}