aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2015-12-06 14:06:07 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2015-12-06 14:06:07 +0100
commit93ee1b1021c974b9dd5ceee7166698af902cf34c (patch)
treed57b88d045c0087eded6d5b6db211dcbb378a6e0 /railties/lib/rails
parent88d194eac9573251cb83a92ebaf88dff4fa54ad3 (diff)
downloadrails-93ee1b1021c974b9dd5ceee7166698af902cf34c.tar.gz
rails-93ee1b1021c974b9dd5ceee7166698af902cf34c.tar.bz2
rails-93ee1b1021c974b9dd5ceee7166698af902cf34c.zip
Invert command and commands tasks reference.
We should first attempt to run commands through Rails command, and then fall back to trying the commands tasks. Because eventually the commands tasks should be their own commands.
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/commands.rb15
-rw-r--r--railties/lib/rails/commands/command.rb5
-rw-r--r--railties/lib/rails/commands/commands_tasks.rb4
3 files changed, 14 insertions, 10 deletions
diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb
index d4d8d3ac75..df2ed94654 100644
--- a/railties/lib/rails/commands.rb
+++ b/railties/lib/rails/commands.rb
@@ -1,5 +1,3 @@
-ARGV << '--help' if ARGV.empty?
-
aliases = {
"g" => "generate",
"d" => "destroy",
@@ -10,10 +8,15 @@ aliases = {
"t" => "test",
}
-command = ARGV.shift
-command = aliases[command] || command
+if ARGV.empty?
+ ARGV << '--help'
+ command = ''
+else
+ command = ARGV.shift
+ command = aliases[command] || command
+end
+require 'rails/commands/command'
require 'rails/commands/dev_cache'
-require 'rails/commands/commands_tasks'
-Rails::CommandsTasks.new(ARGV).run_command!(command)
+Rails::Commands::Command.run(command, ARGV)
diff --git a/railties/lib/rails/commands/command.rb b/railties/lib/rails/commands/command.rb
index fe0b77cb96..d2e1cd18b4 100644
--- a/railties/lib/rails/commands/command.rb
+++ b/railties/lib/rails/commands/command.rb
@@ -1,3 +1,5 @@
+require 'rails/commands/commands_tasks'
+
module Rails
module Commands
class Command
@@ -15,7 +17,8 @@ module Rails
if command = command_for(command_name)
command.new(argv).run(command_name)
- true # Indicate command was found and run.
+ else
+ Rails::CommandsTasks.new(argv).run_command!(task_name)
end
end
diff --git a/railties/lib/rails/commands/commands_tasks.rb b/railties/lib/rails/commands/commands_tasks.rb
index c70a2af577..7e6b49e2a3 100644
--- a/railties/lib/rails/commands/commands_tasks.rb
+++ b/railties/lib/rails/commands/commands_tasks.rb
@@ -37,9 +37,7 @@ EOT
def run_command!(command)
command = parse_command(command)
- run_with_command = Rails::Commands::Command.run(command, argv)
-
- if !run_with_command && COMMAND_WHITELIST.include?(command)
+ if COMMAND_WHITELIST.include?(command)
send(command)
end
end