We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I would like my program to throw an error if the user tries to enter something other than an integer, e.g.:
app.js --port NOT_AN_INT
should return an Exception instead of falling back to the default.
Everything works great on either:
app.js --port 8081
8081
app.js
8080
Currently, I am forced to handle the flag values without the built-in default value parameter, i.e.:
default
.option('port', 'foo bar', 8080)
becomes:
.option('port', 'foo bar')
That way, I can validate the flag value myself, which is suboptimal. I would've preferred if args would take care of that for me, too :)
args
Can I suggest implementing any of these methods, please?
Either:
args.setOpt(args.STRICT, true)
args.setStrict(true)
args.strictType = true
preferred method
.option('port', 'foo bar', 8080, null, { strict: true })
$ app.js --port abracadabra User error: please enter a valid number for the `port` argument. $ app.js --port 8081 app.js: Ready, port 8081 was accepted.
I hope you would consider this, thanks :)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Feature Request
I would like my program to throw an error if the user tries to enter something other than an integer, e.g.:
should return an Exception instead of falling back to the default.
Everything works great on either:
app.js --port 8081
which sets the port flag to8081
app.js
which leaves it at8080
Workaround
Currently, I am forced to handle the flag values without the built-in
default
value parameter, i.e.:becomes:
That way, I can validate the flag value myself, which is suboptimal. I would've preferred if
args
would take care of that for me, too :)Possible new feature
Can I suggest implementing any of these methods, please?
Method A (Global options)
Either:
args.setOpt(args.STRICT, true)
args.setStrict(true)
args.strictType = true
Method B (Per-flag)
preferred method
Example
I hope you would consider this, thanks :)
The text was updated successfully, but these errors were encountered: