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.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/railties/lib/rails/commands/commands_tasks.rb b/railties/lib/rails/commands/commands_tasks.rb
index 7e6b49e2a3..da3b9452d5 100644
--- a/railties/lib/rails/commands/commands_tasks.rb
+++ b/railties/lib/rails/commands/commands_tasks.rb
@@ -1,3 +1,5 @@
+require 'rails/commands/rake_proxy'
+
module Rails
# This is a class which takes in a rails command and initiates the appropriate
# initiation sequence.
@@ -5,6 +7,8 @@ module Rails
# Warning: This class mutates ARGV because some commands require manipulating
# it before they are run.
class CommandsTasks # :nodoc:
+ include Rails::RakeProxy
+
attr_reader :argv
HELP_MESSAGE = <<-EOT
@@ -20,14 +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)
@@ -39,6 +47,8 @@ EOT
if COMMAND_WHITELIST.include?(command)
send(command)
+ else
+ run_rake_task(command)
end
end
@@ -109,6 +119,7 @@ EOT
def help
write_help_message
+ write_commands ADDITIONAL_COMMANDS + formatted_rake_tasks
end
private
@@ -150,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'