From e775b26a78f2fdb9c9cd1fa3b73a7224688d28f4 Mon Sep 17 00:00:00 2001 From: Michael Scharf Date: Thu, 2 Oct 2014 19:01:10 +0200 Subject: [PATCH] add bash completion support for pause and unpause Signed-off-by: Michael Scharf --- contrib/completion/bash/docker | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 3cc85be203..40a8544050 100755 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -46,6 +46,22 @@ __docker_containers_stopped() 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() { local repos="$( __docker_q images | awk 'NR>1{print $1}' | grep -v '^$' )" @@ -453,6 +469,13 @@ _docker_logs() ;; esac } +_docker_pause() +{ + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_containers_not_paused + fi +} _docker_port() { @@ -715,6 +738,14 @@ _docker_tag() esac } +_docker_unpause() +{ + local counter=$(__docker_pos_first_nonflag) + if [ $cword -eq $counter ]; then + __docker_containers_paused + fi +} + _docker_top() { local counter=$(__docker_pos_first_nonflag) @@ -755,6 +786,7 @@ _docker() load login logs + pause port ps pull @@ -769,6 +801,7 @@ _docker() stop tag top + unpause version wait "