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

OptionParser does not work as expected for strict booleans #13197

Closed
spinettaro opened this issue Dec 19, 2023 · 3 comments
Closed

OptionParser does not work as expected for strict booleans #13197

spinettaro opened this issue Dec 19, 2023 · 3 comments

Comments

@spinettaro
Copy link

Elixir and Erlang/OTP versions

Erlang/OTP 26 [erts-14.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]

Elixir 1.15.6 (compiled with Erlang/OTP 26)

Operating system

Windows

Current behavior

iex(2)> OptionParser.parse(["--source", "false"], strict: [source: :boolean])
{[source: true], ["false"], []}

Expected behavior

iex(2)> OptionParser.parse(["--source", "false"], strict: [source: :boolean])
{[source: false], [], []}

I expect it to work like string

iex(1)>OptionParser.parse(["--source", "lib"], strict: [source: :string])
{[source: "lib"], [], []}
@wojtekmach
Copy link
Member

boolean are in the form --foo and --no-foo, not --foo=x:

iex(1)> OptionParser.parse(["--no-source"], strict: [source: :boolean])
{[source: false], [], []}

@spinettaro
Copy link
Author

ok thanks @wojtekmach, there was an ongoing discussion on openapi.spec repo open-api-spex/open_api_spex#579 . Just as reference

@spinettaro
Copy link
Author

however I'm going to create a PR to make it more explicit in OptionParser documentation. Thanks again for the quick reply @wojtekmach

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

No branches or pull requests

2 participants