celery.bash 4.1 KB

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