add bash completion support for pause and unpause

Signed-off-by: Michael Scharf <github@scharf.gr>
This commit is contained in:
Michael Scharf 2014-10-02 19:01:10 +02:00 committed by Tibor Vass
parent c5f3535b06
commit e775b26a78
1 changed files with 33 additions and 0 deletions

View File

@ -46,6 +46,22 @@ __docker_containers_stopped()
COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) )
} }
__docker_containers_paused()
{
local containers="$( __docker_q ps -q)"
local names="$( __docker_q inspect --format='{{.State.Paused}} {{.Name}}' $containers | sed 's/^false.*//' | sed 's,^true /,,' )"
local hostnames="$( __docker_q inspect --format='{{.State.Paused}} {{.Config.Hostname}}' $containers | sed 's/^false.*//' | sed 's,^true ,,' )"
COMPREPLY=( $( compgen -W "$names $hostnames" -- "$cur" ) )
}
__docker_containers_not_paused()
{
local containers="$( __docker_q ps -q)"
local names="$( __docker_q inspect --format='{{.State.Paused}} {{.Name}}' $containers | sed 's/^true.*//' | sed 's,^false /,,' )"
local hostnames="$( __docker_q inspect --format='{{.State.Paused}} {{.Config.Hostname}}' $containers | sed 's/^true.*//' | sed 's/^false //' )"
COMPREPLY=( $( compgen -W "$names $hostnames" -- "$cur" ) )
}
__docker_image_repos() __docker_image_repos()
{ {
local repos="$( __docker_q images | awk 'NR>1{print $1}' | grep -v '^<none>$' )" local repos="$( __docker_q images | awk 'NR>1{print $1}' | grep -v '^<none>$' )"
@ -453,6 +469,13 @@ _docker_logs()
;; ;;
esac esac
} }
_docker_pause()
{
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_not_paused
fi
}
_docker_port() _docker_port()
{ {
@ -715,6 +738,14 @@ _docker_tag()
esac esac
} }
_docker_unpause()
{
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_containers_paused
fi
}
_docker_top() _docker_top()
{ {
local counter=$(__docker_pos_first_nonflag) local counter=$(__docker_pos_first_nonflag)
@ -755,6 +786,7 @@ _docker()
load load
login login
logs logs
pause
port port
ps ps
pull pull
@ -769,6 +801,7 @@ _docker()
stop stop
tag tag
top top
unpause
version version
wait wait
" "