celery.zsh 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. _celery () {
  11. local -a _1st_arguments ifargs dopts controlargs
  12. typeset -A opt_args
  13. _1st_arguments=('worker' 'events' 'beat' 'shell' 'multi' 'amqp' 'status' 'inspect' \
  14. 'control' 'purge' 'list' 'migrate' 'call' 'result' 'report' \
  15. 'graph', 'logtool', 'help')
  16. ifargs=('--app=' '--broker=' '--loader=' '--config=' '--version')
  17. dopts=('--detach' '--umask=' '--gid=' '--uid=' '--pidfile=' '--logfile=' '--loglevel=')
  18. controlargs=('--timeout' '--destination')
  19. _arguments \
  20. '(-A --app=)'{-A,--app}'[app instance to use (e.g., module.attr_name):APP]' \
  21. '(-b --broker=)'{-b,--broker}'[url to broker. default is "amqp://guest@localhost//":BROKER]' \
  22. '(--loader)--loader[name of custom loader class to use.:LOADER]' \
  23. '(--config)--config[Name of the configuration module:CONFIG]' \
  24. '(--workdir)--workdir[Optional directory to change to after detaching.:WORKING_DIRECTORY]' \
  25. '(-q --quiet)'{-q,--quiet}'[Don"t show as much output.]' \
  26. '(-C --no-color)'{-C,--no-color}'[Don"t display colors.]' \
  27. '(--version)--version[show program"s version number and exit]' \
  28. '(- : *)'{-h,--help}'[show this help message and exit]' \
  29. '*:: :->subcmds' && return 0
  30. if (( CURRENT == 1 )); then
  31. _describe -t commands "celery sub-command" _1st_arguments
  32. return
  33. fi
  34. case "$words[1]" in
  35. worker)
  36. _arguments \
  37. '(-C --concurrency=)'{-C,--concurrency=}'[Number of child processes processing the queue. The default is the number of CPUs.]' \
  38. '(--pool)--pool=:::(prefork eventlet gevent solo)' \
  39. '(--purge --discard)'{--discard,--purge}'[Purges all waiting tasks before the daemon is started.]' \
  40. '(-f --logfile=)'{-f,--logfile=}'[Path to log file. If no logfile is specified, stderr is used.]' \
  41. '(--loglevel=)--loglevel=:::(critical error warning info debug)' \
  42. '(-N --hostname=)'{-N,--hostname=}'[Set custom hostname, e.g., "foo@example.com".]' \
  43. '(-B --beat)'{-B,--beat}'[Also run the celerybeat periodic task scheduler.]' \
  44. '(-s --schedule=)'{-s,--schedule=}'[Path to the schedule database if running with the -B option. Defaults to celerybeat-schedule.]' \
  45. '(-S --statedb=)'{-S,--statedb=}'[Path to the state database.Default: None]' \
  46. '(-E --events)'{-E,--events}'[Send events that can be captured by monitors like celeryev, celerymon, and others.]' \
  47. '(--time-limit=)--time-limit=[nables a hard time limit (in seconds int/float) for tasks]' \
  48. '(--soft-time-limit=)--soft-time-limit=[Enables a soft time limit (in seconds int/float) for tasks]' \
  49. '(--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.]' \
  50. '(-Q --queues=)'{-Q,--queues=}'[List of queues to enable for this worker, separated by comma. By default all configured queues are enabled.]' \
  51. '(-I --include=)'{-I,--include=}'[Comma separated list of additional modules to import.]' \
  52. '(--pidfile=)--pidfile=[Optional file used to store the process pid.]' \
  53. '(--autoscale=)--autoscale=[Enable autoscaling by providing max_concurrency, min_concurrency.]' \
  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. }