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
|
|
|
|
|
2011-05-27 02:46:32 -04:00
|
|
|
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'
|
2011-06-07 05:21:38 -04:00
|
|
|
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
|
2012-08-05 18:27:56 -04:00
|
|
|
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.
|
2012-05-05 02:11:09 -04:00
|
|
|
|
|
|
|
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
|