-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
// 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; |
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.
the config parser runs well before the rest of yargs. as far as i can tell, it looks something like:
- start parsing argv
- run config parser
- check if it's a --help command
- run before validation middleware
- run validation
- run after validation middleware
- finished parsing argv
- 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.
24b6b43
to
4b2d960
Compare
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.
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 😄.
No description provided.