celery.bash 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # This is a bash completion script for celery
  2. # Redirect it to a file, then source it or copy it to /etc/bash_completion.d
  3. # to get tab completion. celery must be on your PATH for this to work.
  4. _celery()
  5. {
  6. local cur basep opts base kval kkey loglevels prevp in_opt controlargs
  7. local pools
  8. COMPREPLY=()
  9. cur="${COMP_WORDS[COMP_CWORD]}"
  10. prevp="${COMP_WORDS[COMP_CWORD-1]}"
  11. basep="${COMP_WORDS[1]}"
  12. opts="worker events beat shell multi amqp status
  13. inspect control purge list migrate call result report"
  14. fargs="--app= --broker= --loader= --config= --version"
  15. dopts="--detach --umask= --gid= --uid= --pidfile= --logfile= --loglevel="
  16. controlargs="--timeout --destination"
  17. pools="prefork eventlet gevent threads solo"
  18. loglevels="critical error warning info debug"
  19. in_opt=0
  20. # find the current subcommand, store in basep'
  21. for index in $(seq 1 $((${#COMP_WORDS[@]} - 2)))
  22. do
  23. basep=${COMP_WORDS[$index]}
  24. if [ "${basep:0:2}" != "--" ]; then
  25. break;
  26. fi
  27. done
  28. if [ "${cur:0:2}" == "--" -a "$cur" != "${cur//=}" ]; then
  29. in_opt=1
  30. kkey="${cur%=*}"
  31. kval="${cur#*=}"
  32. elif [ "${prevp:0:1}" == "-" ]; then
  33. in_opt=1
  34. kkey="$prevp"
  35. kval="$cur"
  36. fi
  37. if [ $in_opt -eq 1 ]; then
  38. case "${kkey}" in
  39. --uid|-u)
  40. COMPREPLY=( $(compgen -u -- "$kval") )
  41. return 0
  42. ;;
  43. --gid|-g)
  44. COMPREPLY=( $(compgen -g -- "$kval") )
  45. return 0
  46. ;;
  47. --pidfile|--logfile|-p|-f|--statedb|-S|-s|--schedule-filename)
  48. COMPREPLY=( $(compgen -f -- "$kval") )
  49. return 0
  50. ;;
  51. --workdir)
  52. COMPREPLY=( $(compgen -d -- "$kval") )
  53. return 0
  54. ;;
  55. --loglevel|-l)
  56. COMPREPLY=( $(compgen -W "$loglevels" -- "$kval") )
  57. return 0
  58. ;;
  59. --pool|-P)
  60. COMPREPLY=( $(compgen -W "$pools" -- "$kval") )
  61. return 0
  62. ;;
  63. *)
  64. ;;
  65. esac
  66. fi
  67. case "${basep}" in
  68. worker)
  69. COMPREPLY=( $(compgen -W '--concurrency= --pool= --purge --logfile=
  70. --loglevel= --hostname= --beat --schedule= --scheduler= --statedb= --events
  71. --time-limit= --soft-time-limit= --maxtasksperchild= --queues=
  72. --include= --pidfile= --autoscale= --autoreload --no-execv $fargs' -- ${cur} ) )
  73. return 0
  74. ;;
  75. inspect)
  76. COMPREPLY=( $(compgen -W 'active active_queues ping registered report
  77. reserved revoked scheduled stats --help $controlargs $fargs' -- ${cur}) )
  78. return 0
  79. ;;
  80. control)
  81. COMPREPLY=( $(compgen -W 'add_consumer autoscale cancel_consumer
  82. disable_events enable_events pool_grow pool_shrink
  83. rate_limit time_limit --help $controlargs $fargs' -- ${cur}) )
  84. return 0
  85. ;;
  86. multi)
  87. COMPREPLY=( $(compgen -W 'start restart stopwait stop show
  88. kill names expand get help --quiet --nosplash
  89. --verbose --no-color --help $fargs' -- ${cur} ) )
  90. return 0
  91. ;;
  92. amqp)
  93. COMPREPLY=( $(compgen -W 'queue.declare queue.purge exchange.delete
  94. basic.publish exchange.declare queue.delete queue.bind
  95. basic.get --help $fargs' -- ${cur} ))
  96. return 0
  97. ;;
  98. list)
  99. COMPREPLY=( $(compgen -W 'bindings $fargs' -- ${cur} ) )
  100. return 0
  101. ;;
  102. shell)
  103. COMPREPLY=( $(compgen -W '--ipython --bpython --python
  104. --without-tasks --eventlet --gevent $fargs' -- ${cur} ) )
  105. return 0
  106. ;;
  107. beat)
  108. COMPREPLY=( $(compgen -W '--schedule= --scheduler=
  109. --max-interval= $dopts $fargs' -- ${cur} ))
  110. return 0
  111. ;;
  112. events)
  113. COMPREPLY=( $(compgen -W '--dump --camera= --freq=
  114. --maxrate= $dopts $fargs' -- ${cur}))
  115. return 0
  116. ;;
  117. *)
  118. ;;
  119. esac
  120. COMPREPLY=($(compgen -W "${opts} ${fargs}" -- ${cur}))
  121. return 0
  122. }
  123. complete -F _celery celery