Skip to content

Commit

Permalink
Merge pull request moby#30444 from albers/completion-checkpoints
Browse files Browse the repository at this point in the history
Add bash completion for `docker checkpoint`
  • Loading branch information
LK4D4 authored Feb 1, 2017
2 parents f9998c8 + 926fa56 commit 39f717a
Showing 1 changed file with 106 additions and 1 deletion.
107 changes: 106 additions & 1 deletion contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,94 @@ _docker_build() {
}


_docker_checkpoint() {
local subcommands="
create
ls
rm
"
local aliases="
list
remove
"
__docker_subcommands "$subcommands $aliases" && return

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
;;
*)
COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
;;
esac
}

_docker_checkpoint_create() {
case "$prev" in
--checkpoint-dir)
_filedir -d
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--checkpoint-dir --help --leave-running" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '--checkpoint-dir')
if [ $cword -eq $counter ]; then
__docker_complete_containers_running
fi
;;
esac
}

_docker_checkpoint_ls() {
case "$prev" in
--checkpoint-dir)
_filedir -d
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--checkpoint-dir --help" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '--checkpoint-dir')
if [ $cword -eq $counter ]; then
__docker_complete_containers_all
fi
;;
esac
}

_docker_checkpoint_rm() {
case "$prev" in
--checkpoint-dir)
_filedir -d
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--checkpoint-dir --help" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '--checkpoint-dir')
if [ $cword -eq $counter ]; then
__docker_complete_containers_all
elif [ $cword -eq $(($counter + 1)) ]; then
COMPREPLY=( $( compgen -W "$(__docker_q checkpoint ls "$prev" | sed 1d)" -- "$cur" ) )
fi
;;
esac
}


_docker_container() {
local subcommands="
attach
Expand Down Expand Up @@ -1644,9 +1732,25 @@ _docker_container_run() {
_docker_container_start() {
__docker_complete_detach-keys && return

case "$prev" in
--checkpoint)
if [ __docker_is_experimental ] ; then
return
fi
;;
--checkpoint-dir)
if [ __docker_is_experimental ] ; then
_filedir -d
return
fi
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--attach -a --detach-keys --help --interactive -i" -- "$cur" ) )
local options="--attach -a --detach-keys --help --interactive -i"
__docker_is_experimental && options+=" --checkpoint --checkpoint-dir"
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
;;
*)
__docker_complete_containers_stopped
Expand Down Expand Up @@ -4173,6 +4277,7 @@ _docker() {
)

local experimental_commands=(
checkpoint
deploy
)

Expand Down

0 comments on commit 39f717a

Please sign in to comment.