celery.bash 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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
  7. COMPREPLY=()
  8. cur="${COMP_WORDS[COMP_CWORD]}"
  9. basep="${COMP_WORDS[1]}"
  10. opts="worker events beat shell multi amqp status
  11. inspect control purge list migrate call result report"
  12. fargs="--app= --broker= --loader= --config= --version"
  13. dopts="--detach --umask= --gid= --uid= --pidfile= --logfile= --loglevel="
  14. # find the current subcommand, store in basep'
  15. for index in $(seq 1 $((${#COMP_WORDS[@]} - 2)))
  16. do
  17. basep=${COMP_WORDS[$index]}
  18. if [ "${basep:0:2}" != "--" ]; then
  19. break;
  20. fi
  21. done
  22. if [ "${cur:0:2}" == "--" -a "$cur" != "${cur//=}" ]; then
  23. kkey="${cur%=*}"
  24. kval="${cur#*=}"
  25. case "${kkey}" in
  26. --uid)
  27. COMPREPLY=( $(compgen -u -- "$kval") )
  28. return 0
  29. ;;
  30. --gid)
  31. COMPREPLY=( $(compgen -g -- "$kval") )
  32. return 0
  33. ;;
  34. *)
  35. ;;
  36. esac
  37. fi
  38. case "${basep}" in
  39. worker)
  40. COMPREPLY=( $(compgen -W '--concurrency= --pool= --purge --logfile=
  41. --loglevel= --hostname= --beat --schedule= --scheduler= --statedb= --events
  42. --time-limit= --soft-time-limit= --maxtasksperchild= --queues=
  43. --include= --pidfile= --autoscale= --autoreload --no-execv' -- ${cur} ) )
  44. return 0
  45. ;;
  46. inspect)
  47. COMPREPLY=( $(compgen -W 'active active_queues ping registered report
  48. reserved revoked scheduled stats --help' -- ${cur}) )
  49. return 0
  50. ;;
  51. control)
  52. COMPREPLY=( $(compgen -W 'add_consumer autoscale cancel_consumer
  53. disable_events enable_events pool_grow pool_shrink
  54. rate_limit time_limit --help' -- ${cur}) )
  55. return 0
  56. ;;
  57. multi)
  58. COMPREPLY=( $(compgen -W 'start restart stopwait stop show
  59. kill names expand get help --quiet --nosplash
  60. --verbose --no-color --help' -- ${cur} ) )
  61. return 0
  62. ;;
  63. amqp)
  64. COMPREPLY=( $(compgen -W 'queue.declare queue.purge exchange.delete
  65. basic.publish exchange.declare queue.delete queue.bind
  66. basic.get --help' -- ${cur} ))
  67. return 0
  68. ;;
  69. list)
  70. COMPREPLY=( $(compgen -W 'bindings' -- ${cur} ) )
  71. return 0
  72. ;;
  73. shell)
  74. COMPREPLY=( $(compgen -W '--ipython --bpython --python
  75. --without-tasks --eventlet --gevent' -- ${cur} ) )
  76. return 0
  77. ;;
  78. beat)
  79. COMPREPLY=( $(compgen -W '--schedule= --scheduler=
  80. --max-interval= $dopts' -- ${cur} ))
  81. return 0
  82. ;;
  83. events)
  84. COMPREPLY=( $(compgen -W '--dump --camera= --freq=
  85. --maxrate= $dopts' -- ${cur}))
  86. return 0
  87. ;;
  88. *)
  89. ;;
  90. esac
  91. COMPREPLY=($(compgen -W "${opts} ${fargs}" -- ${cur}))
  92. return 0
  93. }
  94. complete -F _celery celery