From 28c66b04911e98617be65bd4dce9cb9b9e134e4c Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Fri, 16 Oct 2015 11:25:46 +0200 Subject: [PATCH 1/2] Add missing options to bash completion for `docker build` Signed-off-by: Harald Albers --- contrib/completion/bash/docker | 38 +++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index c1720e458c..99be9856fa 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -461,8 +461,37 @@ _docker_attach() { } _docker_build() { + local options_with_args=" + --build-arg + --cgroup-parent + --cpuset-cpus + --cpuset-mems + --cpu-shares -c + --cpu-period + --cpu-quota + --file -f + --memory -m + --memory-swap + --tag -t + --ulimit + " + + local boolean_options=" + --disable-content-trust=false + --force-rm + --help + --no-cache + --pull + --quiet -q + --rm + " + + local all_options="$options_with_args $boolean_options" + case "$prev" in - --cgroup-parent|--cpuset-cpus|--cpuset-mems|--cpu-shares|-c|--cpu-period|--cpu-quota|--memory|-m|--memory-swap) + --build-arg) + COMPREPLY=( $( compgen -e -- "$cur" ) ) + __docker_nospace return ;; --file|-f) @@ -473,14 +502,17 @@ _docker_build() { __docker_image_repos_and_tags return ;; + $(__docker_to_extglob "$options_with_args") ) + return + ;; esac case "$cur" in -*) - COMPREPLY=( $( compgen -W "--cgroup-parent --cpuset-cpus --cpuset-mems --cpu-shares -c --cpu-period --cpu-quota --file -f --force-rm --help --memory -m --memory-swap --no-cache --pull --quiet -q --rm --tag -t --ulimit" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) ;; *) - local counter="$(__docker_pos_first_nonflag '--cgroup-parent|--cpuset-cpus|--cpuset-mems|--cpu-shares|-c|--cpu-period|--cpu-quota|--file|-f|--memory|-m|--memory-swap|--tag|-t')" + local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) if [ $cword -eq $counter ]; then _filedir -d fi From 3a713d91ce7d9edfe301e367f097d8cf370d2c52 Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Fri, 16 Oct 2015 11:31:31 +0200 Subject: [PATCH 2/2] bash completion: minor refactoring for consistency Signed-off-by: Harald Albers --- contrib/completion/bash/docker | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 99be9856fa..b7b09a6b39 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -1343,7 +1343,7 @@ _docker_run() { --workdir -w " - local all_options="$options_with_args + local boolean_options=" --disable-content-trust=false --help --interactive -i @@ -1354,14 +1354,14 @@ _docker_run() { --tty -t " + local all_options="$options_with_args $boolean_options" + [ "$command" = "run" ] && all_options="$all_options --detach -d --rm --sig-proxy=false " - local options_with_args_glob=$(__docker_to_extglob "$options_with_args") - case "$prev" in --add-host) case "$cur" in @@ -1486,7 +1486,7 @@ _docker_run() { __docker_containers_all return ;; - $options_with_args_glob ) + $(__docker_to_extglob "$options_with_args") ) return ;; esac