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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcoe No problem. I will do it when I will rebase the PR for french translations, once this one is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bcoe. Mind adding some tests with command aliases?
lib/validation.js
Outdated
|
||
if (unknown.length > 0) { | ||
usage.fail(__n( | ||
'Unknown argument: %s', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-parser
were 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).