Skip to content

Commit 2ac475c

Browse files
albersthaJeztah
authored andcommitted
Add bash completion for manifest command family
Signed-off-by: Harald Albers <github@albersweb.de> (cherry picked from commit 0fb4256) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 2a36695 commit 2ac475c

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

cli/command/manifest/util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type osArch struct {
1818
// list of valid os/arch values (see "Optional Environment Variables" section
1919
// of https://golang.org/doc/install/source
2020
// Added linux/s390x as we know System z support already exists
21+
// Keep in sync with _docker_manifest_annotate in contrib/completion/bash/docker
2122
var validOSArches = map[osArch]bool{
2223
{os: "darwin", arch: "386"}: true,
2324
{os: "darwin", arch: "amd64"}: true,

contrib/completion/bash/docker

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,7 @@ _docker_docker() {
11441144
*)
11451145
local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" )
11461146
if [ "$cword" -eq "$counter" ]; then
1147+
__docker_client_is_experimental && commands+=(${experimental_client_commands[*]})
11471148
__docker_server_is_experimental && commands+=(${experimental_server_commands[*]})
11481149
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
11491150
fi
@@ -3836,6 +3837,109 @@ _docker_swarm_update() {
38363837
esac
38373838
}
38383839

3840+
_docker_manifest() {
3841+
local subcommands="
3842+
annotate
3843+
create
3844+
inspect
3845+
push
3846+
"
3847+
__docker_subcommands "$subcommands" && return
3848+
3849+
case "$cur" in
3850+
-*)
3851+
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
3852+
;;
3853+
*)
3854+
COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
3855+
;;
3856+
esac
3857+
}
3858+
3859+
_docker_manifest_annotate() {
3860+
case "$prev" in
3861+
--arch)
3862+
COMPREPLY=( $( compgen -W "
3863+
386
3864+
amd64
3865+
arm
3866+
arm64
3867+
mips64
3868+
mips64le
3869+
ppc64le
3870+
s390x" -- "$cur" ) )
3871+
return
3872+
;;
3873+
--os)
3874+
COMPREPLY=( $( compgen -W "
3875+
darwin
3876+
dragonfly
3877+
freebsd
3878+
linux
3879+
netbsd
3880+
openbsd
3881+
plan9
3882+
solaris
3883+
windows" -- "$cur" ) )
3884+
return
3885+
;;
3886+
--os-features|--variant)
3887+
return
3888+
;;
3889+
esac
3890+
3891+
case "$cur" in
3892+
-*)
3893+
COMPREPLY=( $( compgen -W "--arch --help --os --os-features --variant" -- "$cur" ) )
3894+
;;
3895+
*)
3896+
local counter=$( __docker_pos_first_nonflag "--arch|--os|--os-features|--variant" )
3897+
if [ "$cword" -eq "$counter" ] || [ "$cword" -eq "$((counter + 1))" ]; then
3898+
__docker_complete_images --force-tag --id
3899+
fi
3900+
;;
3901+
esac
3902+
}
3903+
3904+
_docker_manifest_create() {
3905+
case "$cur" in
3906+
-*)
3907+
COMPREPLY=( $( compgen -W "--amend -a --help --insecure" -- "$cur" ) )
3908+
;;
3909+
*)
3910+
__docker_complete_images --force-tag --id
3911+
;;
3912+
esac
3913+
}
3914+
3915+
_docker_manifest_inspect() {
3916+
case "$cur" in
3917+
-*)
3918+
COMPREPLY=( $( compgen -W "--help --insecure --verbose -v" -- "$cur" ) )
3919+
;;
3920+
*)
3921+
local counter=$( __docker_pos_first_nonflag )
3922+
if [ "$cword" -eq "$counter" ] || [ "$cword" -eq "$((counter + 1))" ]; then
3923+
__docker_complete_images --force-tag --id
3924+
fi
3925+
;;
3926+
esac
3927+
}
3928+
3929+
_docker_manifest_push() {
3930+
case "$cur" in
3931+
-*)
3932+
COMPREPLY=( $( compgen -W "--help --insecure --purge -p" -- "$cur" ) )
3933+
;;
3934+
*)
3935+
local counter=$( __docker_pos_first_nonflag )
3936+
if [ "$cword" -eq "$counter" ]; then
3937+
__docker_complete_images --force-tag --id
3938+
fi
3939+
;;
3940+
esac
3941+
}
3942+
38393943
_docker_node() {
38403944
local subcommands="
38413945
demote
@@ -5093,6 +5197,10 @@ _docker() {
50935197
wait
50945198
)
50955199

5200+
local experimental_client_commands=(
5201+
manifest
5202+
)
5203+
50965204
local experimental_server_commands=(
50975205
checkpoint
50985206
deploy

0 commit comments

Comments
 (0)