Merge pull request #3752 from thaJeztah/20.10_backport_completion

[20.10 backport] Add completion for docker-compose plugin
This commit is contained in:
Sebastiaan van Stijn 2022-08-27 21:37:23 +02:00 committed by GitHub
commit bd04f199f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 1 deletions

View File

@ -5485,6 +5485,23 @@ _docker_wait() {
_docker_container_wait
}
COMPOSE_PLUGIN_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}')
_docker_compose() {
local completionCommand="__completeNoDesc"
local resultArray=($COMPOSE_PLUGIN_PATH $completionCommand compose)
for value in "${words[@]:2}"; do
if [ -z "$value" ]; then
resultArray+=( "''" )
else
resultArray+=( "$value" )
fi
done
local result=$(eval "${resultArray[*]}" 2> /dev/null | grep -v '^:[0-9]*$')
COMPREPLY=( $(compgen -W "${result}" -- "$current") )
}
_docker() {
local previous_extglob_setting=$(shopt -p extglob)
shopt -s extglob
@ -5554,11 +5571,17 @@ _docker() {
wait
)
local known_plugin_commands=()
if [ -f "$COMPOSE_PLUGIN_PATH" ] ; then
known_plugin_commands+=("compose")
fi
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