Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert help on unrecognized bare options #50878

Merged
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
50 changes: 0 additions & 50 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,6 @@

*Stan Lo*

* `bin/rails` now prints its help message when given an unrecognized bare
option.

__Before__

```console
$ bin/rails -v
Rails 7.2.0.alpha

$ bin/rails -V
rake, version 13.0.6

$ bin/rails -s
Running 0 tests in a single process (parallelization threshold is 50)
...

$ bin/rails -S
invalid option: -S
```

__After__

```console
$ bin/rails -v
Rails 7.2.0.alpha

$ bin/rails -V
Usage:
bin/rails COMMAND [options]

You must specify a command. The most common commands are:
...

$ bin/rails -s
Usage:
bin/rails COMMAND [options]

You must specify a command. The most common commands are:
...

$ bin/rails -S
Usage:
bin/rails COMMAND [options]

You must specify a command. The most common commands are:
...
```

*Jonathan Hefner*

* Ensure `autoload_paths`, `autoload_once_paths`, `eager_load_paths`, and
`load_paths` only have directories when initialized from engine defaults.
Previously, files under the `app` directory could end up there too.
Expand Down
10 changes: 4 additions & 6 deletions railties/lib/rails/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,14 @@ def rails_new_with_no_path?(args)

def split_namespace(namespace)
case namespace
when /^(.+):(\w+)$/
[$1, $2]
when ""
["help", "help"]
when HELP_MAPPINGS, "help"
["help", "help_extended"]
when VERSION_MAPPINGS
["version", "version"]
when "--tasks", "-T"
["", ""]
when /^-/, ""
["help", "help"]
when /^(.+):(\w+)$/
[$1, $2]
else
[namespace, namespace]
end
Expand Down
5 changes: 2 additions & 3 deletions railties/test/command/help_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ class Rails::Command::HelpIntegrationTest < ActiveSupport::TestCase
setup :build_app
teardown :teardown_app

test "prints help on unrecognized bare option" do
assert_match "You must specify a command.", rails("--zzz")
assert_match "You must specify a command.", rails("-z")
test "when passing --trace it invokes default" do
assert_match "Invoke default", rails("--trace")
end

test "prints helpful error on unrecognized command" do
Expand Down