From 52f2f9810eaf3d385ca3eef8ed6fc62e4fd1f7d3 Mon Sep 17 00:00:00 2001 From: Dharam Gollapudi Date: Fri, 13 Nov 2015 16:58:51 -0800 Subject: Implement Rake proxy for Rails' command line interface. Allows any Rake task to be run through `bin/rails` such as `bin/rails db:migrate`, `bin/rails notes` etc. The Rake tasks are appended to Rails' help output, and blend in as standard commands. --- guides/source/initialization.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'guides/source/initialization.md') diff --git a/guides/source/initialization.md b/guides/source/initialization.md index ebe1cb206a..1215931465 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -139,7 +139,8 @@ aliases = { "c" => "console", "s" => "server", "db" => "dbconsole", - "r" => "runner" + "r" => "runner", + "t" => "test" } command = ARGV.shift @@ -158,19 +159,20 @@ defined here to find the matching command. ### `rails/commands/command_tasks.rb` -When one types an incorrect rails command, the `run_command` is responsible for -throwing an error message. If the command is valid, a method of the same name -is called. +If the command is part of the COMMAND_WHITELIST, a method of the same name is called, +if not we proxy it to rake. ```ruby COMMAND_WHITELIST = %w(plugin generate destroy console server dbconsole application runner new version help) def run_command!(command) command = parse_command(command) + if COMMAND_WHITELIST.include?(command) send(command) else - write_error_message(command) + ARGV.unshift(command) + send(:rake) end end ``` -- cgit v1.2.3