You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want write all output with winston module. I trying to add the configureOutput method before or after all commands. It affects only command which addded with the command method. Live example
...
// Init commander.
const program = new Command()
.name("CLI")
.configureOutput({
writeOut: (str) => {
console.log("writeOut:", str);
},
writeErr: (str) => {
console.log("writeErr:", str);
console.log("Test passed!");
},
});
// Add one command, main way.
const command_test_as_var = program.createCommand("test_as_var");
command_test_as_var.addOption(
new Option("--arg <arg>", "Some word.").makeOptionMandatory()
)
command_test_as_var.action(action);
program.addCommand(command_test_as_var);
// Add second command.
program
.command("test_inline")
.addOption(
new Option("--arg <arg>", "Some word.",).makeOptionMandatory()
)
.action(action);
...
I have:
~/Commander-Async-Issue$ node ./output_issue.js test_as_var
error: required option '--arg <arg>' not specified
~/Commander-Async-Issue$ node ./output_issue.js test_inline
writeErr: error: required option '--arg <arg>' not specified
Test passed!
Expecting:
~/Commander-Async-Issue$ node ./output_issue.js test_as_var
writeErr: error: required option '--arg <arg>' not specified
Test passed!
~/Commander-Async-Issue$ node ./output_issue.js test_inline
writeErr: error: required option '--arg <arg>' not specified
Test passed!
I can call configureOutput for each command and then everything works as expected, but according to #1770 I am thinking this is a bug.
The text was updated successfully, but these errors were encountered:
For safety, .addCommand() does not copy the inherited settings from the parent command in case they were written independently with different expectations about the settings and the settings break the added command.
There is a helper routine .copyInheritedSettings() for copying the settings when it is wanted:
I want write all output with winston module. I trying to add the configureOutput method before or after all commands. It affects only command which addded with the command method. Live example
I have:
Expecting:
I can call configureOutput for each command and then everything works as expected, but according to #1770 I am thinking this is a bug.
The text was updated successfully, but these errors were encountered: