-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
bugCommander is not working as intendedCommander is not working as intended
Description
I'm trying to use the option conflicts configuration, but it doesn't appear to catch the conflicts.
const { program, Option } = require("commander");
const handleAction = (command) => {
const options = program.opts();
//options.exact && (options.wild || options.all) && console.log("conflict");
console.log(
`${command.name()} with options ${JSON.stringify(program.opts())}`
);
};
//Global options
program
.addOption(
new Option("-a, --all", "all wallets").conflicts(["exact", "wild"])
)
.addOption(
new Option("-x, --exact <name>", "exact wallet name").conflicts([
"all",
"wild",
])
)
.addOption(
new Option("-w, --wild <partial>", "wild card").conflicts(["all", "exact"])
)
.option("-p, --password <password>");
//Sub commands
program.command("claim").action((options, command) => {
handleAction(command);
});
program.parse();
When I run with:
node commands.js claim -a -x OG
The result is:
claim with options {"all":true,"exact":"OG"}
Have I configured it incorrectly? Also tried specifying just the short names. Same result.
Thanks.
Metadata
Metadata
Assignees
Labels
bugCommander is not working as intendedCommander is not working as intended