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

docs(api): explain .parse()’s exiting behavior more clearly #1647

Merged
merged 5 commits into from May 27, 2020

Conversation

roryokane
Copy link
Contributor

The original wording “disables the exitProcess setting” is ambiguous. It could be wrongly interpreted to mean “disable the exitProcess function, which allows changing of the setting”, which would then leave ambiguous the actual value used for the exitProcess setting.

The original wording “disables the `exitProcess` setting” is ambiguous. It could be wrongly interpreted to mean “disable the `exitProcess` function, which allows changing of the setting”, which would then leave ambiguous the actual value used for the `exitProcess` setting.
docs/api.md Outdated
***Note:*** Providing a callback to `parse()` disables the [`exitProcess` setting](#exitprocess) until after the callback is invoked.
***Note:*** Providing a callback to `parse()` disables automatic exiting of the
process (as if the [`exitProcess` setting](#exitprocess) were set to `false`)
until after the callback is invoked.
Copy link
Member

Choose a reason for hiding this comment

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

rather than saying "until after the callback is invoked", perhaps something along the lines of, the Node process will exit normally, i.e., when the event loop is empty, or an error is thrown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m afraid I don’t understand the relevance of the Node process exiting normally, or why it’s unnecessary to say “until after the callback is invoked”.

This is how I understand the phrase “until after the callback is invoked”:

Providing a callback to parse() disables automatic exiting of the process (as if the exitProcess setting were set to false). After the callback is invoked, future calls to yargs.parse() without a callback will follow the exitProcess setting – i.e. they might exit automatically if an error is encountered during parsing.

Is that an accurate reading? How is normal Node exiting behavior relevant?

Copy link
Member

Choose a reason for hiding this comment

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

I’m afraid I don’t understand the relevance of the Node process exiting normally

Because this is the way exitProcess(false) works: yargs no longer exits the process, and if you have some code after your call to parse(), it is executed by node.

If this code calls parse() again without exitProcess(false), then, yes, yargs will exit the process. Otherwise, the process will be exited normally by node after all code is executed.

Your first wording could be understood as yargs automatically exiting the process after the callback was ran (so before the code after parse() was executed), which is not the case.

@roryokane
Copy link
Contributor Author

How’s this?

docs/api.md Outdated Show resolved Hide resolved
@bcoe
Copy link
Member

bcoe commented May 24, 2020

@roryokane left suggestion 👍

the change from yargs#1647 (comment), plus rewrapping the paragraph since that’s the convention in this file
@roryokane
Copy link
Contributor Author

I’m okay with that. Added a commit with that change.

@bcoe bcoe merged commit be9da50 into yargs:master May 27, 2020
@bcoe
Copy link
Member

bcoe commented May 27, 2020

@roryokane thank you for the contribution.

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.

None yet

3 participants