1
0
mirror of https://github.com/docker/cli.git synced 2026-01-18 08:21:31 +03:00

Let bash completion for docker network rm only complete custom networks

Signed-off-by: Harald Albers <github@albersweb.de>
Upstream-commit: 0c473c9e9c
Component: cli
This commit is contained in:
Harald Albers
2016-01-26 10:57:38 -08:00
committed by Tibor Vass
parent cce394556a
commit 0d0af7552d

View File

@@ -148,16 +148,20 @@ __docker_complete_containers_and_images() {
COMPREPLY+=( "${containers[@]}" )
}
# Returns the names and optionally IDs of networks.
# The selection can be narrowed by an optional filter parameter, e.g. 'type=custom'
__docker_networks() {
local filter="$1"
# By default, only network names are completed.
# Set DOCKER_COMPLETION_SHOW_NETWORK_IDS=yes to also complete network IDs.
local fields='$2'
[ "${DOCKER_COMPLETION_SHOW_NETWORK_IDS}" = yes ] && fields='$1,$2'
__docker_q network ls --no-trunc | awk "NR>1 {print $fields}"
__docker_q network ls --no-trunc ${filter:+-f "$filter"} | awk "NR>1 {print $fields}"
#__docker_q network ls --no-trunc | awk "NR>1 {print $fields}"
}
__docker_complete_networks() {
COMPREPLY=( $(compgen -W "$(__docker_networks)" -- "$cur") )
COMPREPLY=( $(compgen -W "$(__docker_networks $@)" -- "$cur") )
}
__docker_complete_network_ids() {
@@ -1357,7 +1361,7 @@ _docker_network_rm() {
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
;;
*)
__docker_complete_networks
__docker_complete_networks type=custom
esac
}