mirror of https://github.com/docker/cli.git
Improve bash completion for `docker swarm {init,join} --{advertise,listen}-addr}`
Signed-off-by: Harald Albers <github@albersweb.de>
This commit is contained in:
parent
8f0986f04b
commit
6c4812f606
|
@ -414,6 +414,20 @@ __docker_complete_resolved_hostname() {
|
||||||
COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') )
|
COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__docker_local_interfaces() {
|
||||||
|
command -v ip >/dev/null 2>&1 || return
|
||||||
|
ip addr show scope global 2>/dev/null | sed -n 's| \+inet \([0-9.]\+\).* \([^ ]\+\)|\1 \2|p'
|
||||||
|
}
|
||||||
|
|
||||||
|
__docker_complete_local_interfaces() {
|
||||||
|
local additional_interface
|
||||||
|
if [ "$1" = "--add" ] ; then
|
||||||
|
additional_interface="$2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMPREPLY=( $( compgen -W "$(__docker_local_interfaces) $additional_interface" -- "$cur" ) )
|
||||||
|
}
|
||||||
|
|
||||||
__docker_complete_capabilities() {
|
__docker_complete_capabilities() {
|
||||||
# The list of capabilities is defined in types.go, ALL was added manually.
|
# The list of capabilities is defined in types.go, ALL was added manually.
|
||||||
COMPREPLY=( $( compgen -W "
|
COMPREPLY=( $( compgen -W "
|
||||||
|
@ -1836,15 +1850,21 @@ _docker_swarm() {
|
||||||
|
|
||||||
_docker_swarm_init() {
|
_docker_swarm_init() {
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
--listen-addr)
|
|
||||||
if [[ $cur == *: ]] ; then
|
|
||||||
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
|
|
||||||
fi
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
--advertise-addr)
|
--advertise-addr)
|
||||||
if [[ $cur == *: ]] ; then
|
if [[ $cur == *: ]] ; then
|
||||||
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
|
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
|
||||||
|
else
|
||||||
|
__docker_complete_local_interfaces
|
||||||
|
__docker_nospace
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
--listen-addr)
|
||||||
|
if [[ $cur == *: ]] ; then
|
||||||
|
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
|
||||||
|
else
|
||||||
|
__docker_complete_local_interfaces --add 0.0.0.0
|
||||||
|
__docker_nospace
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
|
@ -1859,19 +1879,25 @@ _docker_swarm_init() {
|
||||||
|
|
||||||
_docker_swarm_join() {
|
_docker_swarm_join() {
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
--token)
|
--advertise-addr)
|
||||||
|
if [[ $cur == *: ]] ; then
|
||||||
|
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
|
||||||
|
else
|
||||||
|
__docker_complete_local_interfaces
|
||||||
|
__docker_nospace
|
||||||
|
fi
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--listen-addr)
|
--listen-addr)
|
||||||
if [[ $cur == *: ]] ; then
|
if [[ $cur == *: ]] ; then
|
||||||
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
|
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
|
||||||
|
else
|
||||||
|
__docker_complete_local_interfaces --add 0.0.0.0
|
||||||
|
__docker_nospace
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--advertise-addr)
|
--token)
|
||||||
if [[ $cur == *: ]] ; then
|
|
||||||
COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
|
|
||||||
fi
|
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue