Skip to content

Commit

Permalink
Detect compose plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
(cherry picked from commit 5a8d7d5)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
ulyssessouza authored and thaJeztah committed Aug 26, 2022
1 parent b30d250 commit 613b936
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -5485,21 +5485,21 @@ _docker_wait() {
_docker_container_wait
}

COMPOSE_PLUGIN_PATH=$(docker info --format '{{json .ClientInfo.Plugins}}' | sed -n 's/.*"Path":"\([^"]\+docker-compose\)".*/\1/p')

_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
local resultArray=($COMPOSE_PLUGIN_PATH $completionCommand compose)
for value in "${words[@]:2}"; do
if [ -z "$value" ]; then
resultArray+=( "''" )
else
resultArray+=( "${value}" )
resultArray+=( "$value" )
fi
done
local result=$(eval "${resultArray[*]}" 2> /dev/null)
local result=$(eval "${resultArray[*]}" 2> /dev/null | grep -v '^:[0-9]*$')

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

_docker() {
Expand Down Expand Up @@ -5571,9 +5571,11 @@ _docker() {
wait
)

local known_plugin_commands=(
compose
)
local known_plugin_commands=()

if [ -f "$COMPOSE_PLUGIN_PATH" ] ; then
known_plugin_commands+=("compose")
fi

local experimental_server_commands=(
checkpoint
Expand Down

0 comments on commit 613b936

Please sign in to comment.