mirror of https://github.com/docker/cli.git
Fix bash completion for completing nodes
Signed-off-by: Harald Albers <github@albersweb.de>
This commit is contained in:
parent
4577834e8c
commit
5f791f6b6a
|
@ -361,18 +361,33 @@ __docker_complete_stacks() {
|
||||||
# An optional first option `--id|--name` may be used to limit the
|
# An optional first option `--id|--name` may be used to limit the
|
||||||
# output to the IDs or names of matching items. This setting takes
|
# output to the IDs or names of matching items. This setting takes
|
||||||
# precedence over the environment setting.
|
# precedence over the environment setting.
|
||||||
|
# Completions may be added with `--add`, e.g. `--add self`.
|
||||||
__docker_nodes() {
|
__docker_nodes() {
|
||||||
|
local add=()
|
||||||
local fields='$2' # default: node name only
|
local fields='$2' # default: node name only
|
||||||
[ "${DOCKER_COMPLETION_SHOW_NODE_IDS}" = yes ] && fields='$1,$2' # ID and name
|
[ "${DOCKER_COMPLETION_SHOW_NODE_IDS}" = yes ] && fields='$1,$2' # ID and name
|
||||||
|
|
||||||
if [ "$1" = "--id" ] ; then
|
while true ; do
|
||||||
fields='$1' # IDs only
|
case "$1" in
|
||||||
shift
|
--id)
|
||||||
elif [ "$1" = "--name" ] ; then
|
fields='$1' # IDs only
|
||||||
fields='$2' # names only
|
shift
|
||||||
shift
|
;;
|
||||||
fi
|
--name)
|
||||||
__docker_q node ls "$@" | tr -d '*' | awk "NR>1 {print $fields}"
|
fields='$2' # names only
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--add)
|
||||||
|
add+=("$2")
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $(__docker_q node ls "$@" | tr -d '*' | awk "NR>1 {print $fields}") "${add[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# __docker_complete_nodes applies completion of nodes based on the current
|
# __docker_complete_nodes applies completion of nodes based on the current
|
||||||
|
@ -388,8 +403,7 @@ __docker_complete_nodes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__docker_complete_nodes_plus_self() {
|
__docker_complete_nodes_plus_self() {
|
||||||
__docker_complete_nodes "$@"
|
__docker_complete_nodes --add self "$@"
|
||||||
COMPREPLY+=( self )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# __docker_services returns a list of all services. Additional options to
|
# __docker_services returns a list of all services. Additional options to
|
||||||
|
|
Loading…
Reference in New Issue