Skip to content
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

fix help text not displaying #446

Merged
merged 2 commits into from
Dec 3, 2024
Merged

fix help text not displaying #446

merged 2 commits into from
Dec 3, 2024

Conversation

echo-bravo-yahoo
Copy link
Contributor

No description provided.

Comment on lines -37 to -52
// this case only occurs when an error is thrown and not caught
if (!argv) {
// we give yargs _just_ enough information that we can use it to parse
// out the verbosity flags needed by the logger
argv = yargs(hideBin(process.argv))
.options({
verboseComponent: {
type: "array",
default: [],
},
verbosity: {
type: "number",
default: 0,
},
})
.version(false).argv;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the config parser runs well before the rest of yargs. as far as i can tell, it looks something like:

  1. start parsing argv
  2. run config parser
  3. check if it's a --help command
  4. run before validation middleware
  5. run validation
  6. run after validation middleware
  7. finished parsing argv
  8. run command handler

anyway, this block was previously only hit on errors, and exists to pull the populate verbosity so we can decide if we should log the full error stack. now, though, log is called by config parser - which also happens before argv are available. for whatever reason, calling yargs...argv is sticky and clobbers the help it would otherwise generate.

so, in the error case, we can instead read the argv out of the parsed yargs object, and do nothing in the config parser case.

@echo-bravo-yahoo echo-bravo-yahoo marked this pull request as ready for review December 2, 2024 22:07
@echo-bravo-yahoo echo-bravo-yahoo requested a review from a team as a code owner December 2, 2024 22:07
Copy link
Contributor

@ptpaterson ptpaterson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, undefined is never > nor < nor = any number. So I think you could do argv?.verbosity >= verbosity, but I absolutely hate truthiness, so I like it this way instead 😄.

@ecooper ecooper merged commit daf9815 into v3 Dec 3, 2024
4 checks passed
@ecooper ecooper deleted the fix-help-text branch December 3, 2024 21:02
@cleve-fauna cleve-fauna mentioned this pull request Dec 5, 2024
This was referenced Dec 6, 2024
@cleve-fauna cleve-fauna mentioned this pull request Dec 13, 2024
@wildemat wildemat mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants