提交 93ee1b10 编写于 作者: K Kasper Timm Hansen

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.
上级 88d194ea
ARGV << '--help' if ARGV.empty?
aliases = {
"g" => "generate",
"d" => "destroy",
......@@ -10,10 +8,15 @@
"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)
require 'rails/commands/commands_tasks'
module Rails
module Commands
class Command
......@@ -15,7 +17,8 @@ def self.run(task_name, argv)
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
......
......@@ -37,9 +37,7 @@ def initialize(argv)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册