-
Notifications
You must be signed in to change notification settings - Fork 105
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
Throw error if unexpected option values are present #40
Comments
yes, it will throw if an unknown option is present (e.g. So, you're saying the module should throw if unexpected values are present. This sounds reasonable - I will investigate in more depth tonight, thanks. |
That's right, I think it would be very useful to throw anytime something isn't expected. The main reason I'm looking for an arg parser is to protect me from my own silly mistakes (like entering something wrong on the command line, or something having changed during refactoring), which could lead to some subtle bugs. Another thing I just noticed is that if I have an option like But if you have a boolean |
Validation (including deciding whether an option value is required) is out of scope for this module - it's too opinionated, everyone does it their own way. This module parses the command line only. Simple validation example here - you'll need to do it yourself. |
just FYI, the next version will throw by default if either an unknown option or value are found. |
Implemented in v5.0.0. |
The docs say
By default, an exception is thrown if the user sets an unknown option (one without a valid definition).
But as mentioned in #39, if your definition is{ name: 'file', defaultOption:true }
and command line is$ example one.js two.js three.js
,file
will be set toone.js
.But it should throw an error by default, because it means I've specified things on the command line that weren't expected, so I should either correct the command line or the definition rather than letting the program carry on because something could be wrong.
The text was updated successfully, but these errors were encountered: