Skip to content

Could have error() output to stderr? #997

@crystalfp

Description

@crystalfp

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions