Skip to content

Commit

Permalink
Add completion for docker-compose plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Ulysses Souza <[email protected]>
(cherry picked from commit 1148163)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
ulyssessouza authored and thaJeztah committed Aug 26, 2022
1 parent fe0cdaf commit b30d250
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -5485,6 +5485,23 @@ _docker_wait() {
_docker_container_wait
}

_docker_compose() {
local composePluginPath="${HOME}/.docker/cli-plugins/docker-compose"
local completionCommand="__completeNoDesc"
local resultArray=(${composePluginPath} ${completionCommand} compose)
for value in "${words[@]:2}"
do
if [[ "${value}" == "" ]] ; then
resultArray+=( "''" )
else
resultArray+=( "${value}" )
fi
done
local result=$(eval "${resultArray[*]}" 2> /dev/null)

COMPREPLY=( $(compgen -W "${result%%:*}" -- "$current") )
}

_docker() {
local previous_extglob_setting=$(shopt -p extglob)
shopt -s extglob
Expand Down Expand Up @@ -5554,11 +5571,15 @@ _docker() {
wait
)

local known_plugin_commands=(
compose
)

local experimental_server_commands=(
checkpoint
)

local commands=(${management_commands[*]} ${top_level_commands[*]})
local commands=(${management_commands[*]} ${top_level_commands[*]} ${known_plugin_commands[*]})
[ -z "$DOCKER_HIDE_LEGACY_COMMANDS" ] && commands+=(${legacy_commands[*]})

# These options are valid as global options for all client commands
Expand Down

0 comments on commit b30d250

Please sign in to comment.