Merge pull request #682 from albers/completion-service-options

Fix and simplify bash completion for service env, mounts and labels
This commit is contained in:
Vincent Demeester 2018-02-01 14:02:51 -08:00 committed by GitHub
commit 26a2a45967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 57 deletions

View File

@ -3354,7 +3354,6 @@ _docker_service_update_and_create() {
local options_with_args=" local options_with_args="
--endpoint-mode --endpoint-mode
--entrypoint --entrypoint
--env -e
--force --force
--health-cmd --health-cmd
--health-interval --health-interval
@ -3363,12 +3362,10 @@ _docker_service_update_and_create() {
--health-timeout --health-timeout
--hostname --hostname
--isolation --isolation
--label -l
--limit-cpu --limit-cpu
--limit-memory --limit-memory
--log-driver --log-driver
--log-opt --log-opt
--mount
--replicas --replicas
--reserve-cpu --reserve-cpu
--reserve-memory --reserve-memory
@ -3416,11 +3413,14 @@ _docker_service_update_and_create() {
--dns --dns
--dns-option --dns-option
--dns-search --dns-search
--env -e
--env-file --env-file
--generic-resource --generic-resource
--group --group
--host --host
--label -l
--mode --mode
--mount
--name --name
--network --network
--placement-pref --placement-pref
@ -3429,39 +3429,14 @@ _docker_service_update_and_create() {
" "
case "$prev" in case "$prev" in
--config)
__docker_complete_configs
return
;;
--env-file) --env-file)
_filedir _filedir
return return
;; ;;
--group)
COMPREPLY=( $(compgen -g -- "$cur") )
return
;;
--host)
case "$cur" in
*:)
__docker_complete_resolved_hostname
return
;;
esac
;;
--mode) --mode)
COMPREPLY=( $( compgen -W "global replicated" -- "$cur" ) ) COMPREPLY=( $( compgen -W "global replicated" -- "$cur" ) )
return return
;; ;;
--placement-pref)
COMPREPLY=( $( compgen -W "spread" -S = -- "$cur" ) )
__docker_nospace
return
;;
--secret)
__docker_complete_secrets
return
;;
esac esac
fi fi
if [ "$subcommand" = "update" ] ; then if [ "$subcommand" = "update" ] ; then
@ -3479,6 +3454,8 @@ _docker_service_update_and_create() {
--dns-rm --dns-rm
--dns-search-add --dns-search-add
--dns-search-rm --dns-search-rm
--env-add
--env-rm
--generic-resource-add --generic-resource-add
--generic-resource-rm --generic-resource-rm
--group-add --group-add
@ -3486,6 +3463,10 @@ _docker_service_update_and_create() {
--host-add --host-add
--host-rm --host-rm
--image --image
--label-add
--label-rm
--mount-add
--mount-rm
--network-add --network-add
--network-rm --network-rm
--placement-pref-add --placement-pref-add
@ -3498,39 +3479,14 @@ _docker_service_update_and_create() {
" "
case "$prev" in case "$prev" in
--config-add|--config-rm) --env-rm)
__docker_complete_configs COMPREPLY=( $( compgen -e -- "$cur" ) )
return return
;; ;;
--group-add|--group-rm)
COMPREPLY=( $(compgen -g -- "$cur") )
return
;;
--host-add|--host-rm)
case "$cur" in
*:)
__docker_complete_resolved_hostname
return
;;
esac
;;
--image) --image)
__docker_complete_images --repo --tag --id __docker_complete_images --repo --tag --id
return return
;; ;;
--network-add|--network-rm)
__docker_complete_networks
return
;;
--placement-pref-add|--placement-pref-rm)
COMPREPLY=( $( compgen -W "spread" -S = -- "$cur" ) )
__docker_nospace
return
;;
--secret-add|--secret-rm)
__docker_complete_secrets
return
;;
esac esac
fi fi
@ -3544,16 +3500,32 @@ _docker_service_update_and_create() {
esac esac
case "$prev" in case "$prev" in
--config|--config-add|--config-rm)
__docker_complete_configs
return
;;
--endpoint-mode) --endpoint-mode)
COMPREPLY=( $( compgen -W "dnsrr vip" -- "$cur" ) ) COMPREPLY=( $( compgen -W "dnsrr vip" -- "$cur" ) )
return return
;; ;;
--env|-e) --env|-e|--env-add)
# we do not append a "=" here because "-e VARNAME" is legal systax, too # we do not append a "=" here because "-e VARNAME" is legal systax, too
COMPREPLY=( $( compgen -e -- "$cur" ) ) COMPREPLY=( $( compgen -e -- "$cur" ) )
__docker_nospace __docker_nospace
return return
;; ;;
--group|--group-add|--group-rm)
COMPREPLY=( $(compgen -g -- "$cur") )
return
;;
--host|--host-add|--host-rm)
case "$cur" in
*:)
__docker_complete_resolved_hostname
return
;;
esac
;;
--isolation) --isolation)
__docker_complete_isolation __docker_complete_isolation
return return
@ -3566,10 +3538,15 @@ _docker_service_update_and_create() {
__docker_complete_log_options __docker_complete_log_options
return return
;; ;;
--network) --network|--network-add|--network-rm)
__docker_complete_networks __docker_complete_networks
return return
;; ;;
--placement-pref|--placement-pref-add|--placement-pref-rm)
COMPREPLY=( $( compgen -W "spread" -S = -- "$cur" ) )
__docker_nospace
return
;;
--restart-condition) --restart-condition)
COMPREPLY=( $( compgen -W "any none on-failure" -- "$cur" ) ) COMPREPLY=( $( compgen -W "any none on-failure" -- "$cur" ) )
return return
@ -3578,6 +3555,10 @@ _docker_service_update_and_create() {
COMPREPLY=( $( compgen -W "continue pause" -- "$cur" ) ) COMPREPLY=( $( compgen -W "continue pause" -- "$cur" ) )
return return
;; ;;
--secret|--secret-add|--secret-rm)
__docker_complete_secrets
return
;;
--stop-signal) --stop-signal)
__docker_complete_signals __docker_complete_signals
return return