Matching autocomplete for Docker v0.9.1

Many deprecations since 0.8 and new commands.
This commit is contained in:
Bob Maerten 2014-03-26 10:40:46 +01:00
parent ffc17b6b4d
commit 76e1edf31f

View File

@ -2,7 +2,8 @@
# Docker autocompletion for oh-my-zsh # Docker autocompletion for oh-my-zsh
# Requires: Docker installed # Requires: Docker installed
# Author : Azaan (@aeonazaan) # Author: Azaan (@aeonazaan)
# Updates: Bob Maerten (@bobmaerten) for Docker v0.9+
# ----- Helper functions # ----- Helper functions
@ -24,21 +25,30 @@ __docker_images() {
# Seperate function for each command, makes extension easier later # Seperate function for each command, makes extension easier later
# --------------------------- # ---------------------------
__attach() { __attach() {
_arguments \
'--no-stdin[Do not attach stdin]' \
'--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]'
__docker_containers __docker_containers
} }
__build() { __build() {
_arguments \ _arguments \
'-q=false[Suppress verbose build output]' \ '--no-cache[Do not use cache when building the image]' \
'-t="[fuck to be applied to the resulting image in case of success]' \ '(-q,--quiet)'{-q,--quiet}'[Suppress the verbose output generated by the containers]' \
'--rm[Remove intermediate containers after a successful build]' \
'(-t,--tag=)'{-t,--tag=}'[Repository name (and optionally a tag) to be applied to the resulting image in case of success]' \
'*:files:_files' '*:files:_files'
} }
__commit() { __commit() {
_arguments \ _arguments \
'-author="[Author]' \ '(-a,--author=)'{-a,--author=}'[Author (eg. "John Hannibal Smith <hannibal@a-team.com>"]' \
'-m="[Commit message]' \ '(-m,--message=)'{-m,--message=}'[Commit message]' \
'-run="[Config automatically applied when the image is run.\n]' '--run=[Config automatically applied when the image is run.]'
__docker_containers
}
__cp() {
__docker_containers __docker_containers
} }
@ -46,21 +56,29 @@ __diff() {
__docker_containers __docker_containers
} }
__events() {
_arguments \
'--since=[Show previously created events and then stream.]'
}
__export() { __export() {
__docker_containers __docker_containers
} }
__history() { __history() {
_arguments \
'--no-trunc=[Don''t truncate output]' \
'(-q,--quiet)'{-q,--quiet}'[Only show numeric IDs]'
__docker_images __docker_images
} }
__images() { __images() {
_arguments \ _arguments \
'-a[show all images]' \ '(-a,--all)'{-a,--all}'[Show all images (by default filter out the intermediate images used to build)]' \
'-notrunc[dont truncate output]' \ '--no-trunc[Don''t truncate output]' \
'-q[only show numeric IDs]' \ '(-q,--quiet=)'{-q,--quiet=}'[Only show numeric IDs]' \
'-viz[output graph in graphviz format]' '(-t,--tree=)'{-t,--tree=}'[Output graph in tree format]' \
'(-v,--viz=)'{-v,--viz=}'[Output graph in graphviz format]'
__docker_images __docker_images
} }
@ -86,14 +104,20 @@ __kill() {
__docker_containers __docker_containers
} }
__load() {
_arguments '*:files:_files'
}
__login() { __login() {
_arguments \ _arguments \
'-e="[email]' \ '(-e,--email=)'{-e,-email=}'[Email]' \
'-p="[password]' \ '(-p,--password=)'{-p,-password=}'[Password]' \
'-u="[username]' \ '(-u,--username=)'{-u,-username=}'[Username]'
} }
__logs() { __logs() {
_arguments \
'(-f,--follow)'{-f,-follow}'[Follow log output]'
__docker_containers __docker_containers
} }
@ -107,77 +131,107 @@ __top() {
__ps() { __ps() {
_arguments \ _arguments \
'-a[Show all containers. Only running containers are shown by default.]' \ '(-a,--all)'{-a,--all}'[Show all containers. Only running containers are shown by default.]' \
'-beforeId="[Show only container created before Id, include non-running ones.]' \ '--before-id=[Show only container created before Id, include non-running ones.]' \
'-l[Show only the latest created container, include non-running ones.]' \ '(-l,--latest)'{-l,--latest}'[Show only the latest created container, include non-running ones.]' \
'-n=[Show n last created containers, include non-running ones.]' \ '-n=[Show n last created containers, include non-running ones. default=-1.]' \
'-notrunc[Dont truncate output]' \ '--no-trunc[Don''t truncate output]' \
'-q[Only display numeric IDs]' \ '(-q,--quiet)'{-q,--quiet}'[Only display numeric IDs]' \
'-s[Display sizes]' \ '(-s,--size)'{-s,--size}'[Display sizes]' \
'-sinceId="[Show only containers created since Id, include non-running ones.]' '--since-id=[Show only containers created since Id, include non-running ones.]'
} }
__pull() { __pull() {
_arguments '-t="[Download tagged image in repository]' _arguments \
'(-t,--tag=)'{-t,--tag=}'[Download tagged image in repository]'
} }
__push() { __push() {
# no arguments
} }
__restart() { __restart() {
_arguments '-t=[number of seconds to try to stop before killing]' _arguments \
'(-t,--time=)'{-t,--time=}'[Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10]'
__docker_containers __docker_containers
} }
__rm() { __rm() {
_arguments '-v[Remove the volumes associated to the container]' _arguments \
'(-f,--force=)'{-f,--force=}'[Force removal of running container]' \
'(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \
'(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]'
__docker_containers __docker_containers
} }
__rmi() { __rmi() {
_arguments \
'(-f,--force=)'{-f,--force=}'[Force]' \
__docker_images __docker_images
} }
__run() { __run() {
_arguments \ _arguments \
'-a=[Attach to stdin, stdout or stderr.]' \ '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \
'-c=[CPU shares (relative weight)]' \ '(-a,--attach=)'{-a,--attach=}'[Attach to stdin, stdout or stderr.]' \
'-d[Detached mode: leave the container running in the background]' \ '(-c,--cpu-shares=)'{-c,--cpu-shares=}': CPU shares (relative weight)]' \
'-dns=[Set custom dns servers]' \ '--cidfile=[Write the container ID to the file]' \
'-e=[Set environment variables]' \ '(-d,--detach=)'{-d,--detach=}'[Detached mode: Run container in the background, print new container id]' \
'-entrypoint="[Overwrite the default entrypoint of the image]' \ '--dns=[Set custom dns servers]' \
'-h="[Container host name]' \ '(-e,--env=)'{-e,--env=}'[Set environment variables]' \
'-i[Keep stdin open even if not attached]' \ '--entrypoint=[Overwrite the default entrypoint of the image]' \
'-m=[Memory limit (in bytes)]' \ '--expose=[Expose a port from the container without publishing it to your host]' \
'-p=[Expose a containers port to the host (use docker port to see the actual mapping)]' \ '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \
'-t[Allocate a pseudo-tty]' \ '(-i,--interactive=)'{-i,--interactive=}'[Keep stdin open even if not attached]' \
'-u="[Username or UID]' \ '--link=[Add link to another container (name:alias)]' \
'-v=[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \ '--lxc-conf=[Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"]' \
'-volumes-from="[Mount volumes from the specified container]' '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \
'(-n,--networking=)'{-n,--networking=}'[Enable networking for this container]' \
'--name=[Assign a name to the container]' \
'(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) (use "docker port" to see the actual mapping)]' \
'--privileged=[Give extended privileges to this container]' \
'--rm=[Automatically remove the container when it exits (incompatible with -d)]' \
'--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \
'(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \
'(-u,--user=)'{-u,--user=}'[Username or UID]' \
'(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \
'--volumes-from=[Mount volumes from the specified container(s)]' \
'(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]'
__docker_images __docker_images
} }
__search() { __search() {
_arguments '-notrunc[Dont truncate output]' _arguments \
'--no-trunc=[Don''t truncate output]' \
'-s,--stars=)'{-s,--stars=}'[Only displays with at least xxx stars]' \
'-t,--trusted=)'{-t,--trusted=}'[Only show trusted builds]'
}
__save() {
__docker_images
} }
__start() { __start() {
_arguments \
'(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \
'(-i,--interactive=)'{-i, --interactive=}'[Attach container''s stdin]'
__docker_containers __docker_containers
} }
__stop() { __stop() {
_arguments '-t=[number of seconds to try to stop before killing]' _arguments \
'(-t,--time=)'{-t,--time=}'[Number of seconds to wait for the container to stop before killing it.]'
__docker_containers __docker_containers
} }
__tag() { __tag() {
_arguments '-f[Force]' _arguments \
'(-f,--force=)'{-f,--force=}'[Force]'
__docker_images __docker_images
} }
__version() { __version() {
# no arguments
} }
__wait() { __wait() {
@ -192,7 +246,9 @@ _1st_arguments=(
"attach":"Attach to a running container" "attach":"Attach to a running container"
"build":"Build a container from a Dockerfile" "build":"Build a container from a Dockerfile"
"commit":"Create a new image from a container's changes" "commit":"Create a new image from a container's changes"
"cp":"Copy files/folders from the containers filesystem to the host path"
"diff":"Inspect changes on a container's filesystem" "diff":"Inspect changes on a container's filesystem"
"events":"Get real time events from the server"
"export":"Stream the contents of a container as a tar archive" "export":"Stream the contents of a container as a tar archive"
"history":"Show the history of an image" "history":"Show the history of an image"
"images":"List images" "images":"List images"
@ -201,10 +257,10 @@ _1st_arguments=(
"insert":"Insert a file in an image" "insert":"Insert a file in an image"
"inspect":"Return low-level information on a container" "inspect":"Return low-level information on a container"
"kill":"Kill a running container" "kill":"Kill a running container"
"load":"Load an image from a tar archive"
"login":"Register or Login to the docker registry server" "login":"Register or Login to the docker registry server"
"logs":"Fetch the logs of a container" "logs":"Fetch the logs of a container"
"port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT" "port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"
"top":"Lookup the running processes of a container"
"ps":"List containers" "ps":"List containers"
"pull":"Pull an image or a repository from the docker registry server" "pull":"Pull an image or a repository from the docker registry server"
"push":"Push an image or a repository to the docker registry server" "push":"Push an image or a repository to the docker registry server"
@ -212,10 +268,12 @@ _1st_arguments=(
"rm":"Remove one or more containers" "rm":"Remove one or more containers"
"rmi":"Remove one or more images" "rmi":"Remove one or more images"
"run":"Run a command in a new container" "run":"Run a command in a new container"
"save":"Save an image to a tar archive"
"search":"Search for an image in the docker index" "search":"Search for an image in the docker index"
"start":"Start a stopped container" "start":"Start a stopped container"
"stop":"Stop a running container" "stop":"Stop a running container"
"tag":"Tag an image into a repository" "tag":"Tag an image into a repository"
"top":"Lookup the running processes of a container"
"version":"Show the docker version information" "version":"Show the docker version information"
"wait":"Block until a container stops, then print its exit code" "wait":"Block until a container stops, then print its exit code"
) )
@ -230,13 +288,17 @@ fi
local -a _command_args local -a _command_args
case "$words[1]" in case "$words[1]" in
attach) attach)
__docker_containers ;; __attach ;;
build) build)
__build ;; __build ;;
commit) commit)
__commit ;; __commit ;;
cp)
__cp ;;
diff) diff)
__diff ;; __diff ;;
events)
__events ;;
export) export)
__export ;; __export ;;
history) history)
@ -253,14 +315,14 @@ case "$words[1]" in
__inspect ;; __inspect ;;
kill) kill)
__kill ;; __kill ;;
load)
__load ;;
login) login)
__login ;; __login ;;
logs) logs)
__logs ;; __logs ;;
port) port)
__port ;; __port ;;
top)
__top ;;
ps) ps)
__ps ;; __ps ;;
pull) pull)
@ -275,6 +337,8 @@ case "$words[1]" in
__rmi ;; __rmi ;;
run) run)
__run ;; __run ;;
save)
__save ;;
search) search)
__search ;; __search ;;
start) start)
@ -283,6 +347,8 @@ case "$words[1]" in
__stop ;; __stop ;;
tag) tag)
__tag ;; __tag ;;
top)
__top ;;
version) version)
__version ;; __version ;;
wait) wait)