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
Conversation
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. |
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.
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.
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’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 theexitProcess
setting were set tofalse
). After the callback is invoked, future calls toyargs.parse()
without a callback will follow theexitProcess
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?
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’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.
How’s this? |
@roryokane left suggestion 👍 |
the change from yargs#1647 (comment), plus rewrapping the paragraph since that’s the convention in this file
I’m okay with that. Added a commit with that change. |
@roryokane thank you for the contribution. |
The original wording “disables the
exitProcess
setting” is ambiguous. It could be wrongly interpreted to mean “disable theexitProcess
function, which allows changing of the setting”, which would then leave ambiguous the actual value used for theexitProcess
setting.