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

Allow for --no-foo as alternative to --/foo #5011

Merged
merged 1 commit into from
Aug 8, 2022
Merged

Conversation

lizmat
Copy link
Contributor

@lizmat lizmat commented Aug 1, 2022

By setting the new "allow-no" flag in %*SUB-MAIN-OPTS:

$ raku -r 'sub MAIN(|c) { say c }; my %*SUB-MAIN-OPTS=:allow-no' --no-foo
(:foo(Bool::False))

as opposed to:

$ raku -r 'sub MAIN(|c) { say c }' --no-foo
(:no-foo(Bool::True))

By setting the new "allow-no" flag in %*SUB-MAIN-OPTS:

  $ raku -r 'sub MAIN(|c) { say c }; my %*SUB-MAIN-OPTS=:allow-no' --no-foo
  \(:foo(Bool::False))

as opposed to:

  $ raku -r 'sub MAIN(|c) { say c }' --no-foo
  \(:no-foo(Bool::True))
Copy link
Member

@jnthn jnthn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems safe given it's opt-in, and a common enough convention to offer it out of the box.

@Leont
Copy link
Contributor

Leont commented Aug 8, 2022

Over time, the built-in argument parser is getting more and more into line with Getopt::Long 🙂

@lizmat
Copy link
Contributor Author

lizmat commented Aug 8, 2022

Is that a documented feature of Getopt::Long? I couldn't find it in the docs, but then again I may have not looked closely enough

@Leont
Copy link
Contributor

Leont commented Aug 8, 2022

Is that a documented feature of Getopt::Long? I couldn't find it in the docs, but then again I may have not looked closely enough

All arguments marked as negatable have a --no-*. It can be done by giving a Bool a default value or using is option('!')

@lizmat lizmat merged commit 61617b1 into master Aug 8, 2022
@lizmat lizmat deleted the lizmat-allow-no branch August 8, 2022 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants