_zeus 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #compdef zeus
  2. #autoload
  3. # in order to make this work, you will need to have the gem zeus installed
  4. # zeus zsh completion
  5. local -a _1st_arguments
  6. if [[ -e .zeus.sock ]]; then
  7. _1st_arguments=(
  8. 'console:Lets you interact with your Rails application from the command line. (alias = c)'
  9. 'cucumber:Runs cucumber.'
  10. 'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
  11. 'destroy:Figures out what generate did, and undoes it. (alias = d)'
  12. 'generate:Uses templates to create a whole lot of things. (alias = g)'
  13. 'rake:Execute rake tasks.'
  14. 'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
  15. 'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
  16. 'test:Runs RSpec tests. (alias = rspec, testrb)'
  17. 'version:Shows the version number.'
  18. )
  19. else
  20. _1st_arguments=(
  21. 'start:Preloads the zeus environment'
  22. 'init:Generate a zeus.json file'
  23. )
  24. fi
  25. _rails_generate_arguments() {
  26. generate_arguments=(
  27. controller
  28. generator
  29. helper
  30. integration_test
  31. mailer
  32. migration
  33. model
  34. observer
  35. performance_test
  36. plugin
  37. resource
  38. scaffold
  39. scaffold_controller
  40. session_migration
  41. stylesheets
  42. )
  43. }
  44. _rake_does_task_list_need_generating () {
  45. if [ ! -f .rake_tasks ]; then return 0;
  46. else
  47. accurate=$(stat -f%m .rake_tasks)
  48. changed=$(stat -f%m Rakefile)
  49. return $(expr $accurate '>=' $changed)
  50. fi
  51. }
  52. _zrake ()
  53. {
  54. local expl
  55. declare -a tasks
  56. if [ -f Rakefile ]; then
  57. if _rake_does_task_list_need_generating; then
  58. echo "\nGenerating .rake_tasks..." > /dev/stderr
  59. rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
  60. fi
  61. tasks=(`cat .rake_tasks`)
  62. _wanted tasks expl 'rake' compadd $tasks
  63. fi
  64. }
  65. local expl
  66. local curcontext="$curcontext" state line
  67. typeset -A opt_args
  68. _arguments -C \
  69. ':command:->command' \
  70. '*::options:->options'
  71. case $state in
  72. (command)
  73. _describe -t commands "zeus subcommand" _1st_arguments
  74. return
  75. ;;
  76. (options)
  77. case $line[1] in
  78. (rake)
  79. _zrake
  80. ;;
  81. (generate|g|destroy|d)
  82. _rails_generate_arguments
  83. _wanted generate_arguments expl 'all generate' compadd -a generate_arguments
  84. ;;
  85. esac
  86. ;;
  87. esac