From 1e864920accacec0176b63c302ce22008a459b1c Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Fri, 11 Sep 2020 21:09:11 +0200 Subject: [PATCH] Improve bash completion for ulimits This adds bash completion for limits after - docker service create --ulimit - docker service update --ulimit-add - docker service update --ulimit-rm - docker container create --ulimit - docker container run --ulimit - docker build --ulimit - dockerd --default-ulimit Signed-off-by: Harald Albers --- contrib/completion/bash/docker | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 04b0fbbbac..f9a6139ebe 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -1149,6 +1149,36 @@ __docker_complete_stack_orchestrator_options() { return 1 } +__docker_complete_ulimits() { + local limits=" + as + chroot + core + cpu + data + fsize + locks + maxlogins + maxsyslogins + memlock + msgqueue + nice + nofile + nproc + priority + rss + rtprio + sigpending + stack + " + if [ "$1" = "--rm" ] ; then + COMPREPLY=( $( compgen -W "$limits" -- "$cur" ) ) + else + COMPREPLY=( $( compgen -W "$limits" -S = -- "$cur" ) ) + __docker_nospace + fi +} + __docker_complete_user_group() { if [[ $cur == *:* ]] ; then COMPREPLY=( $(compgen -g -- "${cur#*:}") ) @@ -2148,6 +2178,10 @@ _docker_container_run_and_create() { __docker_nospace return ;; + --ulimit) + __docker_complete_ulimits + return + ;; --user|-u) __docker_complete_user_group return @@ -2634,6 +2668,10 @@ _docker_daemon() { _filedir return ;; + --default-ulimit) + __docker_complete_ulimits + return + ;; --exec-root|--data-root) _filedir -d return @@ -2897,6 +2935,10 @@ _docker_image_build() { COMPREPLY=( $( compgen -W "$targets" -- "$cur" ) ) return ;; + --ulimit) + __docker_complete_ulimits + return + ;; $(__docker_to_extglob "$options_with_args") ) return ;; @@ -3914,6 +3956,14 @@ _docker_service_update_and_create() { COMPREPLY=( $( compgen -W "continue pause rollback" -- "$cur" ) ) return ;; + --ulimit|--ulimit-add) + __docker_complete_ulimits + return + ;; + --ulimit-rm) + __docker_complete_ulimits --rm + return + ;; --update-order|--rollback-order) COMPREPLY=( $( compgen -W "start-first stop-first" -- "$cur" ) ) return