Delegate bash completion for docker {container,image} inspect
to parameterized function
In #23614 `docker inspect` was semantically enhanced to inspect "everything". Therefore moving its logic to `_docker_container_inspect` was not correct. This commit moves it back to its original top-level location (`_docker_inspect`) so that it can be called by `_docker_{container,image}_inspect` and others (will be added in follow-up PRs). Parameterization was added in order to get caller-specific behavior. Signed-off-by: Harald Albers <github@albersweb.de>
This commit is contained in:
parent
e8310f310d
commit
918ff45c1a
@ -1021,34 +1021,7 @@ _docker_container_export() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_docker_container_inspect() {
|
_docker_container_inspect() {
|
||||||
case "$prev" in
|
_docker_inspect --type container
|
||||||
--format|-f)
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
--type)
|
|
||||||
COMPREPLY=( $( compgen -W "image container" -- "$cur" ) )
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$cur" in
|
|
||||||
-*)
|
|
||||||
COMPREPLY=( $( compgen -W "--format -f --help --size -s --type" -- "$cur" ) )
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
case $(__docker_value_of_option --type) in
|
|
||||||
'')
|
|
||||||
__docker_complete_containers_and_images
|
|
||||||
;;
|
|
||||||
container)
|
|
||||||
__docker_complete_containers_all
|
|
||||||
;;
|
|
||||||
image)
|
|
||||||
__docker_complete_images
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_container_kill() {
|
_docker_container_kill() {
|
||||||
@ -2106,7 +2079,7 @@ _docker_image_import() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_docker_image_inspect() {
|
_docker_image_inspect() {
|
||||||
_docker_inspect
|
_docker_inspect --type image
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_image_load() {
|
_docker_image_load() {
|
||||||
@ -2220,7 +2193,47 @@ _docker_info() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_docker_inspect() {
|
_docker_inspect() {
|
||||||
_docker_container_inspect
|
local type
|
||||||
|
|
||||||
|
if [ "$1" = "--type" ] ; then
|
||||||
|
type="$2"
|
||||||
|
else
|
||||||
|
type=$(__docker_value_of_option --type)
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$prev" in
|
||||||
|
--format|-f)
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
--type)
|
||||||
|
if [ -z "$type" ] ; then
|
||||||
|
COMPREPLY=( $( compgen -W "image container" -- "$cur" ) )
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$cur" in
|
||||||
|
-*)
|
||||||
|
local options="--format -f --help --size -s"
|
||||||
|
if [ -z "$type" ] ; then
|
||||||
|
options+=" --type"
|
||||||
|
fi
|
||||||
|
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
case "$type" in
|
||||||
|
'')
|
||||||
|
__docker_complete_containers_and_images
|
||||||
|
;;
|
||||||
|
container)
|
||||||
|
__docker_complete_containers_all
|
||||||
|
;;
|
||||||
|
image)
|
||||||
|
__docker_complete_images
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_kill() {
|
_docker_kill() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user