-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make calls to process.exit() overridable #575
Comments
The categorical call to |
of course this is opinion. @tj, are you opposed to de-opinionification of |
here's a ref to the offending code |
Doesn't the outputHelp() method cover these situations? |
Even though this issue is old I stumbled upon a similar issue where I am having some trouble. I am using Unfortunately though, when I run @tj I'd like to suggest a change wherein all calls to |
Just bumping this because I'm of the same opinion. I develop a constantly-running server app, and I can run commands on it by socketing in to an IPC handle and then parsing commands using commander. I would be happier if commander didn't call process.exit, tearing down the app. I second @bolinfest and @nearautomata in saying that the exit behaviour could be injected; or perhaps that parse() could return an |
Did someone find any way to override code or at least ignore the exit without changing the code of commander? |
I agree with this issue. If you want to have a live-chat bot (e.g. for Slack or Discord) one doesn't need the bot to "clean exit". It really came as a surprise to me, that this library shuts down your app like that. Please fix this unacceptable behaviour, as it breaks many use cases. I've addressed this in further detail here: #934 @tj Please consider making the |
I have started work on an exit override: #945 (comment) |
There are improvements on the develop branch for the next release (#1040). |
v4.0.0-0 prerelease published: #1067 |
v4.0.0 has been released. |
In general, library code should never call
process.exit()
. Instead, clients of the library should decide how they want to handle errors.In particular, tying
process.exit(0)
to--help
seems particularly bad. For a CLI parser, this may be a reasonable default, but this behavior should at least be overridable.I am trying to build a daemon running on a UNIX domain socket that takes requests and uses commander to parse arguments just as it would if it were running in non-daemon mode. Given the way commander works today, passing
--help
has the side-effect of tearing down my daemon.I have similar issues where commander makes calls to
process.stdout.write()
that are writing to the "wrong" stdout, from my perspective. I think the best way to secure things as a library is to remove all direct references toprocess
fromindex.js
and make all of its behavior injectable. It can still default to what it does today, but it should be overridable.The text was updated successfully, but these errors were encountered: