No usage info is printed, but the documentation says it would
mike-lischke opened this issue · comments
I'm trying commander
the first time following the the first example in the readme file:
import { program } from "commander";
program
.option('--first')
.option('-s, --separator <char>');
program.parse();
This does not print anything, just exists the script. Node.js only shows the standard exit code:
/opt/homebrew/bin/node --no-warnings=ExperimentalWarning --loader ts-node/esm src/index.ts --fits /Volumes/Extern/Work/projects/grammars-v4/acme/
Process exited with code 1
I expected to see the message:
error: unknown option '--fits'
like in the example. Is the documentation wrong or what else could I miss here?
With an exit override it is possible to handle the error and print the description from commander
. I guess this should be mentioned in the documentation.
program
.option("--first")
.option("-s, --separator <char>")
.exitOverride((err) => {
console.error(err.message);
process.exit(1);
});
I tested also in a standalone terminal (not the debugger terminal from VS Code) and there everything was fine, which lead me to search for problems with the VS Code debugger output and found this issue. So it's not the fault of commander
. Sorry for bothering you.