diff options
author | Stefan Sprenger <stefan.sprenger@dkd.de> | 2011-05-26 17:59:00 +0200 |
---|---|---|
committer | Stefan Sprenger <stefan.sprenger@dkd.de> | 2011-05-26 17:59:00 +0200 |
commit | 835c9cee3ede273030bae5dcf465176d64b287dd (patch) | |
tree | 208c4290d695e22349a1d299ec1a09c2d2bf52d8 /railties/lib/rails/engine/commands.rb | |
parent | 60281af200180d752b8300bdad3c0a869d56347f (diff) | |
download | rails-835c9cee3ede273030bae5dcf465176d64b287dd.tar.gz rails-835c9cee3ede273030bae5dcf465176d64b287dd.tar.bz2 rails-835c9cee3ede273030bae5dcf465176d64b287dd.zip |
Introducing engine commands
Diffstat (limited to 'railties/lib/rails/engine/commands.rb')
-rw-r--r-- | railties/lib/rails/engine/commands.rb | 37 |
1 files changed, 37 insertions, 0 deletions
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 |