Improve bash completion for `docker network disconnect`

Signed-off-by: Harald Albers <github@albersweb.de>
This commit is contained in:
Harald Albers 2015-11-15 13:31:13 -08:00 committed by Tibor Vass
parent 7071c15b5f
commit b4a012656c
1 changed files with 19 additions and 4 deletions

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() {