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 <github@albersweb.de>
This commit is contained in:
Harald Albers 2020-09-11 21:09:11 +02:00
parent 2955ece024
commit 1e864920ac
1 changed files with 50 additions and 0 deletions

View File

@ -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