celery.zsh 6.1 KB

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