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
Родитель 78d8df73b5
Коммит d7c9ae60e6
1 изменённых файлов: 19 добавлений и 4 удалений

Просмотреть файл

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