Skip to content

Commit

Permalink
fix bash completion for docker service subcommands
Browse files Browse the repository at this point in the history
Signed-off-by: Harald Albers <[email protected]>
  • Loading branch information
albers committed Jun 17, 2016
1 parent 8f9c7fa commit 42f3b1f
Showing 1 changed file with 109 additions and 8 deletions.
117 changes: 109 additions & 8 deletions contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -1528,11 +1528,11 @@ _docker_network() {
_docker_service() {
local subcommands="
create
tasks
inspect
ls list
rm remove
tasks
update
ls
rm
"
__docker_subcommands "$subcommands" && return

Expand All @@ -1547,43 +1547,134 @@ _docker_service() {
}

_docker_service_create() {
local options_with_args="
--constraint
--endpoint-mode
--env -e
--label -l
--limit-cpu
--limit-memory
--mode
--mount -m
--name
--network
--publish -p
--replicas
--reserve-cpu
--reserve-memory
--restart-condition
--restart-delay
--restart-max-attempts
--restart-window
--stop-grace-period
--update-delay
--update-parallelism
--user -u
--workdir -w
"

local boolean_options="
--help
"

case "$prev" in
$(__docker_to_extglob "$options_with_args") )
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --constraint --endpoint-ingress --endpoint-mode --env --label --limit-cpu --limit-memory --mode --name --network --publish --reserve-cpu --reserve-memory --restart-condition --restart-delay --restart-max-attempts --restart-window --replicas --stop-grace-period --update-delay --update-parallelism --user --volume --workdir" -- "$cur" ) )
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
;;
esac
}

_docker_service_update() {
local options_with_args="
--arg
--command
--constraint
--endpoint-mode
--env -e
--image
--label -l
--limit-cpu
--limit-memory
--mode
--mount -m
--name
--network
--publish -p
--replicas
--reserve-cpu
--reserve-memory
--restart-condition
--restart-delay
--restart-max-attempts
--restart-window
--stop-grace-period
--update-delay
--update-parallelism
--user -u
--workdir -w
"

local boolean_options="
--help
"

case "$prev" in
$(__docker_to_extglob "$options_with_args") )
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--arg --command --constraint --endpoint-ingress --endpoint-mode --env --help --image --label --limit-cpu --limit-memory --mode --name --network --publish --reserve-cpu --reserve-memory --restart-condition--restart-delay --restart-max-attempts --restart-window --replicas --stop-grace-period --update-delay --update-parallelism --user --volume --workdir" -- "$cur" ) )
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
;;
*)
__docker_complete_services
esac
}

_docker_service_inspect() {
case "$prev" in
--format|-f)
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --format --pretty" -- "$cur" ) )
COMPREPLY=( $( compgen -W "--format -f --help --pretty -p" -- "$cur" ) )
;;
*)
__docker_complete_services
esac
}

_docker_service_tasks() {
case "$prev" in
--format|-f)
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help --all --filter --no-resolve" -- "$cur" ) )
COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve -n" -- "$cur" ) )
;;
*)
__docker_complete_services
esac
}

_docker_service_remove() {
_docker_service_rm
}

_docker_service_rm() {
case "$cur" in
-*)
Expand All @@ -1594,10 +1685,20 @@ _docker_service_rm() {
esac
}

_docker_service_list() {
_docker_service_ls
}

_docker_service_ls() {
case "$prev" in
--format|-f)
return
;;
esac

case "$cur" in
-*)
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
COMPREPLY=( $( compgen -W "-f --filter --help --quiet -q" -- "$cur" ) )
;;
esac
}
Expand Down

0 comments on commit 42f3b1f

Please sign in to comment.