1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/lib/rails/engine/commands.rb

42 lines
1 KiB
Ruby
Raw Normal View History

2011-05-26 11:59:00 -04:00
ARGV << '--help' if ARGV.empty?
aliases = {
2011-08-23 00:39:17 -04:00
"g" => "generate",
"d" => "destroy"
2011-05-26 11:59:00 -04:00
}
command = ARGV.shift
command = aliases[command] || command
require ENGINE_PATH
engine = ::Rails::Engine.find(ENGINE_ROOT)
2011-05-26 11:59:00 -04:00
case command
2011-05-27 07:50:42 -04:00
when 'generate', 'destroy'
2011-05-26 11:59:00 -04:00
require 'rails/generators'
Rails::Generators.namespace = engine.railtie_namespace
2011-05-26 11:59:00 -04:00
engine.load_generators
2011-05-27 07:50:42 -04:00
require "rails/commands/#{command}"
2011-05-26 11:59:00 -04:00
when '--version', '-v'
ARGV.unshift '--version'
require 'rails/commands/application'
else
puts "Error: Command not recognized" unless %w(-h --help).include?(command)
2011-05-26 11:59:00 -04:00
puts <<-EOT
Usage: rails COMMAND [ARGS]
2013-05-09 07:57:08 -04:00
The common Rails commands available for engines are:
2011-05-26 11:59:00 -04:00
generate Generate new code (short-cut alias: "g")
2011-08-23 00:39:17 -04:00
destroy Undo code generated with "generate" (short-cut alias: "d")
2011-05-26 11:59:00 -04:00
All commands can be run with -h for more information.
If you want to run any commands that need to be run in context
of the application, like `rails server` or `rails console`,
you should do it from application's directory (typically test/dummy).
2011-05-26 11:59:00 -04:00
EOT
exit(1)
end