-
-
Notifications
You must be signed in to change notification settings - Fork 24
verbose option should check for NaN #365
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
Conversation
|
See relevant yargs doco here: https://yargs.js.org/docs/#api-reference-numberkey |
|
I think this is simply not possible? 🤔 will just gives me: |
|
Just a heads-up — I’ve reverted this for now (see a7ce6aa). I’ll add it back once I confirm it’s the right approach. 🤔 The test looks good, so it's kept. :D |
|
Seems like yargs correctly separates option args from non-option args, I didn't check that error case. The other class of errors still occurs. Try these examples of buggy commands with this does not install the "s" package, but installs the project package similarly, this does not uninstall the "s" package, but uninstalls the project package this does not just compile this only loads |
|
I'm not sure how other CLIs handle this, but it seems reasonable to me. 🤔 Am I overlooking something? |
Linux commands all exit with some sort of error When NPM will use the default value for the option if present and print a warning Otherwise it will fail if the command is malformed
Yes, this is extremely frustrating UI! The issue is that the commands above make it look like |
|
Agreed! I have added the argv check in #369. 😉 I was hoping Yargs would handle this automatically (perhaps there’s an option for it), but I may need to spend some time reviewing their documentation. 🤔 |
Bug
if the argument following
-vis not a number, it is parsed asNaN, possibly corrupting the command.For example
--no-coloris interpreted as the argument to-vand parses toNaN. So--no-coloris ignored in this case.The same thing happens if the argument is a list of file patterns or anything else. E.g.
eask compile -v foo.elwill instead compile all of the files in that directory.Fix
Check: when there is a value for
-vit should be a number between0and5, otherwise immediately exit with an error.