feat: introduces strictCommands() subset of strict mode#1540
Conversation
BREAKING CHANGE: if you use `.demandCommand()` or `.demandCommand(1)`, in conjunction with defining commands, `.strictCommands()` is enabled automatically.
lib/validation.js
Outdated
|
|
||
| if (unknown.length > 0) { | ||
| usage.fail(__n( | ||
| 'Unknown argument: %s', |
There was a problem hiding this comment.
Shouldn't this be "Unknown command"? The error as written looks too similar to the "unknown argument" output.
There was a problem hiding this comment.
you are 100% correct ... the reason I was thinking of using Unknown argument: was to avoid having to update all the languages yargs has been translated into, alternatively we could introduce the new phrase and let folks gradually submit translations.
There was a problem hiding this comment.
I think it's more important to be precise with error messages, even if it adds another untranslated string.
There was a problem hiding this comment.
For fr.json, this would be:
"Unknown command: %s": {
"one": "Commande inconnue : %s",
"other": "Commandes inconnues : %s"
},
The space before ":" is intentional, as we do have a space in French before every punctuation sign drawn in more than one piece (":", "?", "!", ";", etc. but not ","). I see I will have some cleanup to do in fr.json
There was a problem hiding this comment.
👍 @mleguen mind making a PR for the french translation in a separate PR, as I know we've been fixing a few issues with translations recently.
There was a problem hiding this comment.
@bcoe No problem. I will do it when I will rebase the PR for french translations, once this one is merged.
lib/validation.js
Outdated
|
|
||
| if (unknown.length > 0) { | ||
| usage.fail(__n( | ||
| 'Unknown argument: %s', |
There was a problem hiding this comment.
For fr.json, this would be:
"Unknown command: %s": {
"one": "Commande inconnue : %s",
"other": "Commandes inconnues : %s"
},
The space before ":" is intentional, as we do have a space in French before every punctuation sign drawn in more than one piece (":", "?", "!", ";", etc. but not ","). I see I will have some cleanup to do in fr.json
boneskull
left a comment
There was a problem hiding this comment.
for doing my bidding, I express to you gratitude
|
@boneskull @mleguen I think I'm going to hold off on the breaking change until the next major, based on conversations we had in the tooling chat. |
|
@boneskull when you have a moment try |
I have met your demands @boneskull
This seemed like a reasonable feature request, and I'm excited to see whether you get use out of it.
Code review appreciated.
BREAKING CHANGE: if you use.demandCommand()or.demandCommand(1), in conjunctionwith defining commands,
.strictCommands()is enabled automatically.Since the breaking changes to
yargs-parserwere for undocumented behavior (and 15.x.x was actually a regression with regards to the parsing of booleans, I'm going to try to release 15.x.x as a non-breaking change; if the candidate release seems to be breaking too many folks, we can revisit this decision).