From 835c9cee3ede273030bae5dcf465176d64b287dd Mon Sep 17 00:00:00 2001 From: Stefan Sprenger Date: Thu, 26 May 2011 17:59:00 +0200 Subject: Introducing engine commands --- railties/lib/rails/engine/commands.rb | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 railties/lib/rails/engine/commands.rb (limited to 'railties/lib/rails/engine') diff --git a/railties/lib/rails/engine/commands.rb b/railties/lib/rails/engine/commands.rb new file mode 100644 index 0000000000..33a7cd5805 --- /dev/null +++ b/railties/lib/rails/engine/commands.rb @@ -0,0 +1,37 @@ +require 'active_support/core_ext/object/inclusion' + +ARGV << '--help' if ARGV.empty? + +aliases = { + "g" => "generate" +} + +command = ARGV.shift +command = aliases[command] || command + +case command +when 'generate' + require 'rails/generators' + + require ENGINE_PATH + engine = ::Rails::Engine.find(ENGINE_ROOT) + engine.load_generators + + require 'rails/commands/generate' + +when '--version', '-v' + ARGV.unshift '--version' + require 'rails/commands/application' + +else + puts "Error: Command not recognized" unless command.in?(['-h', '--help']) + puts <<-EOT +Usage: rails COMMAND [ARGS] + +The common rails commands available for engines are: + generate Generate new code (short-cut alias: "g") + +All commands can be run with -h for more information. + EOT + exit(1) +end -- cgit v1.2.3