mirror of
https://github.com/containers/skopeo.git
synced 2025-09-23 02:48:26 +00:00
completions: Introduce transports completions
Introduces bash completions for transports which commands (copy, delete, and inspect) support. Signed-off-by: ERAMOTO Masaya <eramoto.masaya@jp.fujitsu.com>
This commit is contained in:
@@ -5,11 +5,12 @@
|
|||||||
_complete_() {
|
_complete_() {
|
||||||
local options_with_args=$1
|
local options_with_args=$1
|
||||||
local boolean_options="$2 -h --help"
|
local boolean_options="$2 -h --help"
|
||||||
|
local transports=$3
|
||||||
|
|
||||||
local option_with_args
|
local option_with_args
|
||||||
for option_with_args in $options_with_args
|
for option_with_args in $options_with_args $transports
|
||||||
do
|
do
|
||||||
if [ "$option_with_args" == "$prev" ]
|
if [ "$option_with_args" == "$prev" -o "$option_with_args" == "$cur" ]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@@ -19,9 +20,22 @@ _complete_() {
|
|||||||
-*)
|
-*)
|
||||||
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
if [ -n "$transports" ]
|
||||||
|
then
|
||||||
|
compopt -o nospace
|
||||||
|
COMPREPLY=( $( compgen -W "$transports" -- "$cur" ) )
|
||||||
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_skopeo_supported_transports() {
|
||||||
|
local subcommand=$1
|
||||||
|
|
||||||
|
${PROG} $subcommand --help | grep "Supported transports" -A 1 | tail -n 1 | sed -e 's/,/:/g' -e 's/$/:/'
|
||||||
|
}
|
||||||
|
|
||||||
_skopeo_copy() {
|
_skopeo_copy() {
|
||||||
local options_with_args="
|
local options_with_args="
|
||||||
--authfile
|
--authfile
|
||||||
@@ -43,7 +57,11 @@ _skopeo_copy() {
|
|||||||
--remove-signatures
|
--remove-signatures
|
||||||
"
|
"
|
||||||
|
|
||||||
_complete_ "$options_with_args" "$boolean_options"
|
local transports="
|
||||||
|
$(_skopeo_supported_transports $(echo $FUNCNAME | sed 's/_skopeo_//'))
|
||||||
|
"
|
||||||
|
|
||||||
|
_complete_ "$options_with_args" "$boolean_options" "$transports"
|
||||||
}
|
}
|
||||||
|
|
||||||
_skopeo_inspect() {
|
_skopeo_inspect() {
|
||||||
@@ -56,7 +74,12 @@ _skopeo_inspect() {
|
|||||||
--raw
|
--raw
|
||||||
--tls-verify
|
--tls-verify
|
||||||
"
|
"
|
||||||
_complete_ "$options_with_args" "$boolean_options"
|
|
||||||
|
local transports="
|
||||||
|
$(_skopeo_supported_transports $(echo $FUNCNAME | sed 's/_skopeo_//'))
|
||||||
|
"
|
||||||
|
|
||||||
|
_complete_ "$options_with_args" "$boolean_options" "$transports"
|
||||||
}
|
}
|
||||||
|
|
||||||
_skopeo_standalone_sign() {
|
_skopeo_standalone_sign() {
|
||||||
@@ -93,7 +116,12 @@ _skopeo_delete() {
|
|||||||
local boolean_options="
|
local boolean_options="
|
||||||
--tls-verify
|
--tls-verify
|
||||||
"
|
"
|
||||||
_complete_ "$options_with_args" "$boolean_options"
|
|
||||||
|
local transports="
|
||||||
|
$(_skopeo_supported_transports $(echo $FUNCNAME | sed 's/_skopeo_//'))
|
||||||
|
"
|
||||||
|
|
||||||
|
_complete_ "$options_with_args" "$boolean_options" "$transports"
|
||||||
}
|
}
|
||||||
|
|
||||||
_skopeo_layers() {
|
_skopeo_layers() {
|
||||||
|
Reference in New Issue
Block a user