mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
447b6a4e67
Selecting which key extensions to include in active_support/rails
made apparent the systematic usage of Object#in? in the code base.
After some discussion in
5ea6b0df9a
we decided to remove it and use plain Ruby, which seems enough
for this particular idiom.
In this commit the refactor has been made case by case. Sometimes
include? is the natural alternative, others a simple || is the
way you actually spell the condition in your head, others a case
statement seems more appropriate. I have chosen the one I liked
the most in each case.
41 lines
1 KiB
Ruby
41 lines
1 KiB
Ruby
ARGV << '--help' if ARGV.empty?
|
|
|
|
aliases = {
|
|
"g" => "generate",
|
|
"d" => "destroy"
|
|
}
|
|
|
|
command = ARGV.shift
|
|
command = aliases[command] || command
|
|
|
|
require ENGINE_PATH
|
|
engine = ::Rails::Engine.find(ENGINE_ROOT)
|
|
|
|
case command
|
|
when 'generate', 'destroy'
|
|
require 'rails/generators'
|
|
Rails::Generators.namespace = engine.railtie_namespace
|
|
engine.load_generators
|
|
require "rails/commands/#{command}"
|
|
|
|
when '--version', '-v'
|
|
ARGV.unshift '--version'
|
|
require 'rails/commands/application'
|
|
|
|
else
|
|
puts "Error: Command not recognized" unless %w(-h --help).include?(command)
|
|
puts <<-EOT
|
|
Usage: rails COMMAND [ARGS]
|
|
|
|
The common rails commands available for engines are:
|
|
generate Generate new code (short-cut alias: "g")
|
|
destroy Undo code generated with "generate" (short-cut alias: "d")
|
|
|
|
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).
|
|
EOT
|
|
exit(1)
|
|
end
|