Updating docker completions
parent
4e730eb9a1
commit
bc38f9817f
|
|
@ -120,7 +120,7 @@ _docker_compose_build() {
|
||||||
|
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
-*)
|
-*)
|
||||||
COMPREPLY=( $( compgen -W "--build-arg --force-rm --help --no-cache --pull" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "--build-arg --force-rm --help --memory --no-cache --pull" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
__docker_compose_services_from_build
|
__docker_compose_services_from_build
|
||||||
|
|
@ -403,14 +403,14 @@ _docker_compose_run() {
|
||||||
__docker_compose_nospace
|
__docker_compose_nospace
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--entrypoint|--name|--user|-u|--volume|-v|--workdir|-w)
|
--entrypoint|--label|-l|--name|--user|-u|--volume|-v|--workdir|-w)
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
-*)
|
-*)
|
||||||
COMPREPLY=( $( compgen -W "-d --entrypoint -e --help --name --no-deps --publish -p --rm --service-ports -T --user -u --volume -v --workdir -w" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "-d --entrypoint -e --help --label -l --name --no-deps --publish -p --rm --service-ports -T --user -u --volume -v --workdir -w" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
__docker_compose_services_all
|
__docker_compose_services_all
|
||||||
|
|
|
||||||
|
|
@ -14,71 +14,160 @@
|
||||||
# . ~/.docker-machine-completion.sh
|
# . ~/.docker-machine-completion.sh
|
||||||
#
|
#
|
||||||
|
|
||||||
_docker_machine_active() {
|
# --- helper functions -------------------------------------------------------
|
||||||
if [[ "${cur}" == -* ]]; then
|
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
_docker_machine_q() {
|
||||||
|
docker-machine 2>/dev/null "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# suppresses trailing whitespace
|
||||||
|
_docker_machine_nospace() {
|
||||||
|
# compopt is not available in ancient bash versions (OSX)
|
||||||
|
# so only call it if it's available
|
||||||
|
type compopt &>/dev/null && compopt -o nospace
|
||||||
|
}
|
||||||
|
|
||||||
|
_docker_machine_machines() {
|
||||||
|
_docker_machine_q ls --format '{{.Name}}' "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_docker_machine_drivers() {
|
||||||
|
local drivers=(
|
||||||
|
amazonec2
|
||||||
|
azure
|
||||||
|
digitalocean
|
||||||
|
exoscale
|
||||||
|
generic
|
||||||
|
google
|
||||||
|
hyperv
|
||||||
|
openstack
|
||||||
|
rackspace
|
||||||
|
softlayer
|
||||||
|
virtualbox
|
||||||
|
vmwarefusion
|
||||||
|
vmwarevcloudair
|
||||||
|
vmwarevsphere
|
||||||
|
)
|
||||||
|
echo "${drivers[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_docker_machine_value_of_option() {
|
||||||
|
local pattern="$1"
|
||||||
|
for (( i=2; i < ${cword}; ++i)); do
|
||||||
|
if [[ ${words[$i]} =~ ^($pattern)$ ]] ; then
|
||||||
|
echo ${words[$i + 1]}
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Returns `key` if we are currently completing the value of a map option
|
||||||
|
# (`key=value`) which matches the glob passed in as an argument.
|
||||||
|
# This function is needed for key-specific argument completions.
|
||||||
|
_docker_machine_map_key_of_current_option() {
|
||||||
|
local glob="$1"
|
||||||
|
|
||||||
|
local key glob_pos
|
||||||
|
if [ "$cur" = "=" ] ; then # key= case
|
||||||
|
key="$prev"
|
||||||
|
glob_pos=$((cword - 2))
|
||||||
|
elif [[ $cur == *=* ]] ; then # key=value case (OSX)
|
||||||
|
key=${cur%=*}
|
||||||
|
glob_pos=$((cword - 1))
|
||||||
|
elif [ "$prev" = "=" ] ; then
|
||||||
|
key=${words[$cword - 2]} # key=value case
|
||||||
|
glob_pos=$((cword - 3))
|
||||||
else
|
else
|
||||||
COMPREPLY=()
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax
|
||||||
|
|
||||||
|
[[ ${words[$glob_pos]} == $glob ]] && echo "$key"
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- completion functions ---------------------------------------------------
|
||||||
|
|
||||||
|
_docker_machine_active() {
|
||||||
|
case "${prev}" in
|
||||||
|
--timeout|-t)
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ "${cur}" == -* ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "--help --timeout -t" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_machine_config() {
|
_docker_machine_config() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--swarm --help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help --swarm" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_machine_create() {
|
_docker_machine_create() {
|
||||||
# cheating, b/c there are approximately one zillion options to create
|
case "${prev}" in
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine create --help | grep '^ -' | sed 's/^ //; s/[^a-z0-9-].*$//')" -- "${cur}"))
|
--driver|-d)
|
||||||
|
COMPREPLY=($(compgen -W "$(_docker_machine_drivers)" -- "${cur}"))
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# driver specific options are only included in help output if --driver is given,
|
||||||
|
# so we have to pass that option when calling docker-machine to harvest options.
|
||||||
|
local driver="$(_docker_machine_value_of_option '--driver|-d')"
|
||||||
|
local parsed_options="$(_docker_machine_q create ${driver:+--driver $driver} --help | grep '^ -' | sed 's/^ //; s/[^a-z0-9-].*$//')"
|
||||||
|
if [[ ${cur} == -* ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "${parsed_options} -d --help" -- "${cur}"))
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_machine_env() {
|
_docker_machine_env() {
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
--shell)
|
--shell)
|
||||||
# What are the options for --shell?
|
COMPREPLY=($(compgen -W "cmd fish powershell tcsh" -- "${cur}"))
|
||||||
COMPREPLY=()
|
return
|
||||||
;;
|
;;
|
||||||
*)
|
|
||||||
if [[ "${cur}" == -* ]]; then
|
|
||||||
COMPREPLY=($(compgen -W "--swarm --shell --unset --no-proxy --help" -- "${cur}"))
|
|
||||||
else
|
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
|
||||||
fi
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [[ "${cur}" == -* ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "--help --no-proxy --shell --swarm --unset -u" -- "${cur}"))
|
||||||
|
else
|
||||||
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# See docker-machine-wrapper.bash for the use command
|
# See docker-machine-wrapper.bash for the use command
|
||||||
_docker_machine_use() {
|
_docker_machine_use() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--swarm --unset --help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help --swarm --unset" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_machine_inspect() {
|
_docker_machine_inspect() {
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
-f|--format)
|
--format|-f)
|
||||||
COMPREPLY=()
|
return
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [[ "${cur}" == -* ]]; then
|
|
||||||
COMPREPLY=($(compgen -W "--format --help" -- "${cur}"))
|
|
||||||
else
|
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [[ "${cur}" == -* ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "--format -f --help" -- "${cur}"))
|
||||||
|
else
|
||||||
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_machine_ip() {
|
_docker_machine_ip() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,26 +175,52 @@ _docker_machine_kill() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_machine_ls() {
|
_docker_machine_ls() {
|
||||||
case "${prev}" in
|
local key=$(_docker_machine_map_key_of_current_option '--filter')
|
||||||
--filter)
|
case "$key" in
|
||||||
COMPREPLY=()
|
driver)
|
||||||
|
COMPREPLY=($(compgen -W "$(_docker_machine_drivers)" -- "${cur##*=}"))
|
||||||
|
return
|
||||||
;;
|
;;
|
||||||
*)
|
state)
|
||||||
COMPREPLY=($(compgen -W "--quiet --filter --format --timeout --help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "Error Paused Running Saved Starting Stopped Stopping" -- "${cur##*=}"))
|
||||||
|
return
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
case "${prev}" in
|
||||||
|
--filter)
|
||||||
|
COMPREPLY=($(compgen -W "driver label name state swarm" -S= -- "${cur}"))
|
||||||
|
_docker_machine_nospace
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
--format|-f|--timeout|-t)
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ "${cur}" == -* ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "--filter --format -f --help --quiet -q --timeout -t" -- "${cur}"))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_docker_machine_provision() {
|
||||||
|
if [[ "${cur}" == -* ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
|
else
|
||||||
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -- "${cur}"))
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_machine_regenerate_certs() {
|
_docker_machine_regenerate_certs() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help --force" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--force -f --help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,16 +228,15 @@ _docker_machine_restart() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_machine_rm() {
|
_docker_machine_rm() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help --force -y" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--force -f --help -y" -- "${cur}"))
|
||||||
else
|
else
|
||||||
# For rm, it's best to be explicit
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
COMPREPLY=()
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,18 +244,18 @@ _docker_machine_ssh() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_docker_machine_scp() {
|
_docker_machine_scp() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help --recursive" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--delta -d --help --recursive -r" -- "${cur}"))
|
||||||
else
|
else
|
||||||
_filedir
|
_filedir
|
||||||
# It would be really nice to ssh to the machine and ls to complete
|
# It would be really nice to ssh to the machine and ls to complete
|
||||||
# remote files.
|
# remote files.
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q | sed 's/$/:/')" -- "${cur}") "${COMPREPLY[@]}")
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines | sed 's/$/:/')" -- "${cur}") "${COMPREPLY[@]}")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +263,7 @@ _docker_machine_start() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Stopped)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,7 +271,7 @@ _docker_machine_status() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,7 +279,7 @@ _docker_machine_stop() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines --filter state=Running)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,7 +287,7 @@ _docker_machine_upgrade() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,7 +295,7 @@ _docker_machine_url() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,7 +303,7 @@ _docker_machine_version() {
|
||||||
if [[ "${cur}" == -* ]]; then
|
if [[ "${cur}" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}"))
|
COMPREPLY=($(compgen -W "$(_docker_machine_machines)" -- "${cur}"))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -215,7 +329,7 @@ _docker_machine_docker_machine() {
|
||||||
|
|
||||||
_docker_machine() {
|
_docker_machine() {
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
local commands=(active config create env inspect ip kill ls regenerate-certs restart rm ssh scp start status stop upgrade url version help)
|
local commands=(active config create env inspect ip kill ls provision regenerate-certs restart rm ssh scp start status stop upgrade url version help)
|
||||||
|
|
||||||
local flags=(--debug --native-ssh --github-api-token --bugsnag-api-token --help --version)
|
local flags=(--debug --native-ssh --github-api-token --bugsnag-api-token --help --version)
|
||||||
local wants_dir=(--storage-path)
|
local wants_dir=(--storage-path)
|
||||||
|
|
@ -249,4 +363,4 @@ _docker_machine() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
complete -F _docker_machine docker-machine
|
complete -F _docker_machine docker-machine docker-machine.exe
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue