From 93ee1b1021c974b9dd5ceee7166698af902cf34c Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sun, 6 Dec 2015 14:06:07 +0100 Subject: 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. --- railties/lib/rails/commands.rb | 15 +++++++++------ railties/lib/rails/commands/command.rb | 5 ++++- railties/lib/rails/commands/commands_tasks.rb | 4 +--- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'railties/lib/rails') 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 -- cgit v1.2.3