aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands/commands_tasks.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/commands/commands_tasks.rb')
-rw-r--r--railties/lib/rails/commands/commands_tasks.rb28
1 files changed, 15 insertions, 13 deletions
diff --git a/railties/lib/rails/commands/commands_tasks.rb b/railties/lib/rails/commands/commands_tasks.rb
index e1713d5798..da3b9452d5 100644
--- a/railties/lib/rails/commands/commands_tasks.rb
+++ b/railties/lib/rails/commands/commands_tasks.rb
@@ -24,15 +24,18 @@ The most common rails commands are:
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:
- destroy Undo code generated with "generate" (short-cut alias: "d")
- 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.
+In addition to those commands, there are:
EOT
+ ADDITIONAL_COMMANDS = [
+ [ 'destroy', 'Undo code generated with "generate" (short-cut alias: "d")' ],
+ [ 'plugin new', 'Generates skeleton for developing a Rails plugin' ],
+ [ 'runner',
+ 'Run a piece of code in the application environment (short-cut alias: "r")' ]
+ ]
+
COMMAND_WHITELIST = %w(plugin generate destroy console server dbconsole runner new version help test)
def initialize(argv)
@@ -45,8 +48,7 @@ EOT
if COMMAND_WHITELIST.include?(command)
send(command)
else
- ARGV.unshift(command)
- send(:rake)
+ run_rake_task(command)
end
end
@@ -110,10 +112,6 @@ EOT
end
end
- def rake
- invoke_rake
- end
-
def version
argv.unshift '--version'
require_command!("application")
@@ -121,8 +119,7 @@ EOT
def help
write_help_message
- write_rake_tasks_help_message
- write_rake_tasks
+ write_commands ADDITIONAL_COMMANDS + formatted_rake_tasks
end
private
@@ -164,6 +161,11 @@ EOT
puts HELP_MESSAGE
end
+ def write_commands(commands)
+ width = commands.map { |name, _| name.size }.max || 10
+ commands.each { |command| printf(" %-#{width}s %s\n", *command) }
+ end
+
def parse_command(command)
case command
when '--version', '-v'