| 1 |
# This is a zsh completion script for Celery |
| 2 |
# It has to be installed as follows: |
| 3 |
# |
| 4 |
# Alternative A) Copy the script to your zsh site-functions directory (often |
| 5 |
# ``/usr/share/zsh/site-functions``) and name the script ``_celery`` |
| 6 |
# |
| 7 |
# Alternative B). Or, use this file as a oh-my-zsh plugin (rename the script |
| 8 |
# to ``_celery``), and add it to .zshrc: plugins=(celery git osx ruby) |
| 9 |
# |
| 10 |
|
| 11 |
_celery () { |
| 12 |
local -a _1st_arguments ifargs dopts controlargs |
| 13 |
|
| 14 |
typeset -A opt_args |
| 15 |
|
| 16 |
_1st_arguments=('worker' 'events' 'beat' 'shell' 'multi' 'amqp' 'status' 'inspect' \ |
| 17 |
'control' 'purge' 'list' 'migrate' 'call' 'result' 'report' \ |
| 18 |
'graph', 'logtool', 'help') |
| 19 |
ifargs=('--app=' '--broker=' '--loader=' '--config=' '--version') |
| 20 |
dopts=('--detach' '--umask=' '--gid=' '--uid=' '--pidfile=' '--logfile=' '--loglevel=') |
| 21 |
controlargs=('--timeout' '--destination') |
| 22 |
_arguments \ |
| 23 |
'(-A --app=)'{-A,--app}'[app instance to use (e.g., module.attr_name):APP]' \ |
| 24 |
'(-b --broker=)'{-b,--broker}'[url to broker. default is "amqp://guest@localhost//":BROKER]' \ |
| 25 |
'(--loader)--loader[name of custom loader class to use.:LOADER]' \ |
| 26 |
'(--config)--config[Name of the configuration module:CONFIG]' \ |
| 27 |
'(--workdir)--workdir[Optional directory to change to after detaching.:WORKING_DIRECTORY]' \ |
| 28 |
'(-q --quiet)'{-q,--quiet}'[Don"t show as much output.]' \ |
| 29 |
'(-C --no-color)'{-C,--no-color}'[Don"t display colors.]' \ |
| 30 |
'(--version)--version[show program"s version number and exit]' \ |
| 31 |
'(- : *)'{-h,--help}'[show this help message and exit]' \ |
| 32 |
'*:: :->subcmds' && return 0 |
| 33 |
|
| 34 |
if (( CURRENT == 1 )); then |
| 35 |
_describe -t commands "celery sub-command" _1st_arguments |
| 36 |
return |
| 37 |
fi |
| 38 |
|
| 39 |
case "$words[1]" in |
| 40 |
worker) |
| 41 |
_arguments \ |
| 42 |
'(-C --concurrency=)'{-C,--concurrency=}'[Number of child processes processing the queue. The default is the number of CPUs.]' \ |
| 43 |
'(--pool)--pool=:::(prefork eventlet gevent solo)' \ |
| 44 |
'(--purge --discard)'{--discard,--purge}'[Purges all waiting tasks before the daemon is started.]' \ |
| 45 |
'(-f --logfile=)'{-f,--logfile=}'[Path to log file. If no logfile is specified, stderr is used.]' \ |
| 46 |
'(--loglevel=)--loglevel=:::(critical error warning info debug)' \ |
| 47 |
'(-N --hostname=)'{-N,--hostname=}'[Set custom hostname, e.g., "[email protected]".]' \ |
| 48 |
'(-B --beat)'{-B,--beat}'[Also run the celerybeat periodic task scheduler.]' \ |
| 49 |
'(-s --schedule=)'{-s,--schedule=}'[Path to the schedule database if running with the -B option. Defaults to celerybeat-schedule.]' \ |
| 50 |
'(-S --statedb=)'{-S,--statedb=}'[Path to the state database.Default: None]' \ |
| 51 |
'(-E --events)'{-E,--events}'[Send events that can be captured by monitors like celeryev, celerymon, and others.]' \ |
| 52 |
'(--time-limit=)--time-limit=[nables a hard time limit (in seconds int/float) for tasks]' \ |
| 53 |
'(--soft-time-limit=)--soft-time-limit=[Enables a soft time limit (in seconds int/float) for tasks]' \ |
| 54 |
'(--max-tasks-per-child=)--max-tasks-per-child=[Maximum number of tasks a pool worker can execute before it"s terminated and replaced by a new worker.]' \ |
| 55 |
'(-Q --queues=)'{-Q,--queues=}'[List of queues to enable for this worker, separated by comma. By default all configured queues are enabled.]' \ |
| 56 |
'(-I --include=)'{-I,--include=}'[Comma separated list of additional modules to import.]' \ |
| 57 |
'(--pidfile=)--pidfile=[Optional file used to store the process pid.]' \ |
| 58 |
'(--autoscale=)--autoscale=[Enable autoscaling by providing max_concurrency, min_concurrency.]' \ |
| 59 |
compadd -a ifargs |
| 60 |
;; |
| 61 |
inspect) |
| 62 |
_values -s \ |
| 63 |
'active[dump active tasks (being processed)]' \ |
| 64 |
'active_queues[dump queues being consumed from]' \ |
| 65 |
'ping[ping worker(s)]' \ |
| 66 |
'registered[dump of registered tasks]' \ |
| 67 |
'report[get bugreport info]' \ |
| 68 |
'reserved[dump reserved tasks (waiting to be processed)]' \ |
| 69 |
'revoked[dump of revoked task ids]' \ |
| 70 |
'scheduled[dump scheduled tasks (eta/countdown/retry)]' \ |
| 71 |
'stats[dump worker statistics]' |
| 72 |
compadd -a controlargs ifargs |
| 73 |
;; |
| 74 |
control) |
| 75 |
_values -s \ |
| 76 |
'add_consumer[tell worker(s) to start consuming a queue]' \ |
| 77 |
'autoscale[change autoscale settings]' \ |
| 78 |
'cancel_consumer[tell worker(s) to stop consuming a queue]' \ |
| 79 |
'disable_events[tell worker(s) to disable events]' \ |
| 80 |
'enable_events[tell worker(s) to enable events]' \ |
| 81 |
'pool_grow[start more pool processes]' \ |
| 82 |
'pool_shrink[use less pool processes]' \ |
| 83 |
'rate_limit[tell worker(s) to modify the rate limit for a task type]' \ |
| 84 |
'time_limit[tell worker(s) to modify the time limit for a task type.]' |
| 85 |
compadd -a controlargs ifargs |
| 86 |
;; |
| 87 |
multi) |
| 88 |
_values -s \ |
| 89 |
'--nosplash[Don"t display program info.]' \ |
| 90 |
'--verbose[Show more output.]' \ |
| 91 |
'--no-color[Don"t display colors.]' \ |
| 92 |
'--quiet[Don"t show as much output.]' \ |
| 93 |
'start' 'restart' 'stopwait' 'stop' 'show' \ |
| 94 |
'names' 'expand' 'get' 'kill' |
| 95 |
compadd -a ifargs |
| 96 |
;; |
| 97 |
amqp) |
| 98 |
_values -s \ |
| 99 |
'queue.declare' 'queue.purge' 'exchange.delete' 'basic.publish' \ |
| 100 |
'exchange.declare' 'queue.delete' 'queue.bind' 'basic.get' |
| 101 |
;; |
| 102 |
list) |
| 103 |
_values -s, 'bindings' |
| 104 |
;; |
| 105 |
shell) |
| 106 |
_values -s \ |
| 107 |
'--ipython[force iPython.]' \ |
| 108 |
'--bpython[force bpython.]' \ |
| 109 |
'--python[force default Python shell.]' \ |
| 110 |
'--without-tasks[don"t add tasks to locals.]' \ |
| 111 |
'--eventlet[use eventlet.]' \ |
| 112 |
'--gevent[use gevent.]' |
| 113 |
compadd -a ifargs |
| 114 |
;; |
| 115 |
beat) |
| 116 |
_arguments \ |
| 117 |
'(-s --schedule=)'{-s,--schedule=}'[Path to the schedule database. Defaults to celerybeat-schedule.]' \ |
| 118 |
'(-S --scheduler=)'{-S,--scheduler=}'[Scheduler class to use. Default is celery.beat.PersistentScheduler.]' \ |
| 119 |
'(--max-interval)--max-interval[]' |
| 120 |
compadd -a dopts fargs |
| 121 |
;; |
| 122 |
events) |
| 123 |
_arguments \ |
| 124 |
'(-d --dump)'{-d,--dump}'[Dump events to stdout.]' \ |
| 125 |
'(-c --camera=)'{-c,--camera=}'[Take snapshots of events using this camera.]' \ |
| 126 |
'(-F --frequency=)'{-F,--frequency=}'[Camera: Shutter frequency. Default is every 1.0 seconds.]' \ |
| 127 |
'(-r --maxrate=)'{-r,--maxrate=}'[Camera: Optional shutter rate limit (e.g., 10/m).]' |
| 128 |
compadd -a dopts fargs |
| 129 |
;; |
| 130 |
*) |
| 131 |
;; |
| 132 |
esac |
| 133 |
} |