I'm trying to define some options, which should be mutually exclusive, but the .conflicts option specified on top-level seems to be ignored when a command is provided. Is this the intended behaviour?
Examples
v1
// v1: Plain .conflicts
require('yargs')
.command({
command: 'a'
})
.option('b', {
global: true
})
.option('c', {
global: true
})
.conflicts('b', 'c')
.argv;
If I run v1 with no command, yargs stop me. But if I add the command, it doesn't:
$ node v1.js -b 2 -c 3
Arguments b and c are mutually exclusive
$ node v1.js a -b 2 -c 3
# No output
v2
// v2: Explicitly added .conflicts to command builder
require('yargs')
.command({
command: 'a',
builder: function (yargs) {
return yargs
.conflicts('b', 'c');
}
})
.option('b', {
global: true
})
.option('c', {
global: true
})
.conflicts('b', 'c')
.argv;
In v2 yargs stops me:
$ node v2.js -b 2 -c 3
Arguments b and c are mutually exclusive
$ node v2.js a -b 2 -c 3
Arguments b and c are mutually exclusive