cmd-ts icon indicating copy to clipboard operation
cmd-ts copied to clipboard

Allow `help` to exit with status other than 1

Open chuckwondo opened this issue 4 years ago • 3 comments

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.

chuckwondo avatar Apr 22 '21 20:04 chuckwondo

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

cspotcode avatar Jan 31 '23 16:01 cspotcode

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

uncenter avatar Sep 11 '23 23:09 uncenter