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

fix(OptionParser): correct error message when flag has underscores #13925

Merged

Conversation

zachdaniel
Copy link
Contributor

Given this scenario:

OptionParser.parse!(["--foo_bar", "baz"], strict: [foo_bar: :string])

the current error message is:

** (OptionParser.ParseError) 1 error found!
--foo_bar : Missing argument of type string
    (elixir 1.17.2) lib/option_parser.ex:301: OptionParser.parse!/2
    iex:5: (file)

This PR fixes it to instead be

** (OptionParser.ParseError) 1 error found!
--foo_bar : Unknown option. Did you mean --foo-bar?
    (elixir 1.17.2) lib/option_parser.ex:301: OptionParser.parse!/2
    iex:5: (file)

Given this scenario:

`OptionParser.parse!(["--foo_bar", "baz"], strict: [foo_bar: :string])`

the current error message is:

```
** (OptionParser.ParseError) 1 error found!
--foo_bar : Missing argument of type string
    (elixir 1.17.2) lib/option_parser.ex:301: OptionParser.parse!/2
    iex:5: (file)
```

This PR fixes it to instead be

```
** (OptionParser.ParseError) 1 error found!
--foo_bar : Unknown option. Did you mean --foo-bar?
    (elixir 1.17.2) lib/option_parser.ex:301: OptionParser.parse!/2
    iex:5: (file)
```
@josevalim josevalim merged commit e8a6709 into elixir-lang:main Oct 23, 2024
9 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants