From af84b7e4417b9b2cc90a8882b0874411e44abe76 Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Thu, 1 Dec 2016 10:27:14 -0800 Subject: [PATCH 1/2] Allow selective activation of experimental features in bash completion Signed-off-by: Harald Albers --- contrib/completion/bash/docker | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index d0e3b16686..81eac85a5b 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -409,6 +409,13 @@ __docker_append_to_completions() { COMPREPLY=( ${COMPREPLY[@]/%/"$1"} ) } +# __docker_is_experimental tests whether the currently configured Docker daemon +# runs in experimental mode. If so, the function exits with 0 (true). +# Otherwise, or if the result cannot be determined, the exit value is 1 (false). +__docker_is_experimental() { + [ "$(__docker_q version -f '{{.Server.Experimental}}')" = "true" ] +} + # __docker_pos_first_nonflag finds the position of the first word that is neither # option nor an option's argument. If there are options that require arguments, # you should pass a glob describing those options, e.g. "--option1|-o|--option2" @@ -851,6 +858,7 @@ _docker_docker() { *) local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" ) if [ $cword -eq $counter ]; then + __docker_is_experimental && commands+=(${experimental_commands[*]}) COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) ) fi ;; @@ -3856,6 +3864,9 @@ _docker() { wait ) + local experimental_commands=( + ) + # These options are valid as global options for all client commands # and valid as command options for `docker daemon` local global_boolean_options=" From 10f567ec6aaa059626bbe32eb8786bf5a4b447fc Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Fri, 2 Dec 2016 03:19:08 -0800 Subject: [PATCH 2/2] Add bash completion for experimental `docker deploy` Signed-off-by: Harald Albers --- contrib/completion/bash/docker | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 81eac85a5b..63b1b2e653 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -1882,6 +1882,10 @@ _docker_daemon() { esac } +_docker_deploy() { + __docker_is_experimental && _docker_stack_deploy +} + _docker_diff() { _docker_container_diff } @@ -3865,6 +3869,7 @@ _docker() { ) local experimental_commands=( + deploy ) # These options are valid as global options for all client commands