Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 83a3adf

Browse files
artheus-sbabthaJeztah
authored andcommitted
Make service completion faster
Signed-off-by: Morten Hekkvang <morten.hekkvang@sbab.se> (cherry picked from commit f55c5b6566e52d3ead55bc0d96528bc2a39daeea) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 667bd9a1b8fd9bb2066fbb575e6359d15892707e Component: cli
1 parent c4b8f0f commit 83a3adf

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

  • components/cli/contrib/completion/bash

components/cli/contrib/completion/bash/docker

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,17 +550,18 @@ __docker_complete_nodes() {
550550
# output to the IDs or names of matching items. This setting takes
551551
# precedence over the environment setting.
552552
__docker_services() {
553-
local fields='$2' # default: service name only
554-
[ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && fields='$1,$2' # ID & name
553+
local format='{{.Name}}' # default: service name only
554+
[ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && format='{{.ID}},{{.Name}}' # ID & name
555555

556556
if [ "$1" = "--id" ] ; then
557-
fields='$1' # IDs only
557+
format='{{.ID}}' # IDs only
558558
shift
559559
elif [ "$1" = "--name" ] ; then
560-
fields='$2' # names only
560+
format='{{.Name}}' # names only
561561
shift
562562
fi
563-
__docker_q service ls "$@" | awk "NR>1 {print $fields}"
563+
564+
__docker_q service ls -q --format "$format" --filter "name=$1"
564565
}
565566

566567
# __docker_complete_services applies completion of services based on the current
@@ -572,7 +573,7 @@ __docker_complete_services() {
572573
current="$2"
573574
shift 2
574575
fi
575-
COMPREPLY=( $(compgen -W "$(__docker_services "$@")" -- "$current") )
576+
COMPREPLY=( $(__docker_services "$@" "$current") )
576577
}
577578

578579
# __docker_tasks returns a list of all task IDs.

0 commit comments

Comments
 (0)