From 0e6eb9976beab68f91166094aa8d4b5e800fa0f2 Mon Sep 17 00:00:00 2001 From: Steve Durrheimer Date: Wed, 22 Mar 2017 23:17:42 +0100 Subject: [PATCH] Add zsh completion for 'docker service {create,update} --placement-pref' Signed-off-by: Steve Durrheimer --- contrib/completion/zsh/_docker | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index 9f19d0fb3a..27bf93eb5d 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -1799,6 +1799,28 @@ __docker_service_complete_ps_filters() { return ret } +__docker_service_complete_placement_pref() { + [[ $PREFIX = -* ]] && return 1 + integer ret=1 + + if compset -P '*='; then + case "${${words[-1]%=*}#*=}" in + (spread) + opts=('engine.labels' 'node.labels') + _describe -t spread-opts "spread options" opts -qS "." && ret=0 + ;; + *) + _message 'value' && ret=0 + ;; + esac + else + opts=('spread') + _describe -t pref-opts "placement pref options" opts -qS "=" && ret=0 + fi + + return ret +} + __docker_services() { [[ $PREFIX = -* ]] && return 1 integer ret=1 @@ -1931,6 +1953,7 @@ __docker_service_subcommand() { "($help)*--env-file=[Read environment variables from a file]:environment file:_files" \ "($help)--mode=[Service Mode]:mode:(global replicated)" \ "($help)--name=[Service name]:name: " \ + "($help)*--placement-pref=[Add a placement preference]:pref:__docker_service_complete_placement_pref" \ "($help)*--publish=[Publish a port]:port: " \ "($help -): :__docker_complete_images" \ "($help -):command: _command_names -e" \ @@ -2016,6 +2039,8 @@ __docker_service_subcommand() { "($help)*--group-add=[Add additional supplementary user groups to the container]:group:_groups" \ "($help)*--group-rm=[Remove previously added supplementary user groups from the container]:group:_groups" \ "($help)--image=[Service image tag]:image:__docker_complete_repositories" \ + "($help)*--placement-pref-add=[Add a placement preference]:pref:__docker_service_complete_placement_pref" \ + "($help)*--placement-pref-rm=[Remove a placement preference]:pref:__docker_service_complete_placement_pref" \ "($help)*--publish-add=[Add or update a port]:port: " \ "($help)*--publish-rm=[Remove a port(target-port mandatory)]:port: " \ "($help)--rollback[Rollback to previous specification]" \