_rails3 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #compdef rails
  2. #autoload
  3. # rails 3 zsh completion, based on homebrew completion
  4. # Extracted from https://github.com/robbyrussell/oh-my-zsh/blob/30620d463850c17f86e7a56fbf6a8b5e793a4e07/plugins/rails3/_rails3
  5. # Published by Christopher Chow
  6. local -a _1st_arguments
  7. _1st_arguments=(
  8. 'generate:Generate new code (short-cut alias: "g")'
  9. 'console:Start the Rails console (short-cut alias: "c")'
  10. 'server:Start the Rails server (short-cut alias: "s")'
  11. 'dbconsole:Start a console for the database specified in config/database.yml (short-cut alias: "db")'
  12. 'new:Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"'
  13. 'application:Generate the Rails application code'
  14. 'destroy:Undo code generated with "generate"'
  15. 'benchmarker:See how fast a piece of code runs'
  16. 'profiler:Get profile information from a piece of code'
  17. 'plugin:Install a plugin'
  18. )
  19. _rails_generate_arguments() {
  20. generate_arguments=(
  21. controller
  22. generator
  23. helper
  24. integration_test
  25. mailer
  26. migration
  27. model
  28. observer
  29. performance_test
  30. plugin
  31. resource
  32. scaffold
  33. scaffold_controller
  34. session_migration
  35. stylesheets
  36. )
  37. }
  38. _arguments \
  39. '(--version)--version[show version]' \
  40. '(--help)--help[show help]' \
  41. '*:: :->subcmds' && return 0
  42. if (( CURRENT == 1 )); then
  43. _describe -t commands "rails subcommand" _1st_arguments
  44. return
  45. fi
  46. case "$words[1]" in
  47. generate)
  48. _rails_generate_arguments
  49. _wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
  50. esac