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: populate correct value on yargs.parsed and stop warning on access #1412
Conversation
Can confirm that this fixes the issue I have reported originally. |
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 do think the unhandled rejection issue should be addressed before merging.
@bcoe IMO, we have a conception issue here: we should not accept async handlers in sync chained functions. I recommend:
|
What is the impact of breaking ability to chain methods? The last suggestion sounds reasonable. First one sounds like a quick workaround that will leave up to the individual yargs consumer to figure out their own way of handling async errors. |
This conception issue is what leads to your last test being so difficult to write. Any client program using async handlers and wanting to perform actions after yargs is done parsing will have the same problem: we cannot know when yargs is done parsing when using async handler. |
In fact, I think it would only prevent chaining However, the major impact would be that, when using async handlers, parse would no longer return directly the parsing results, but a promise. This would be great for people wanting to do things after parsing, but could break existing code. Next major release? |
In order not to block this fix, here is what I suggest:
@bcoe what is your opinion on this? |
@mleguen I'll take another stab at the patch with the I think we should avoid expanding on |
@mleguen ready for review 👍 |
This should address a couple minor issues that lead to #1144:
self.parsed
was being populated with anargv
instance rather than ayargsParser.detailed
instance, leading to the missing fields that raised exceptions.1.
was addressed, the help message was incorrect, becauseasync
handlers prior to this relied on state not being reset; to solve this, we now cache the help message that would be displayed at the time of a promise's invocation.self.parsed
, TypeScript executes all methods on a class, making our warning message display even though it wasn't explicitly invoked (I've reverted the warning message).TypeScript Issue:
@gajus could I get you to try this out?
fixes: #1144