cmd-ts
cmd-ts copied to clipboard
Allow `help` to exit with status other than 1
I would like to be able to exit with status 0 when specifying -h or --help, but it appears that 1 is hard-coded as the exit status. Perhaps providing a means for specifying a different exit status when help is invoked would be nice.
Are there any workaround until this is added to cmd-ts? Catching and detecting the help error and changing process.exitCode or something?
Also, I'm curious, why was it implemented this way? I've done some testing, and most CLIs exit with code 0 when you run --help.
Here are a few commands I tested, all exit with code 0:
kubectl --help
helm --help
cp --help
ls --help
cat --help
node --help
Looks like this is the line that needs to be changed:
https://github.com/Schniz/cmd-ts/blob/e6759073041f19e07906087ddcc15a416361ec7c/src/circuitbreaker.ts#L35
You can see that -h, --help exits with code 1 while -v, --version exits with code 0:
https://github.com/Schniz/cmd-ts/blob/e6759073041f19e07906087ddcc15a416361ec7c/src/circuitbreaker.ts#L33-L39