aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands/command.rb
Commit message (Collapse)AuthorAgeFilesLines
* Invert command and commands tasks reference.Kasper Timm Hansen2015-12-061-1/+4
| | | | | | | 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.
* Add class level `run` to Rails command.Kasper Timm Hansen2015-12-061-18/+12
| | | | | | | | | | | | The class level version is responsible for changing a task name to command name, then finding a command and run it if there is one. The instance level `run` then makes sure arguments have been parsed into `@options` and runs the command by sending it. `Rails::Commands::Command.run` returns true to make it work within `Rails::CommandsTask`, but won't in the future when it handles all option parsing.
* Replace `-> {}` with a proc.Kasper Timm Hansen2015-12-051-1/+1
| | | | | | | | When `parse_options_for` was called for a command that hadn't set up any option parsing with `options_for`, the `call` method would be sent to `-> {}`, which didn't like to be passed two arguments. Switch to `proc {}` which can accept several arguments.
* Remove `_instance` suffix from command.Kasper Timm Hansen2015-12-051-2/+2
| | | | | I want to streamline the wording around `command`, and not start pondering about instances.
* Default `argv` to an empty array.Kasper Timm Hansen2015-12-051-1/+1
| | | | | | | | | | | | | The `ARGV` constant in Ruby is not a string, it's an array as demonstrated by running: ``` $ ruby -e "p ARGV" => [] $ $ ruby -e "p ARGV" test/file.rb --version=2 => ["test/file.rb", "--version=2"] ```
* Spruce up `command_for`.Kasper Timm Hansen2015-12-051-4/+1
| | | | | | * Ditch the instance methods local variable. * Prefer Ruby's default nil return, and remove else branch.
* `exists?` isn't for users.Kasper Timm Hansen2015-12-051-1/+1
| | | | | | | | Checking that a command exists before running it is an implementation detail of the Rails command and Rake task world right now. Eventually I'd like to get rid of `exists?`, when I've worked out another way to fall back to run the old tasks.
* Move `command_name_for` to private section.Kasper Timm Hansen2015-12-051-4/+4
| | | | | Users shouldn't have to lookup the command name for a task. Put it in the private section, so it doesn't show up in any generated documentation.
* Add Rails command infrastructure and encapsulate development cachingChuck Callebs2015-12-041-0/+78