Update bash completion.

pull/6360/head
Omer Katz 2 years ago
parent 937844c048
commit d505db6b3c
  1. 142
      extra/bash-completion/celery.bash

@ -1,131 +1,21 @@
# This is a bash completion script for celery
# Redirect it to a file, then source it or copy it to /etc/bash_completion.d
# to get tab completion. celery must be on your PATH for this to work.
_celery()
{
local cur basep opts base kval kkey loglevels prevp in_opt controlargs
local pools
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prevp="${COMP_WORDS[COMP_CWORD-1]}"
basep="${COMP_WORDS[1]}"
opts="worker events beat shell multi amqp status
inspect control purge list migrate call result
report upgrade flower graph logtool help"
fargs="--app= --broker= --loader= --config= --version"
dopts="--detach --umask= --gid= --uid= --pidfile=
--logfile= --loglevel= --executable="
controlargs="--timeout --destination"
pools="prefork eventlet gevent solo"
loglevels="critical error warning info debug"
in_opt=0
# find the current sub-command, store in basep'
for index in $(seq 1 $((${#COMP_WORDS[@]} - 2)))
do
basep=${COMP_WORDS[$index]}
if [ "${basep:0:2}" != "--" ]; then
break;
fi
done
if [ "${cur:0:2}" == "--" -a "$cur" != "${cur//=}" ]; then
in_opt=1
kkey="${cur%=*}"
kval="${cur#*=}"
elif [ "${prevp:0:1}" == "-" ]; then
in_opt=1
kkey="$prevp"
kval="$cur"
fi
_celery_completion() {
local IFS=$'
'
COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
_CELERY_COMPLETE=complete $1 ) )
return 0
}
if [ $in_opt -eq 1 ]; then
case "${kkey}" in
--uid|-u)
COMPREPLY=( $(compgen -u -- "$kval") )
return 0
;;
--gid|-g)
COMPREPLY=( $(compgen -g -- "$kval") )
return 0
;;
--pidfile|--logfile|-p|-f|--statedb|-S|-s|--schedule-filename)
COMPREPLY=( $(compgen -f -- "$kval") )
return 0
;;
--workdir)
COMPREPLY=( $(compgen -d -- "$kval") )
return 0
;;
--loglevel|-l)
COMPREPLY=( $(compgen -W "$loglevels" -- "$kval") )
return 0
;;
--pool|-P)
COMPREPLY=( $(compgen -W "$pools" -- "$kval") )
return 0
;;
*)
;;
esac
_celery_completionetup() {
local COMPLETION_OPTIONS=""
local BASH_VERSION_ARR=(${BASH_VERSION//./ })
# Only BASH version 4.4 and later have the nosort option.
if [ ${BASH_VERSION_ARR[0]} -gt 4 ] || ([ ${BASH_VERSION_ARR[0]} -eq 4 ] && [ ${BASH_VERSION_ARR[1]} -ge 4 ]); then
COMPLETION_OPTIONS="-o nosort"
fi
case "${basep}" in
worker)
COMPREPLY=( $(compgen -W '--concurrency= --pool= --purge --logfile=
--loglevel= --hostname= --beat --schedule= --scheduler= --statedb= --events
--time-limit= --soft-time-limit= --max-tasks-per-child= --queues=
--include= --pidfile= --autoscale $fargs' -- ${cur} ) )
return 0
;;
inspect)
COMPREPLY=( $(compgen -W 'active active_queues ping registered report
reserved revoked scheduled stats --help $controlargs $fargs' -- ${cur}) )
return 0
;;
control)
COMPREPLY=( $(compgen -W 'add_consumer autoscale cancel_consumer
disable_events enable_events pool_grow pool_shrink
rate_limit time_limit --help $controlargs $fargs' -- ${cur}) )
return 0
;;
multi)
COMPREPLY=( $(compgen -W 'start restart stopwait stop show
kill names expand get help --quiet --nosplash
--verbose --no-color --help $fargs' -- ${cur} ) )
return 0
;;
amqp)
COMPREPLY=( $(compgen -W 'queue.declare queue.purge exchange.delete
basic.publish exchange.declare queue.delete queue.bind
basic.get --help $fargs' -- ${cur} ))
return 0
;;
list)
COMPREPLY=( $(compgen -W 'bindings $fargs' -- ${cur} ) )
return 0
;;
shell)
COMPREPLY=( $(compgen -W '--ipython --bpython --python
--without-tasks --eventlet --gevent $fargs' -- ${cur} ) )
return 0
;;
beat)
COMPREPLY=( $(compgen -W '--schedule= --scheduler=
--max-interval= $dopts $fargs' -- ${cur} ))
return 0
;;
events)
COMPREPLY=( $(compgen -W '--dump --camera= --freq=
--maxrate= $dopts $fargs' -- ${cur}))
return 0
;;
*)
;;
esac
COMPREPLY=($(compgen -W "${opts} ${fargs}" -- ${cur}))
return 0
complete $COMPLETION_OPTIONS -F _celery_completion celery
}
complete -F _celery celery
_celery_completionetup;

Loading…
Cancel
Save