Move zsh completion logic to new subcommand: run

Signed-off-by: Steve Durrheimer <s.durrheimer@gmail.com>
This commit is contained in:
Steve Durrheimer 2016-10-30 18:29:03 +01:00 committed by Tibor Vass
parent 4149666da1
commit 15a2f1f74f
1 changed files with 49 additions and 105 deletions

View File

@ -548,6 +548,7 @@ __docker_container_subcommand() {
"($help)--log-driver=[Default driver for container logs]:logging driver:__docker_log_drivers" "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_log_drivers"
"($help)*--log-opt=[Log driver specific options]:log driver options:__docker_log_options" "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_log_options"
"($help)--mac-address=[Container MAC address]:MAC address: " "($help)--mac-address=[Container MAC address]:MAC address: "
"($help)*--mount=[Attach a filesystem mount to the container]:mount: "
"($help)--name=[Container name]:name: " "($help)--name=[Container name]:name: "
"($help)--network=[Connect a container to a network]:network mode:(bridge none container host)" "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)"
"($help)*--network-alias=[Add network-scoped alias for the container]:alias: " "($help)*--network-alias=[Add network-scoped alias for the container]:alias: "
@ -757,7 +758,43 @@ __docker_container_subcommand() {
esac esac
;; ;;
(run) (run)
__docker_subcommand && ret=0 local state
_arguments $(__docker_arguments) \
$opts_help \
$opts_create_run \
$opts_create_run_update \
$opts_attach_exec_run_start \
"($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \
"($help)--health-cmd=[Command to run to check health]:command: " \
"($help)--health-interval=[Time between running the check]:time: " \
"($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)" \
"($help)--health-timeout=[Maximum time to allow one check to run]:time: " \
"($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]" \
"($help)--rm[Remove intermediate containers when it exits]" \
"($help)--runtime=[Name of the runtime to be used for that container]:runtime:__docker_complete_runtimes" \
"($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \
"($help)--stop-signal=[Signal to kill a container]:signal:_signals" \
"($help)--storage-opt=[Storage driver options for the container]:storage options:->storage-opt" \
"($help -): :__docker_images" \
"($help -):command: _command_names -e" \
"($help -)*::arguments: _normal" && ret=0
case $state in
(link)
if compset -P "*:"; then
_wanted alias expl "Alias" compadd -E "" && ret=0
else
__docker_complete_running_containers -qS ":" && ret=0
fi
;;
(storage-opt)
if compset -P "*="; then
_message "value" && ret=0
else
opts=('size')
_describe -t filter-opts "storage options" opts -qS "=" && ret=0
fi
;;
esac
;; ;;
(start) (start)
__docker_subcommand && ret=0 __docker_subcommand && ret=0
@ -1741,12 +1778,12 @@ __docker_commands() {
} }
__docker_subcommand() { __docker_subcommand() {
local -a _command_args opts_help opts_build_run opts_build_run_update opts_run opts_run_update opts_run_start local -a _command_args opts_help opts_build opts_build_update opts_update
local expl help="--help" local expl help="--help"
integer ret=1 integer ret=1
opts_help=("(: -)--help[Print usage]") opts_help=("(: -)--help[Print usage]")
opts_build_run=( opts_build=(
"($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: " "($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: "
"($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)" "($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)"
"($help)--disable-content-trust[Skip image verification]" "($help)--disable-content-trust[Skip image verification]"
@ -1754,7 +1791,7 @@ __docker_subcommand() {
"($help)*--ulimit=[ulimit options]:ulimit: " "($help)*--ulimit=[ulimit options]:ulimit: "
"($help)--userns=[Container user namespace]:user namespace:(host)" "($help)--userns=[Container user namespace]:user namespace:(host)"
) )
opts_build_run_update=( opts_build_update=(
"($help -c --cpu-shares)"{-c=,--cpu-shares=}"[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)" "($help -c --cpu-shares)"{-c=,--cpu-shares=}"[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)"
"($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: " "($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: "
"($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: " "($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: "
@ -1765,64 +1802,10 @@ __docker_subcommand() {
"($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: " "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: "
"($help)--memory-swap=[Total memory limit with swap]:Memory limit: " "($help)--memory-swap=[Total memory limit with swap]:Memory limit: "
) )
opts_run_start=( opts_start=(
"($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys" "($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys"
) )
opts_run=( opts_update=(
"($help -a --attach)"{-a=,--attach=}"[Attach to stdin, stdout or stderr]:device:(STDIN STDOUT STDERR)"
"($help)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: "
"($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: "
"($help)*--cap-add=[Add Linux capabilities]:capability: "
"($help)*--cap-drop=[Drop Linux capabilities]:capability: "
"($help)--cidfile=[Write the container ID to the file]:CID file:_files"
"($help)*--device=[Add a host device to the container]:device:_files"
"($help)*--device-read-bps=[Limit the read rate (bytes per second) from a device]:device:IO rate: "
"($help)*--device-read-iops=[Limit the read rate (IO per second) from a device]:device:IO rate: "
"($help)*--device-write-bps=[Limit the write rate (bytes per second) to a device]:device:IO rate: "
"($help)*--device-write-iops=[Limit the write rate (IO per second) to a device]:device:IO rate: "
"($help)*--dns=[Custom DNS servers]:DNS server: "
"($help)*--dns-opt=[Custom DNS options]:DNS option: "
"($help)*--dns-search=[Custom DNS search domains]:DNS domains: "
"($help)*"{-e=,--env=}"[Environment variables]:environment variable: "
"($help)--entrypoint=[Overwrite the default entrypoint of the image]:entry point: "
"($help)*--env-file=[Read environment variables from a file]:environment file:_files"
"($help)*--expose=[Expose a port from the container without publishing it]: "
"($help)*--group=[Set one or more supplementary user groups for the container]:group:_groups"
"($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts"
"($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]"
"($help)--ip=[Container IPv4 address]:IPv4: "
"($help)--ip6=[Container IPv6 address]:IPv6: "
"($help)--ipc=[IPC namespace to use]:IPC namespace: "
"($help)*--link=[Add link to another container]:link:->link"
"($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: "
"($help)*"{-l=,--label=}"[Container metadata]:label: "
"($help)--log-driver=[Default driver for container logs]:logging driver:__docker_log_drivers"
"($help)*--log-opt=[Log driver specific options]:log driver options:__docker_log_options"
"($help)--mac-address=[Container MAC address]:MAC address: "
"($help)*--mount=[Attach a filesystem mount to the container]:mount: "
"($help)--name=[Container name]:name: "
"($help)--network=[Connect a container to a network]:network mode:(bridge none container host)"
"($help)*--network-alias=[Add network-scoped alias for the container]:alias: "
"($help)--oom-kill-disable[Disable OOM Killer]"
"($help)--oom-score-adj[Tune the host's OOM preferences for containers (accepts -1000 to 1000)]"
"($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]"
"($help -P --publish-all)"{-P,--publish-all}"[Publish all exposed ports]"
"($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports"
"($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid"
"($help)--privileged[Give extended privileges to this container]"
"($help)--read-only[Mount the container's root filesystem as read only]"
"($help)*--security-opt=[Security options]:security option: "
"($help)--stop-timeout=[Timeout (in seconds) to stop a container]:time: "
"($help)*--sysctl=-[sysctl options]:sysctl: "
"($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]"
"($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users"
"($help)--tmpfs[mount tmpfs]"
"($help)*-v[Bind mount a volume]:volume: "
"($help)--volume-driver=[Optional volume driver for the container]:volume driver:(local)"
"($help)*--volumes-from=[Mount volumes from the specified container]:volume: "
"($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories"
)
opts_run_update=(
"($help)--blkio-weight=[Block IO (relative weight), between 10 and 1000]:Block IO weight:(10 100 500 1000)" "($help)--blkio-weight=[Block IO (relative weight), between 10 and 1000]:Block IO weight:(10 100 500 1000)"
"($help)--kernel-memory=[Kernel memory limit in bytes]:Memory limit: " "($help)--kernel-memory=[Kernel memory limit in bytes]:Memory limit: "
"($help)--memory-reservation=[Memory soft limit]:Memory limit: " "($help)--memory-reservation=[Memory soft limit]:Memory limit: "
@ -1836,8 +1819,8 @@ __docker_subcommand() {
(build) (build)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
$opts_build_run \ $opts_build \
$opts_build_run_update \ $opts_build_update \
"($help)*--build-arg[Build-time variables]:<varname>=<value>: " \ "($help)*--build-arg[Build-time variables]:<varname>=<value>: " \
"($help)--compress[Compress the build context using gzip]" \ "($help)--compress[Compress the build context using gzip]" \
"($help -f --file)"{-f=,--file=}"[Name of the Dockerfile]:Dockerfile:_files" \ "($help -f --file)"{-f=,--file=}"[Name of the Dockerfile]:Dockerfile:_files" \
@ -2162,46 +2145,7 @@ __docker_subcommand() {
"($help -)*: :__docker_images" && ret=0 "($help -)*: :__docker_images" && ret=0
;; ;;
(run) (run)
_arguments $(__docker_arguments) \ __docker_container_subcommand && ret=0
$opts_help \
$opts_build_run \
$opts_build_run_update \
$opts_run \
$opts_run_update \
$opts_exec_run_start \
"($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \
"($help)--health-cmd=[Command to run to check health]:command: " \
"($help)--health-interval=[Time between running the check]:time: " \
"($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)" \
"($help)--health-timeout=[Maximum time to allow one check to run]:time: " \
"($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]" \
"($help)--rm[Remove intermediate containers when it exits]" \
"($help)--runtime=[Name of the runtime to be used for that container]:runtime:__docker_complete_runtimes" \
"($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \
"($help)--stop-signal=[Signal to kill a container]:signal:_signals" \
"($help)--storage-opt=[Storage driver options for the container]:storage options:->storage-opt" \
"($help -): :__docker_images" \
"($help -):command: _command_names -e" \
"($help -)*::arguments: _normal" && ret=0
case $state in
(link)
if compset -P "*:"; then
_wanted alias expl "Alias" compadd -E "" && ret=0
else
__docker_complete_running_containers -qS ":" && ret=0
fi
;;
(storage-opt)
if compset -P "*="; then
_message "value" && ret=0
else
opts=('size')
_describe -t filter-opts "storage options" opts -qS "=" && ret=0
fi
;;
esac
;; ;;
(save) (save)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -2243,7 +2187,7 @@ __docker_subcommand() {
(start) (start)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
$opts_run_start \ $opts_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_complete_stopped_containers" && ret=0 "($help -)*:containers:__docker_complete_stopped_containers" && ret=0
@ -2294,8 +2238,8 @@ __docker_subcommand() {
(update) (update)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
$opts_run_update \ $opts_update \
$opts_build_run_update \ $opts_build_update \
"($help -)*: :->values" && ret=0 "($help -)*: :->values" && ret=0
case $state in case $state in