1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #18465 from albers/completion-network-disconnect-2

Improve bash completion for `docker network disconnect`
This commit is contained in:
Tianon Gravi 2015-12-08 12:46:15 -08:00
commit de7b80db03

View file

@ -157,6 +157,11 @@ __docker_networks() {
COMPREPLY=( $(compgen -W "$networks" -- "$cur") )
}
__docker_containers_in_network() {
local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1")
COMPREPLY=( $(compgen -W "$containers" -- "$cur") )
}
__docker_volumes() {
COMPREPLY=( $(compgen -W "$(__docker_q volume ls -q)" -- "$cur") )
}
@ -1092,7 +1097,7 @@ _docker_network_connect() {
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag '--tail')
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_networks
elif [ $cword -eq $(($counter + 1)) ]; then
@ -1127,9 +1132,19 @@ _docker_network_create() {
}
_docker_network_disconnect() {
# TODO disconnect should only complete running containers connected
# to the specified network.
_docker_network_connect
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
;;
*)
local counter=$(__docker_pos_first_nonflag)
if [ $cword -eq $counter ]; then
__docker_networks
elif [ $cword -eq $(($counter + 1)) ]; then
__docker_containers_in_network "$prev"
fi
;;
esac
}
_docker_network_inspect() {