-
Notifications
You must be signed in to change notification settings - Fork 22
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
Way to disable built-in default values #53
Comments
Just a couple of issues to be aware of: getopts(["-atabc"], {
string: ["t"],
}) //=> { _:[], a:true, t:"abc" } Similarly, getopts(["-t", "alpha"], {
boolean: ["t"],
}) //=> { _:["alpha"], t:true } As long as we don't interfere with that, I'm down for it. We could even make it the default behavior since |
I just took a quick glance, but putting an Lines 189 to 190 in 35dfad8
|
Looks like a clean solution! Do you happen to know what other parsers out there, e.g., yargs do? If a similar feature/option already exists in another parser it may be worthwhile naming ours the same or similarly (although not necessarily). |
After a quick test, it seems that by default, |
getopts
assigns default values to string (''
), number (0
) and boolean (false
) options.Issues:
With modern JS syntaxes like destructuring, default values and the nullish coalescing operator (
??
), I don't see much use default values being handled bygetopts
in the future.In the meantime, a simple option like
builtInDefaults: false
would be good enough to cover my use case 🙂What's your opinion on this?
The text was updated successfully, but these errors were encountered: