Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
* Show Rake task description if command is run with -h.

Adding `-h` (or `--help`) to a Rails command that's a Rake task, now returns
the task description instead of the general Rake help.

*Petrik de Heus*

* Fix `config_for` error when there's only a shared root array.

*Loïc Delmaire*
Expand Down
1 change: 1 addition & 0 deletions railties/lib/rails/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def invoke(full_namespace, args = [], **config)
if command && command.all_commands[command_name]
command.perform(command_name, args, config)
else
args = ["--describe", full_namespace] if HELP_MAPPINGS.include?(args[0])
find_by_namespace("rake").perform(full_namespace, args, config)
end
ensure
Expand Down
9 changes: 9 additions & 0 deletions railties/test/application/rake_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ def test_gems_tasks_are_loaded_first_than_application_ones
assert_match(/^Rails version/, rails("invoke_about"))
end

test "help arguments describe rake tasks" do
task_description = <<~DESC
rails db:migrate
Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog).
DESC

assert_match task_description, rails("db:migrate", "-h")
end

test "task backtrace is silenced" do
add_to_config <<-RUBY
rake_tasks do
Expand Down