1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-13 17:30:08 +00:00

Update docker completion from upstream (#5426)

be9e3f59e6/contrib/completion/zsh/_docker
This commit is contained in:
Zach Himsel 2016-09-20 10:40:54 -06:00 committed by Marc Cornellà
parent 9d91e92f26
commit f39dcfda8d

View file

@ -138,7 +138,7 @@ __docker_containers_names() {
__docker_get_containers all names "$@" __docker_get_containers all names "$@"
} }
__docker_plugins() { __docker_complete_info_plugins() {
[[ $PREFIX = -* ]] && return 1 [[ $PREFIX = -* ]] && return 1
integer ret=1 integer ret=1
emulate -L zsh emulate -L zsh
@ -228,7 +228,7 @@ __docker_get_log_options() {
journald_options=("env" "labels" "tag") journald_options=("env" "labels" "tag")
json_file_options=("env" "labels" "max-file" "max-size") json_file_options=("env" "labels" "max-file" "max-size")
syslog_options=("env" "labels" "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag") syslog_options=("env" "labels" "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag")
splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "tag") splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-gzip" "splunk-gzip-level" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag")
[[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0 [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0
[[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0 [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0
@ -340,7 +340,7 @@ __docker_complete_ps_filters() {
__docker_networks && ret=0 __docker_networks && ret=0
;; ;;
(status) (status)
status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running') status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running' 'removing')
_describe -t status-filter-opts "Status Filter Options" status_opts && ret=0 _describe -t status-filter-opts "Status Filter Options" status_opts && ret=0
;; ;;
(volume) (volume)
@ -434,7 +434,7 @@ __docker_complete_events_filter() {
(event) (event)
local -a event_opts local -a event_opts
event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach' event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach'
'exec_start' 'export' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' 'exec_start' 'export' 'health_status' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start'
'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update') 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update')
_describe -t event-filter-opts "event filter options" event_opts && ret=0 _describe -t event-filter-opts "event filter options" event_opts && ret=0
;; ;;
@ -463,6 +463,8 @@ __docker_complete_events_filter() {
return ret return ret
} }
# BO network
__docker_network_complete_ls_filters() { __docker_network_complete_ls_filters() {
[[ $PREFIX = -* ]] && return 1 [[ $PREFIX = -* ]] && return 1
integer ret=1 integer ret=1
@ -470,7 +472,7 @@ __docker_network_complete_ls_filters() {
if compset -P '*='; then if compset -P '*='; then
case "${${words[-1]%=*}#*=}" in case "${${words[-1]%=*}#*=}" in
(driver) (driver)
__docker_plugins Network && ret=0 __docker_complete_info_plugins Network && ret=0
;; ;;
(id) (id)
__docker_networks_ids && ret=0 __docker_networks_ids && ret=0
@ -629,6 +631,7 @@ __docker_network_subcommand() {
$opts_help \ $opts_help \
"($help)--no-trunc[Do not truncate the output]" \ "($help)--no-trunc[Do not truncate the output]" \
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
"($help)--format=[Pretty-print networks using a Go template]:template: " \
"($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0 "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0
case $state in case $state in
(filter-options) (filter-options)
@ -649,6 +652,8 @@ __docker_network_subcommand() {
return ret return ret
} }
# EO network
# BO node # BO node
__docker_node_complete_ls_filters() { __docker_node_complete_ls_filters() {
@ -716,7 +721,6 @@ __docker_nodes() {
[[ $filter != "none" ]] && args=("-f $filter") [[ $filter != "none" ]] && args=("-f $filter")
lines=(${(f)"$(_call_program commands docker $docker_options node ls $args)"}) lines=(${(f)"$(_call_program commands docker $docker_options node ls $args)"})
# Parse header line to find columns # Parse header line to find columns
local i=1 j=1 k header=${lines[1]} local i=1 j=1 k header=${lines[1]}
declare -A begin end declare -A begin end
@ -788,7 +792,7 @@ __docker_node_commands() {
"ls:List nodes in the swarm" "ls:List nodes in the swarm"
"promote:Promote a node as manager in the swarm" "promote:Promote a node as manager in the swarm"
"rm:Remove one or more nodes from the swarm" "rm:Remove one or more nodes from the swarm"
"ps:List tasks running on a node" "ps:List tasks running on a node, defaults to current node"
"update:Update a node" "update:Update a node"
) )
_describe -t docker-node-commands "docker node command" _docker_node_subcommands _describe -t docker-node-commands "docker node command" _docker_node_subcommands
@ -842,6 +846,7 @@ __docker_node_subcommand() {
"($help -a --all)"{-a,--all}"[Display all instances]" \ "($help -a --all)"{-a,--all}"[Display all instances]" \
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
"($help)--no-resolve[Do not map IDs to Names]" \ "($help)--no-resolve[Do not map IDs to Names]" \
"($help)--no-trunc[Do not truncate output]" \
"($help -)1:node:__docker_complete_nodes" && ret=0 "($help -)1:node:__docker_complete_nodes" && ret=0
case $state in case $state in
(filter-options) (filter-options)
@ -1078,6 +1083,7 @@ __docker_service_subcommand() {
"($help)*--constraint=[Placement constraints]:constraint: " "($help)*--constraint=[Placement constraints]:constraint: "
"($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)" "($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)"
"($help)*"{-e=,--env=}"[Set environment variables]:env: " "($help)*"{-e=,--env=}"[Set environment variables]:env: "
"($help)*--group-add=[Add additional user groups to the container]:group:_groups"
"($help)*--label=[Service labels]:label: " "($help)*--label=[Service labels]:label: "
"($help)--limit-cpu=[Limit CPUs]:value: " "($help)--limit-cpu=[Limit CPUs]:value: "
"($help)--limit-memory=[Limit Memory]:value: " "($help)--limit-memory=[Limit Memory]:value: "
@ -1157,6 +1163,7 @@ __docker_service_subcommand() {
"($help -a --all)"{-a,--all}"[Display all tasks]" \ "($help -a --all)"{-a,--all}"[Display all tasks]" \
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
"($help)--no-resolve[Do not map IDs to Names]" \ "($help)--no-resolve[Do not map IDs to Names]" \
"($help)--no-trunc[Do not truncate output]" \
"($help -)1:service:__docker_complete_services" && ret=0 "($help -)1:service:__docker_complete_services" && ret=0
case $state in case $state in
(filter-options) (filter-options)
@ -1171,6 +1178,7 @@ __docker_service_subcommand() {
"($help)--arg=[Service command args]:arguments: _normal" \ "($help)--arg=[Service command args]:arguments: _normal" \
"($help)*--container-label-add=[Add or update container labels]:label: " \ "($help)*--container-label-add=[Add or update container labels]:label: " \
"($help)*--container-label-rm=[Remove a container label by its key]:label: " \ "($help)*--container-label-rm=[Remove a container label by its key]:label: " \
"($help)*--group-rm=[Remove previously added user groups from the container]:group:_groups" \
"($help)--image=[Service image tag]:image:__docker_repositories" \ "($help)--image=[Service image tag]:image:__docker_repositories" \
"($help -)1:service:__docker_complete_services" && ret=0 "($help -)1:service:__docker_complete_services" && ret=0
;; ;;
@ -1250,6 +1258,8 @@ __docker_swarm_subcommand() {
# EO swarm # EO swarm
# BO volume
__docker_volume_complete_ls_filters() { __docker_volume_complete_ls_filters() {
[[ $PREFIX = -* ]] && return 1 [[ $PREFIX = -* ]] && return 1
integer ret=1 integer ret=1
@ -1261,7 +1271,7 @@ __docker_volume_complete_ls_filters() {
_describe -t dangling-filter-opts "Dangling Filter Options" dangling_opts && ret=0 _describe -t dangling-filter-opts "Dangling Filter Options" dangling_opts && ret=0
;; ;;
(driver) (driver)
__docker_plugins Volume && ret=0 __docker_complete_info_plugins Volume && ret=0
;; ;;
(name) (name)
__docker_volumes && ret=0 __docker_volumes && ret=0
@ -1271,7 +1281,7 @@ __docker_volume_complete_ls_filters() {
;; ;;
esac esac
else else
opts=('dangling' 'driver' 'name') opts=('dangling' 'driver' 'label' 'name')
_describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0
fi fi
@ -1330,12 +1340,12 @@ __docker_volume_subcommand() {
case "$words[1]" in case "$words[1]" in
(create) (create)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) -A '-*' \
$opts_help \ $opts_help \
"($help -d --driver)"{-d=,--driver=}"[Volume driver name]:Driver name:(local)" \ "($help -d --driver)"{-d=,--driver=}"[Volume driver name]:Driver name:(local)" \
"($help)*--label=[Set metadata for a volume]:label=value: " \ "($help)*--label=[Set metadata for a volume]:label=value: " \
"($help)--name=[Volume name]" \ "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " \
"($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " && ret=0 "($help -)1:Volume name: " && ret=0
;; ;;
(inspect) (inspect)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
@ -1347,6 +1357,7 @@ __docker_volume_subcommand() {
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
"($help)--format=[Pretty-print volumes using a Go template]:template: " \
"($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0 "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0
case $state in case $state in
(filter-options) (filter-options)
@ -1357,6 +1368,7 @@ __docker_volume_subcommand() {
(rm) (rm)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
"($help -f --force)"{-f,--force}"[Force the removal of one or more volumes]" \
"($help -):volume:__docker_volumes" && ret=0 "($help -):volume:__docker_volumes" && ret=0
;; ;;
(help) (help)
@ -1367,6 +1379,8 @@ __docker_volume_subcommand() {
return ret return ret
} }
# EO volume
__docker_caching_policy() { __docker_caching_policy() {
oldp=( "$1"(Nmh+1) ) # 1 hour oldp=( "$1"(Nmh+1) ) # 1 hour
(( $#oldp )) (( $#oldp ))
@ -1646,7 +1660,8 @@ __docker_subcommand() {
$opts_help \ $opts_help \
"($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \
"($help)--since=[Events created since this timestamp]:timestamp: " \ "($help)--since=[Events created since this timestamp]:timestamp: " \
"($help)--until=[Events created until this timestamp]:timestamp: " && ret=0 "($help)--until=[Events created until this timestamp]:timestamp: " \
"($help)--format=[Format the output using the given go template]:template: " && ret=0
;; ;;
(exec) (exec)
local state local state
@ -1689,7 +1704,7 @@ __docker_subcommand() {
"($help -a --all)"{-a,--all}"[Show all images]" \ "($help -a --all)"{-a,--all}"[Show all images]" \
"($help)--digests[Show digests]" \ "($help)--digests[Show digests]" \
"($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \
"($help)--format[Pretty-print containers using a Go template]:format: " \ "($help)--format[Pretty-print images using a Go template]:template: " \
"($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 -): :__docker_repositories" && ret=0 "($help -): :__docker_repositories" && ret=0
@ -1710,7 +1725,8 @@ __docker_subcommand() {
;; ;;
(info|version) (info|version)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help && ret=0 $opts_help \
"($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0
;; ;;
(inspect) (inspect)
local state local state
@ -1806,6 +1822,23 @@ __docker_subcommand() {
$opts_help \ $opts_help \
"($help -)*:containers:__docker_runningcontainers" && ret=0 "($help -)*:containers:__docker_runningcontainers" && ret=0
;; ;;
(plugin)
local curcontext="$curcontext" state
_arguments $(__docker_arguments) \
$opts_help \
"($help -): :->command" \
"($help -)*:: :->option-or-argument" && ret=0
case $state in
(command)
__docker_plugin_commands && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:docker-${words[-1]}:
__docker_plugin_subcommand && ret=0
;;
esac
;;
(port) (port)
_arguments $(__docker_arguments) \ _arguments $(__docker_arguments) \
$opts_help \ $opts_help \
@ -1818,9 +1851,9 @@ __docker_subcommand() {
"($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_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]:format: " \ "($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]" \
"($help)-n[Show n last created containers, include non-running one]:n:(1 5 10 25 50)" \ "($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \
"($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]" \