Add bash completion for `manifest` command family

Signed-off-by: Harald Albers <github@albersweb.de>
This commit is contained in:
Harald Albers 2018-07-31 21:24:31 +02:00
parent a183c952c6
commit 0fb4256a00
2 changed files with 109 additions and 0 deletions

View File

@ -18,6 +18,7 @@ type osArch struct {
// list of valid os/arch values (see "Optional Environment Variables" section // list of valid os/arch values (see "Optional Environment Variables" section
// of https://golang.org/doc/install/source // of https://golang.org/doc/install/source
// Added linux/s390x as we know System z support already exists // Added linux/s390x as we know System z support already exists
// Keep in sync with _docker_manifest_annotate in contrib/completion/bash/docker
var validOSArches = map[osArch]bool{ var validOSArches = map[osArch]bool{
{os: "darwin", arch: "386"}: true, {os: "darwin", arch: "386"}: true,
{os: "darwin", arch: "amd64"}: true, {os: "darwin", arch: "amd64"}: true,

View File

@ -1144,6 +1144,7 @@ _docker_docker() {
*) *)
local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" ) local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" )
if [ "$cword" -eq "$counter" ]; then if [ "$cword" -eq "$counter" ]; then
__docker_client_is_experimental && commands+=(${experimental_client_commands[*]})
__docker_server_is_experimental && commands+=(${experimental_server_commands[*]}) __docker_server_is_experimental && commands+=(${experimental_server_commands[*]})
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) ) COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
fi fi
@ -3833,6 +3834,109 @@ _docker_swarm_update() {
esac esac
} }
_docker_manifest() {
local subcommands="
annotate
create
inspect
push
"
__docker_subcommands "$subcommands" && return
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
;;
*)
COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
;;
esac
}
_docker_manifest_annotate() {
case "$prev" in
--arch)
COMPREPLY=( $( compgen -W "
386
amd64
arm
arm64
mips64
mips64le
ppc64le
s390x" -- "$cur" ) )
return
;;
--os)
COMPREPLY=( $( compgen -W "
darwin
dragonfly
freebsd
linux
netbsd
openbsd
plan9
solaris
windows" -- "$cur" ) )
return
;;
--os-features|--variant)
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--arch --help --os --os-features --variant" -- "$cur" ) )
;;
*)
local counter=$( __docker_pos_first_nonflag "--arch|--os|--os-features|--variant" )
if [ "$cword" -eq "$counter" ] || [ "$cword" -eq "$((counter + 1))" ]; then
__docker_complete_images --force-tag --id
fi
;;
esac
}
_docker_manifest_create() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--amend -a --help --insecure" -- "$cur" ) )
;;
*)
__docker_complete_images --force-tag --id
;;
esac
}
_docker_manifest_inspect() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --insecure --verbose -v" -- "$cur" ) )
;;
*)
local counter=$( __docker_pos_first_nonflag )
if [ "$cword" -eq "$counter" ] || [ "$cword" -eq "$((counter + 1))" ]; then
__docker_complete_images --force-tag --id
fi
;;
esac
}
_docker_manifest_push() {
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --insecure --purge -p" -- "$cur" ) )
;;
*)
local counter=$( __docker_pos_first_nonflag )
if [ "$cword" -eq "$counter" ]; then
__docker_complete_images --force-tag --id
fi
;;
esac
}
_docker_node() { _docker_node() {
local subcommands=" local subcommands="
demote demote
@ -5090,6 +5194,10 @@ _docker() {
wait wait
) )
local experimental_client_commands=(
manifest
)
local experimental_server_commands=( local experimental_server_commands=(
checkpoint checkpoint
deploy deploy