From de2dd5b3d380cbbe50a2c040e55b94cd4fe2c259 Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Thu, 16 Mar 2017 15:47:01 +0100 Subject: [PATCH 1/2] Add bash completion for `--project-directory` Signed-off-by: Harald Albers --- contrib/completion/bash/docker-compose | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/completion/bash/docker-compose b/contrib/completion/bash/docker-compose index 2591f500b..e6e5bd6cd 100644 --- a/contrib/completion/bash/docker-compose +++ b/contrib/completion/bash/docker-compose @@ -160,6 +160,10 @@ _docker_compose_docker_compose() { _filedir "y?(a)ml" return ;; + --project-directory) + _filedir -d + return + ;; $(__docker_compose_to_extglob "$daemon_options_with_args") ) return ;; @@ -554,6 +558,7 @@ _docker_compose() { local daemon_options_with_args=" --file -f --host -H + --project-directory --project-name -p --tlscacert --tlscert From 6a773a018e1ca917d8c05abe9b6d5fceda845e6e Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Thu, 16 Mar 2017 16:01:43 +0100 Subject: [PATCH 2/2] Rename variables in bash completion The old names were supposed to designate variables that get propagated to the Docker daemon. This is not true for all contained options and therefore confused me. The new names focus on the placement after the top level command. Signed-off-by: Harald Albers --- contrib/completion/bash/docker-compose | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/completion/bash/docker-compose b/contrib/completion/bash/docker-compose index e6e5bd6cd..89485e24a 100644 --- a/contrib/completion/bash/docker-compose +++ b/contrib/completion/bash/docker-compose @@ -18,7 +18,7 @@ __docker_compose_q() { - docker-compose 2>/dev/null "${daemon_options[@]}" "$@" + docker-compose 2>/dev/null "${top_level_options[@]}" "$@" } # Transforms a multiline list of strings into a single line string @@ -164,14 +164,14 @@ _docker_compose_docker_compose() { _filedir -d return ;; - $(__docker_compose_to_extglob "$daemon_options_with_args") ) + $(__docker_compose_to_extglob "$top_level_options_with_args") ) return ;; esac case "$cur" in -*) - COMPREPLY=( $( compgen -W "$daemon_boolean_options $daemon_options_with_args --help -h --verbose --version -v" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "$top_level_boolean_options $top_level_options_with_args --help -h --verbose --version -v" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) @@ -550,12 +550,12 @@ _docker_compose() { # options for the docker daemon that have to be passed to secondary calls to # docker-compose executed by this script - local daemon_boolean_options=" + local top_level_boolean_options=" --skip-hostname-check --tls --tlsverify " - local daemon_options_with_args=" + local top_level_options_with_args=" --file -f --host -H --project-directory @@ -572,19 +572,19 @@ _docker_compose() { # search subcommand and invoke its handler. # special treatment of some top-level options local command='docker_compose' - local daemon_options=() + local top_level_options=() local counter=1 while [ $counter -lt $cword ]; do case "${words[$counter]}" in - $(__docker_compose_to_extglob "$daemon_boolean_options") ) + $(__docker_compose_to_extglob "$top_level_boolean_options") ) local opt=${words[counter]} - daemon_options+=($opt) + top_level_options+=($opt) ;; - $(__docker_compose_to_extglob "$daemon_options_with_args") ) + $(__docker_compose_to_extglob "$top_level_options_with_args") ) local opt=${words[counter]} local arg=${words[++counter]} - daemon_options+=($opt $arg) + top_level_options+=($opt $arg) ;; -*) ;;