diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-10-12 18:23:50 -0700 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-10-12 18:23:50 -0700 |
commit | 32b4d464849d976431342aa0cfe2d4e17b10e9f0 (patch) | |
tree | be4a7bbd41774a0e5f9e6986b7328f454de8cc06 /railties/lib | |
parent | db8dbe76db514734082af9e8d166c1b33ea2f39f (diff) | |
parent | 20385ec6b16f1bb8158a3d087d1298a8f23a19e4 (diff) | |
download | rails-32b4d464849d976431342aa0cfe2d4e17b10e9f0.tar.gz rails-32b4d464849d976431342aa0cfe2d4e17b10e9f0.tar.bz2 rails-32b4d464849d976431342aa0cfe2d4e17b10e9f0.zip |
Merge pull request #7891 from schneems/schneems/rake_command_warning
Prompt to run rake when accidentally typed rails
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/commands.rb | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 9c5dc8f188..b0fae13192 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -9,6 +9,30 @@ aliases = { "r" => "runner" } +help_message = <<-EOT +Usage: rails COMMAND [ARGS] + +The most common rails commands are: + generate Generate new code (short-cut alias: "g") + console Start the Rails console (short-cut alias: "c") + server Start the Rails server (short-cut alias: "s") + dbconsole Start a console for the database specified in config/database.yml + (short-cut alias: "db") + new Create a new Rails application. "rails new my_app" creates a + new application called MyApp in "./my_app" + +In addition to those, there are: + application Generate the Rails application code + destroy Undo code generated with "generate" (short-cut alias: "d") + benchmarker See how fast a piece of code runs + profiler Get profile information from a piece of code + plugin new Generates skeleton for developing a Rails plugin + runner Run a piece of code in the application environment (short-cut alias: "r") + +All commands can be run with -h (or --help) for more information. +EOT + + command = ARGV.shift command = aliases[command] || command @@ -81,29 +105,14 @@ 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 most common rails commands are: - generate Generate new code (short-cut alias: "g") - console Start the Rails console (short-cut alias: "c") - server Start the Rails server (short-cut alias: "s") - dbconsole Start a console for the database specified in config/database.yml - (short-cut alias: "db") - new Create a new Rails application. "rails new my_app" creates a - new application called MyApp in "./my_app" +when '-h', '--help' + puts help_message -In addition to those, there are: - application Generate the Rails application code - destroy Undo code generated with "generate" (short-cut alias: "d") - benchmarker See how fast a piece of code runs - profiler Get profile information from a piece of code - plugin new Generates skeleton for developing a Rails plugin - runner Run a piece of code in the application environment (short-cut alias: "r") - -All commands can be run with -h (or --help) for more information. - EOT +else + puts "Error: Command '#{command}' not recognized" + if %x{rake #{command} --dry-run 2>&1 } && $?.success? + puts "Did you mean: `$ rake #{command}` ?\n\n" + end + puts help_message exit(1) end |