From 784ebccffaa8329aee9e88877e6039b5002ad8e3 Mon Sep 17 00:00:00 2001 From: Steve Durrheimer Date: Fri, 20 Jan 2017 15:46:50 +0100 Subject: [PATCH] Add zsh completion for 'docker {container,image,network,system} prune --filter' Signed-off-by: Steve Durrheimer --- contrib/completion/zsh/_docker | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index 2b7e822e36..a170ad1d52 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -474,6 +474,26 @@ __docker_complete_events_filter() { return ret } +__docker_complete_prune_filters() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + declare -a opts + + opts=('until') + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + *) + _message 'value' && ret=0 + ;; + esac + else + _describe -t filter-opts "filter options" opts -qS "=" && ret=0 + fi + + return ret +} + # BO container __docker_container_commands() { @@ -731,6 +751,7 @@ __docker_container_subcommand() { (prune) _arguments $(__docker_arguments) \ $opts_help \ + "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0 ;; (rename) @@ -977,6 +998,7 @@ __docker_image_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help -a --all)"{-a,--all}"[Remove all unused images, not just dangling ones]" \ + "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0 ;; (pull) @@ -1204,6 +1226,7 @@ __docker_network_subcommand() { (prune) _arguments $(__docker_arguments) \ $opts_help \ + "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0 ;; (rm) @@ -2142,6 +2165,7 @@ __docker_system_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help -a --all)"{-a,--all}"[Remove all unused data, not just dangling ones]" \ + "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0 ;; (help)