mirror of
https://github.com/containers/skopeo.git
synced 2025-09-14 05:50:56 +00:00
Merge pull request #256 from rhatdan/bash_completions
Complete bash completions for skopeo
This commit is contained in:
2
Makefile
2
Makefile
@@ -81,7 +81,7 @@ install-docs: docs/skopeo.1
|
|||||||
install -D -m 644 docs/skopeo.1 ${MANINSTALLDIR}/man1/skopeo.1
|
install -D -m 644 docs/skopeo.1 ${MANINSTALLDIR}/man1/skopeo.1
|
||||||
|
|
||||||
install-completions:
|
install-completions:
|
||||||
install -m 644 -D hack/make/bash_autocomplete ${BASHINSTALLDIR}/skopeo
|
install -m 644 -D completions/bash/skopeo ${BASHINSTALLDIR}/skopeo
|
||||||
|
|
||||||
shell: build-container
|
shell: build-container
|
||||||
$(DOCKER_RUN_DOCKER) bash
|
$(DOCKER_RUN_DOCKER) bash
|
||||||
|
148
completions/bash/skopeo
Normal file
148
completions/bash/skopeo
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
: ${PROG:=$(basename ${BASH_SOURCE})}
|
||||||
|
|
||||||
|
_complete_() {
|
||||||
|
local options_with_args=$1
|
||||||
|
local boolean_options="$2 -h --help"
|
||||||
|
|
||||||
|
case "$prev" in
|
||||||
|
$options_with_args)
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$cur" in
|
||||||
|
-*)
|
||||||
|
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_skopeo_copy() {
|
||||||
|
local options_with_args="
|
||||||
|
--sign-by
|
||||||
|
--src-creds --screds
|
||||||
|
--dest-creds --dcreds
|
||||||
|
"
|
||||||
|
local boolean_options="
|
||||||
|
--remove-signatures
|
||||||
|
"
|
||||||
|
_complete_ "$options_with_args" "$boolean_options"
|
||||||
|
}
|
||||||
|
|
||||||
|
_skopeo_inspect() {
|
||||||
|
local options_with_args="
|
||||||
|
--creds
|
||||||
|
"
|
||||||
|
local boolean_options="
|
||||||
|
--raw
|
||||||
|
"
|
||||||
|
_complete_ "$options_with_args" "$boolean_options"
|
||||||
|
}
|
||||||
|
|
||||||
|
_skopeo_standalone_sign() {
|
||||||
|
local options_with_args="
|
||||||
|
-o --output
|
||||||
|
"
|
||||||
|
local boolean_options="
|
||||||
|
"
|
||||||
|
_complete_ "$options_with_args" "$boolean_options"
|
||||||
|
}
|
||||||
|
|
||||||
|
_skopeo_standalone_verify() {
|
||||||
|
local options_with_args="
|
||||||
|
"
|
||||||
|
local boolean_options="
|
||||||
|
"
|
||||||
|
_complete_ "$options_with_args" "$boolean_options"
|
||||||
|
}
|
||||||
|
|
||||||
|
_skopeo_manifest_digest() {
|
||||||
|
local options_with_args="
|
||||||
|
"
|
||||||
|
local boolean_options="
|
||||||
|
"
|
||||||
|
_complete_ "$options_with_args" "$boolean_options"
|
||||||
|
}
|
||||||
|
|
||||||
|
_skopeo_delete() {
|
||||||
|
local options_with_args="
|
||||||
|
--creds
|
||||||
|
"
|
||||||
|
local boolean_options="
|
||||||
|
"
|
||||||
|
_complete_ "$options_with_args" "$boolean_options"
|
||||||
|
}
|
||||||
|
|
||||||
|
_skopeo_layers() {
|
||||||
|
local options_with_args="
|
||||||
|
"
|
||||||
|
local boolean_options="
|
||||||
|
"
|
||||||
|
_complete_ "$options_with_args" "$boolean_options"
|
||||||
|
}
|
||||||
|
|
||||||
|
_skopeo_skopeo() {
|
||||||
|
local options_with_args="
|
||||||
|
--cert-path
|
||||||
|
--policy
|
||||||
|
--registries.d
|
||||||
|
"
|
||||||
|
local boolean_options="
|
||||||
|
--debug
|
||||||
|
--tls-verify
|
||||||
|
--version -v
|
||||||
|
--help -h
|
||||||
|
"
|
||||||
|
commands=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
|
||||||
|
|
||||||
|
case "$prev" in
|
||||||
|
$main_options_with_args_glob )
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$cur" in
|
||||||
|
-*)
|
||||||
|
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_cli_bash_autocomplete() {
|
||||||
|
local cur opts base
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
COMPREPLY=()
|
||||||
|
local cur prev words cword
|
||||||
|
|
||||||
|
_get_comp_words_by_ref -n : cur prev words cword
|
||||||
|
|
||||||
|
local command=${PROG} cpos=0
|
||||||
|
local counter=1
|
||||||
|
counter=1
|
||||||
|
while [ $counter -lt $cword ]; do
|
||||||
|
case "!${words[$counter]}" in
|
||||||
|
*)
|
||||||
|
command=$(echo "${words[$counter]}" | sed 's/-/_/g')
|
||||||
|
cpos=$counter
|
||||||
|
(( cpos++ ))
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
(( counter++ ))
|
||||||
|
done
|
||||||
|
|
||||||
|
local completions_func=_skopeo_${command}
|
||||||
|
declare -F $completions_func >/dev/null && $completions_func
|
||||||
|
|
||||||
|
eval "$previous_extglob_setting"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _cli_bash_autocomplete $PROG
|
@@ -1,14 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
|
|
||||||
: ${PROG:=$(basename ${BASH_SOURCE})}
|
|
||||||
|
|
||||||
_cli_bash_autocomplete() {
|
|
||||||
local cur opts base
|
|
||||||
COMPREPLY=()
|
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
||||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
|
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
complete -F _cli_bash_autocomplete $PROG
|
|
Reference in New Issue
Block a user