Move zsh completion logic to new subcommand: create

Signed-off-by: Steve Durrheimer <s.durrheimer@gmail.com>
master
Steve Durrheimer 2016-10-29 15:45:46 +02:00 committed by Tibor Vass
parent 2d250dcaf1
commit 6e850a9613
1 changed files with 110 additions and 40 deletions

View File

@ -507,13 +507,87 @@ __docker_container_commands() {
}
__docker_container_subcommand() {
local -a _command_args opts_help opts_attach_exec_run_start
local -a _command_args opts_help opts_attach_exec_run_start opts_create_run opts_create_run_update
local expl help="--help"
integer ret=1
opts_attach_exec_run_start=(
"($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys"
)
opts_create_run=(
"($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)--cgroup-parent=[Parent cgroup for the container]:cgroup: "
"($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)--disable-content-trust[Skip image verification]"
"($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)--isolation=[Container isolation technology]:isolation:(default hyperv process)"
"($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)--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)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: "
"($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)*--ulimit=[ulimit options]:ulimit: "
"($help)--userns=[Container user namespace]:user namespace:(host)"
"($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_create_run_update=(
"($help)--blkio-weight=[Block IO (relative weight), between 10 and 1000]:Block IO weight:(10 100 500 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-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: "
"($help)--cpu-rt-period=[Limit the CPU real-time period]:CPU real-time period in microseconds: "
"($help)--cpu-rt-runtime=[Limit the CPU real-time runtime]:CPU real-time runtime in microseconds: "
"($help)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: "
"($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: "
"($help)--kernel-memory=[Kernel memory limit in bytes]:Memory limit: "
"($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: "
"($help)--memory-reservation=[Memory soft limit]:Memory limit: "
"($help)--memory-swap=[Total memory limit with swap]:Memory limit: "
"($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)"
)
opts_help=("(: -)--help[Print usage]")
case "$words[1]" in
@ -552,7 +626,22 @@ __docker_container_subcommand() {
esac
;;
(create)
__docker_subcommand && ret=0
_arguments $(__docker_arguments) \
$opts_help \
$opts_create_run \
$opts_create_run_update \
"($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
;;
esac
;;
(diff)
__docker_subcommand && ret=0
@ -1582,12 +1671,12 @@ __docker_commands() {
}
__docker_subcommand() {
local -a _command_args opts_help opts_build_create_run opts_build_create_run_update opts_create_run opts_create_run_update
local -a _command_args opts_help opts_build_run opts_build_run_update opts_run opts_run_update opts_exec_run_start
local expl help="--help"
integer ret=1
opts_help=("(: -)--help[Print usage]")
opts_build_create_run=(
opts_build_run=(
"($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: "
"($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)"
"($help)--disable-content-trust[Skip image verification]"
@ -1595,7 +1684,7 @@ __docker_subcommand() {
"($help)*--ulimit=[ulimit options]:ulimit: "
"($help)--userns=[Container user namespace]:user namespace:(host)"
)
opts_build_create_run_update=(
opts_build_run_update=(
"($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-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: "
@ -1606,7 +1695,10 @@ __docker_subcommand() {
"($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: "
"($help)--memory-swap=[Total memory limit with swap]:Memory limit: "
)
opts_create_run=(
opts_exec_run_start=(
"($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys"
)
opts_run=(
"($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: "
@ -1660,15 +1752,12 @@ __docker_subcommand() {
"($help)*--volumes-from=[Mount volumes from the specified container]:volume: "
"($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories"
)
opts_create_run_update=(
opts_run_update=(
"($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)--memory-reservation=[Memory soft limit]:Memory limit: "
"($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)"
)
opts_attach_exec_run_start=(
"($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys"
)
case "$words[1]" in
(attach)
@ -1677,8 +1766,8 @@ __docker_subcommand() {
(build)
_arguments $(__docker_arguments) \
$opts_help \
$opts_build_create_run \
$opts_build_create_run_update \
$opts_build_run \
$opts_build_run_update \
"($help)*--build-arg[Build-time variables]:<varname>=<value>: " \
"($help)--compress[Compress the build context using gzip]" \
"($help -f --file)"{-f=,--file=}"[Name of the Dockerfile]:Dockerfile:_files" \
@ -1715,26 +1804,7 @@ __docker_subcommand() {
__docker_container_subcommand && ret=0
;;
(create)
_arguments $(__docker_arguments) \
$opts_help \
$opts_build_create_run \
$opts_build_create_run_update \
$opts_create_run \
$opts_create_run_update \
"($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
;;
esac
__docker_container_subcommand && ret=0
;;
(daemon)
_arguments $(__docker_arguments) \
@ -2093,11 +2163,11 @@ __docker_subcommand() {
(run)
_arguments $(__docker_arguments) \
$opts_help \
$opts_build_create_run \
$opts_build_create_run_update \
$opts_create_run \
$opts_create_run_update \
$opts_attach_exec_run_start \
$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: " \
@ -2172,7 +2242,7 @@ __docker_subcommand() {
(start)
_arguments $(__docker_arguments) \
$opts_help \
$opts_attach_exec_run_start \
$opts_exec_run_start \
"($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \
"($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \
"($help -)*:containers:__docker_complete_stopped_containers" && ret=0
@ -2223,8 +2293,8 @@ __docker_subcommand() {
(update)
_arguments $(__docker_arguments) \
$opts_help \
$opts_create_run_update \
$opts_build_create_run_update \
$opts_run_update \
$opts_build_run_update \
"($help -)*: :->values" && ret=0
case $state in