Rename containers complete function in zsh completion

Signed-off-by: Steve Durrheimer <s.durrheimer@gmail.com>
This commit is contained in:
Steve Durrheimer 2016-10-29 12:30:14 +02:00 committed by Tibor Vass
parent 308b0edef8
commit b5721467b2
1 changed files with 40 additions and 40 deletions

View File

@ -113,27 +113,27 @@ __docker_get_containers() {
return ret return ret
} }
__docker_stoppedcontainers() { __docker_complete_stopped_containers() {
[[ $PREFIX = -* ]] && return 1 [[ $PREFIX = -* ]] && return 1
__docker_get_containers stopped all "$@" __docker_get_containers stopped all "$@"
} }
__docker_runningcontainers() { __docker_complete_running_containers() {
[[ $PREFIX = -* ]] && return 1 [[ $PREFIX = -* ]] && return 1
__docker_get_containers running all "$@" __docker_get_containers running all "$@"
} }
__docker_containers() { __docker_complete_containers() {
[[ $PREFIX = -* ]] && return 1 [[ $PREFIX = -* ]] && return 1
__docker_get_containers all all "$@" __docker_get_containers all all "$@"
} }
__docker_containers_ids() { __docker_complete_containers_ids() {
[[ $PREFIX = -* ]] && return 1 [[ $PREFIX = -* ]] && return 1
__docker_get_containers all ids "$@" __docker_get_containers all ids "$@"
} }
__docker_containers_names() { __docker_complete_containers_names() {
[[ $PREFIX = -* ]] && return 1 [[ $PREFIX = -* ]] && return 1
__docker_get_containers all names "$@" __docker_get_containers all names "$@"
} }
@ -295,7 +295,7 @@ __docker_complete_pid() {
if compset -P '*:'; then if compset -P '*:'; then
case "${${words[-1]%:*}#*=}" in case "${${words[-1]%:*}#*=}" in
(container) (container)
__docker_runningcontainers && ret=0 __docker_complete_running_containers && ret=0
;; ;;
*) *)
_message 'value' && ret=0 _message 'value' && ret=0
@ -330,20 +330,20 @@ __docker_complete_ps_filters() {
__docker_images && ret=0 __docker_images && ret=0
;; ;;
(before|since) (before|since)
__docker_containers && ret=0 __docker_complete_containers && ret=0
;; ;;
(health) (health)
health_opts=('healthy' 'none' 'starting' 'unhealthy') health_opts=('healthy' 'none' 'starting' 'unhealthy')
_describe -t health-filter-opts "health filter options" health_opts && ret=0 _describe -t health-filter-opts "health filter options" health_opts && ret=0
;; ;;
(id) (id)
__docker_containers_ids && ret=0 __docker_complete_containers_ids && ret=0
;; ;;
(is-task) (is-task)
_describe -t boolean-filter-opts "filter options" boolean_opts && ret=0 _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0
;; ;;
(name) (name)
__docker_containers_names && ret=0 __docker_complete_containers_names && ret=0
;; ;;
(network) (network)
__docker_networks && ret=0 __docker_networks && ret=0
@ -428,7 +428,7 @@ __docker_complete_events_filter() {
if compset -P '*='; then if compset -P '*='; then
case "${${words[-1]%=*}#*=}" in case "${${words[-1]%=*}#*=}" in
(container) (container)
__docker_containers && ret=0 __docker_complete_containers && ret=0
;; ;;
(daemon) (daemon)
emulate -L zsh emulate -L zsh
@ -595,14 +595,14 @@ __docker_network_subcommand() {
"($help)*--link=[Add a link to another container]:link:->link" \ "($help)*--link=[Add a link to another container]:link:->link" \
"($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: " \ "($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: " \
"($help -)1:network:__docker_networks" \ "($help -)1:network:__docker_networks" \
"($help -)2:containers:__docker_containers" && ret=0 "($help -)2:containers:__docker_complete_containers" && ret=0
case $state in case $state in
(link) (link)
if compset -P "*:"; then if compset -P "*:"; then
_wanted alias expl "Alias" compadd -E "" && ret=0 _wanted alias expl "Alias" compadd -E "" && ret=0
else else
__docker_runningcontainers -qS ":" && ret=0 __docker_complete_running_containers -qS ":" && ret=0
fi fi
;; ;;
esac esac
@ -627,7 +627,7 @@ __docker_network_subcommand() {
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -)1:network:__docker_networks" \ "($help -)1:network:__docker_networks" \
"($help -)2:containers:__docker_containers" && ret=0 "($help -)2:containers:__docker_complete_containers" && ret=0
;; ;;
(inspect) (inspect)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -1521,7 +1521,7 @@ __docker_subcommand() {
$opts_attach_exec_run_start \ $opts_attach_exec_run_start \
"($help)--no-stdin[Do not attach stdin]" \ "($help)--no-stdin[Do not attach stdin]" \
"($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \ "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \
"($help -):containers:__docker_runningcontainers" && ret=0 "($help -):containers:__docker_complete_running_containers" && ret=0
;; ;;
(build) (build)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -1547,7 +1547,7 @@ __docker_subcommand() {
"($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \ "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \
"($help -m --message)"{-m=,--message=}"[Commit message]:message: " \ "($help -m --message)"{-m=,--message=}"[Commit message]:message: " \
"($help -p --pause)"{-p,--pause}"[Pause container during commit]" \ "($help -p --pause)"{-p,--pause}"[Pause container during commit]" \
"($help -):container:__docker_containers" \ "($help -):container:__docker_complete_containers" \
"($help -): :__docker_repositories_with_tags" && ret=0 "($help -): :__docker_repositories_with_tags" && ret=0
;; ;;
(cp) (cp)
@ -1561,7 +1561,7 @@ __docker_subcommand() {
if compset -P "*:"; then if compset -P "*:"; then
_files && ret=0 _files && ret=0
else else
__docker_containers -qS ":" && ret=0 __docker_complete_containers -qS ":" && ret=0
fi fi
;; ;;
esac esac
@ -1582,7 +1582,7 @@ __docker_subcommand() {
if compset -P "*:"; then if compset -P "*:"; then
_wanted alias expl "Alias" compadd -E "" && ret=0 _wanted alias expl "Alias" compadd -E "" && ret=0
else else
__docker_runningcontainers -qS ":" && ret=0 __docker_complete_running_containers -qS ":" && ret=0
fi fi
;; ;;
esac esac
@ -1680,7 +1680,7 @@ __docker_subcommand() {
(diff) (diff)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -)*:containers:__docker_containers" && ret=0 "($help -)*:containers:__docker_complete_containers" && ret=0
;; ;;
(events) (events)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -1701,7 +1701,7 @@ __docker_subcommand() {
"($help)--privileged[Give extended Linux capabilities to the command]" \ "($help)--privileged[Give extended Linux capabilities to the command]" \
"($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \ "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \
"($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" \ "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" \
"($help -):containers:__docker_runningcontainers" \ "($help -):containers:__docker_complete_running_containers" \
"($help -)*::command:->anycommand" && ret=0 "($help -)*::command:->anycommand" && ret=0
case $state in case $state in
@ -1716,7 +1716,7 @@ __docker_subcommand() {
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -o --output)"{-o=,--output=}"[Write to a file, instead of stdout]:output file:_files" \ "($help -o --output)"{-o=,--output=}"[Write to a file, instead of stdout]:output file:_files" \
"($help -)*:containers:__docker_containers" && ret=0 "($help -)*:containers:__docker_complete_containers" && ret=0
;; ;;
(history) (history)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -1768,11 +1768,11 @@ __docker_subcommand() {
case $state in case $state in
(values) (values)
if [[ ${words[(r)--type=container]} == --type=container ]]; then if [[ ${words[(r)--type=container]} == --type=container ]]; then
__docker_containers && ret=0 __docker_complete_containers && ret=0
elif [[ ${words[(r)--type=image]} == --type=image ]]; then elif [[ ${words[(r)--type=image]} == --type=image ]]; then
__docker_images && ret=0 __docker_images && ret=0
else else
__docker_images && __docker_containers && ret=0 __docker_images && __docker_complete_containers && ret=0
fi fi
;; ;;
esac esac
@ -1781,7 +1781,7 @@ __docker_subcommand() {
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -s --signal)"{-s=,--signal=}"[Signal to send]:signal:_signals" \ "($help -s --signal)"{-s=,--signal=}"[Signal to send]:signal:_signals" \
"($help -)*:containers:__docker_runningcontainers" && ret=0 "($help -)*:containers:__docker_complete_running_containers" && ret=0
;; ;;
(load) (load)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -1809,7 +1809,7 @@ __docker_subcommand() {
"($help -s --since)"{-s=,--since=}"[Show logs since this timestamp]:timestamp: " \ "($help -s --since)"{-s=,--since=}"[Show logs since this timestamp]:timestamp: " \
"($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \ "($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \
"($help)--tail=[Output the last K lines]:lines:(1 10 20 50 all)" \ "($help)--tail=[Output the last K lines]:lines:(1 10 20 50 all)" \
"($help -)*:containers:__docker_containers" && ret=0 "($help -)*:containers:__docker_complete_containers" && ret=0
;; ;;
(network) (network)
local curcontext="$curcontext" state local curcontext="$curcontext" state
@ -1848,7 +1848,7 @@ __docker_subcommand() {
(pause|unpause) (pause|unpause)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -)*:containers:__docker_runningcontainers" && ret=0 "($help -)*:containers:__docker_complete_running_containers" && ret=0
;; ;;
(plugin) (plugin)
local curcontext="$curcontext" state local curcontext="$curcontext" state
@ -1870,14 +1870,14 @@ __docker_subcommand() {
(port) (port)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -)1:containers:__docker_runningcontainers" \ "($help -)1:containers:__docker_complete_running_containers" \
"($help -)2:port:_ports" && ret=0 "($help -)2:port:_ports" && ret=0
;; ;;
(ps) (ps)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -a --all)"{-a,--all}"[Show all containers]" \ "($help -a --all)"{-a,--all}"[Show all containers]" \
"($help)--before=[Show only container created before...]:containers:__docker_containers" \ "($help)--before=[Show only container created before...]:containers:__docker_complete_containers" \
"($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \
"($help)--format=[Pretty-print containers using a Go template]:template: " \ "($help)--format=[Pretty-print containers using a Go template]:template: " \
"($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \ "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \
@ -1885,7 +1885,7 @@ __docker_subcommand() {
"($help)--no-trunc[Do not truncate output]" \ "($help)--no-trunc[Do not truncate output]" \
"($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
"($help -s --size)"{-s,--size}"[Display total file sizes]" \ "($help -s --size)"{-s,--size}"[Display total file sizes]" \
"($help)--since=[Show only containers created since...]:containers:__docker_containers" && ret=0 "($help)--since=[Show only containers created since...]:containers:__docker_complete_containers" && ret=0
;; ;;
(pull) (pull)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -1903,20 +1903,20 @@ __docker_subcommand() {
(rename) (rename)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -):old name:__docker_containers" \ "($help -):old name:__docker_complete_containers" \
"($help -):new name: " && ret=0 "($help -):new name: " && ret=0
;; ;;
(stop) (stop)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \ "($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \
"($help -)*:containers:__docker_runningcontainers" && ret=0 "($help -)*:containers:__docker_complete_running_containers" && ret=0
;; ;;
(restart) (restart)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \ "($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \
"($help -)*:containers:__docker_containers_ids" && ret=0 "($help -)*:containers:__docker_complete_containers_ids" && ret=0
;; ;;
(rm) (rm)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -1928,9 +1928,9 @@ __docker_subcommand() {
case $state in case $state in
(values) (values)
if [[ ${words[(r)-f]} == -f || ${words[(r)--force]} == --force ]]; then if [[ ${words[(r)-f]} == -f || ${words[(r)--force]} == --force ]]; then
__docker_containers && ret=0 __docker_complete_containers && ret=0
else else
__docker_stoppedcontainers && ret=0 __docker_complete_stopped_containers && ret=0
fi fi
;; ;;
esac esac
@ -1970,7 +1970,7 @@ __docker_subcommand() {
if compset -P "*:"; then if compset -P "*:"; then
_wanted alias expl "Alias" compadd -E "" && ret=0 _wanted alias expl "Alias" compadd -E "" && ret=0
else else
__docker_runningcontainers -qS ":" && ret=0 __docker_complete_running_containers -qS ":" && ret=0
fi fi
;; ;;
(storage-opt) (storage-opt)
@ -2027,7 +2027,7 @@ __docker_subcommand() {
$opts_attach_exec_run_start \ $opts_attach_exec_run_start \
"($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \ "($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \
"($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \ "($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \
"($help -)*:containers:__docker_stoppedcontainers" && ret=0 "($help -)*:containers:__docker_complete_stopped_containers" && ret=0
;; ;;
(stats) (stats)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -2035,7 +2035,7 @@ __docker_subcommand() {
"($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \ "($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \
"($help)--format=[Pretty-print images using a Go template]:template: " \ "($help)--format=[Pretty-print images using a Go template]:template: " \
"($help)--no-stream[Disable streaming stats and only pull the first result]" \ "($help)--no-stream[Disable streaming stats and only pull the first result]" \
"($help -)*:containers:__docker_runningcontainers" && ret=0 "($help -)*:containers:__docker_complete_running_containers" && ret=0
;; ;;
(swarm) (swarm)
local curcontext="$curcontext" state local curcontext="$curcontext" state
@ -2063,7 +2063,7 @@ __docker_subcommand() {
(top) (top)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -)1:containers:__docker_runningcontainers" \ "($help -)1:containers:__docker_complete_running_containers" \
"($help -)*:: :->ps-arguments" && ret=0 "($help -)*:: :->ps-arguments" && ret=0
case $state in case $state in
(ps-arguments) (ps-arguments)
@ -2082,9 +2082,9 @@ __docker_subcommand() {
case $state in case $state in
(values) (values)
if [[ ${words[(r)--kernel-memory*]} = (--kernel-memory*) ]]; then if [[ ${words[(r)--kernel-memory*]} = (--kernel-memory*) ]]; then
__docker_stoppedcontainers && ret=0 __docker_complete_stopped_containers && ret=0
else else
__docker_containers && ret=0 __docker_complete_containers && ret=0
fi fi
;; ;;
esac esac
@ -2109,7 +2109,7 @@ __docker_subcommand() {
(wait) (wait)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -)*:containers:__docker_runningcontainers" && ret=0 "($help -)*:containers:__docker_complete_running_containers" && ret=0
;; ;;
(help) (help)
_arguments $(__docker_arguments) ":subcommand:__docker_commands" && ret=0 _arguments $(__docker_arguments) ":subcommand:__docker_commands" && ret=0