_rails 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #compdef rails
  2. #autoload
  3. local -a _1st_arguments
  4. _1st_arguments=(
  5. 'generate:Generate new code (short-cut alias: "g")'
  6. 'console:Start the Rails console (short-cut alias: "c")'
  7. 'server:Start the Rails server (short-cut alias: "s")'
  8. 'dbconsole:Start a console for the database specified in config/database.yml (short-cut alias: "db")'
  9. 'new:Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"'
  10. 'application:Generate the Rails application code'
  11. 'destroy:Undo code generated with "generate"'
  12. 'benchmarker:See how fast a piece of code runs'
  13. 'profiler:Get profile information from a piece of code'
  14. 'plugin:Install a plugin'
  15. 'plugin new:Generates skeleton for developing a Rails plugin'
  16. 'runner:Run a piece of code in the application environment (short-cut alias: "r")'
  17. )
  18. _rails_generate_arguments() {
  19. generate_arguments=(
  20. assets
  21. controller
  22. decorator
  23. generator
  24. helper
  25. integration_test
  26. mailer
  27. migration
  28. model
  29. observer
  30. performance_test
  31. plugin
  32. resource
  33. scaffold
  34. scaffold_controller
  35. session_migration
  36. stylesheets
  37. task
  38. )
  39. }
  40. _arguments \
  41. '(--version)--version[show version]' \
  42. '(--help)--help[show help]' \
  43. '*:: :->subcmds' && return 0
  44. if (( CURRENT == 1 )); then
  45. _describe -t commands "rails subcommand" _1st_arguments
  46. return
  47. else
  48. _files
  49. return
  50. fi
  51. case "$words[1]" in
  52. g|generate)
  53. _rails_generate_arguments
  54. _wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
  55. d|destroy)
  56. _rails_generate_arguments
  57. _wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
  58. esac