fix: failed command usage string is missing arg descriptions and optional args#2105
Merged
bcoe merged 4 commits intoyargs:mainfrom Jan 9, 2022
jly36963:fix-failed-default-command-usage-string
Merged
fix: failed command usage string is missing arg descriptions and optional args#2105bcoe merged 4 commits intoyargs:mainfrom jly36963:fix-failed-default-command-usage-string
bcoe merged 4 commits intoyargs:mainfrom
jly36963:fix-failed-default-command-usage-string
Conversation
Contributor
Author
|
@bcoe However, I don't think I understand the comment above that block. Line 312 in 59a86fb If I understand it correctly, then the usage shouldn't contain anything from the default command, eg: |
bcoe
reviewed
Jan 9, 2022
| descriptions, | ||
| } = frozen); | ||
| // Addresses: https://github.com/yargs/yargs/issues/2030 | ||
| if (defaultCommand) { |
Member
There was a problem hiding this comment.
I like that you just made this a boolean setting rather than adding a new method.
bcoe
approved these changes
Jan 9, 2022
Member
|
@jly36963 as always, thank you for the contribution. |
This was referenced Sep 6, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses:
#2030
#2102
Problem
The usage from a failed default command is missing the following:
Example
In the code and output below, you will see that the failed default command is missing descriptions and optional arguments. (I omitted the command usage output, as it's not part of the issue.)
Solution
I'm still trying to figure out the fix for this. I wrote a unit test that should demonstrate the incongruity between expected/actual behavior.
Notes
This is what I've found so far, concerning failed default commands and the parts that are missing from the usage output:
usage.failif validation failsyargs.showHelp('error')this.#usage.showHelpemit(self.help())I logged
descriptionsat multiple points in the yargs process, and it's strange because arg1/arg2 show up in descriptions, but later get removed. I don't know if that's a result of resetting or using cached values, but something is wonky there. I'll keep trying to figure out why they get removed.