-
Notifications
You must be signed in to change notification settings - Fork 70
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
Support for required options #218
Support for required options #218
Conversation
lib/slop/parser.rb
Outdated
@@ -80,6 +80,13 @@ def parse(strings) | |||
|
|||
@arguments += ignored_args | |||
|
|||
unused_options.each do |o| | |||
if o.config[:required] && !suppress_errors? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the whole loop can be obviated when !suppress_errors?
- that is, move that expression out of the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very true. I'll fix that.
2e3f3d0
to
f21a4b4
Compare
This is a cool change. Can you teach users the |
Sure thing. Should I add it to the README, or is somewhere else better? |
@woodruffw README's best! |
(To fully answer: gem version should not be changed with a feature. That's a separate release acitivity.) |
This commit introduces support for required options, which are options that cause the parser to raise a `MissingRequiredOption` exception if not present. Options can be marked as required by passing `required: true` in their configuration, and any errors caused by missing required options can be suppressed via `suppress_errors: true`.
f21a4b4
to
311cb9f
Compare
Updated the README, plus I added
👍 |
Any update on this @olleolleolle? |
Thanks! Would it be possible to get a version released for this change? I'd love to start using it 😄 |
Thanks both. I've released 4.6.0 |
I've been needing this in one of my own projects and I saw that someone previously requested it in #203, so I went ahead and implemented it 😄
Let me know if you'd like me to update the README and/or Gem version in this PR as well.
Thanks for the awesome library!
Fixes #203