I have a command line application with the output redirected to a file.
node app.js mandatory-argument > output.dat
If mandatory-argument is not present, commander help() function is called. Unfortunately the help text goes to the output file due to the redirection. In the commander source file, the help output is hardcoded to go to stdout (line 1147).
A workaround is to call help() this way:
const cb = (hlpText: string): string => {
process.stderr.write(hlpText);
return "";
};
program.help(cb);
But should be simpler if all commander messages go to stderr and not to stdout.
Thanks for looking!
mario
I have a command line application with the output redirected to a file.
If
mandatory-argumentis not present, commanderhelp()function is called. Unfortunately the help text goes to the output file due to the redirection. In the commander source file, the help output is hardcoded to go to stdout (line 1147).A workaround is to call
help()this way:But should be simpler if all commander messages go to stderr and not to stdout.
Thanks for looking!
mario