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
program
.addOption(new Option('-p, --port <number>', 'port number').makeOptionMandatory())
.addOption(new Option('--disable-server', 'disables the server').conflicts('port'))
In the above example, if both --port and --disable-server are provided, it shows conflicting error as expected. However, if only --disable-server is provided, it throws an error that says --port was not specified.
program
.addOption(new Option('-p, --port <number>', 'port number'))
.addOption(new Option('--disable-server', 'disables the server').conflicts('port'))
If --port is not marked as mandatory, the program runs if neither option is provided.
Desired Behavior
A way to specify either of two conflicting options as mandatory. In the above example, --port should be mandatory only if --disable-server is not provided.
If both --port and --disable-server are provided, it should show conflicting error as expected.
If only --disable-server is provided, it should not throw any error.
If only --port is provided, it should not throw any error.
If neither option is provided, it should throw an error that says --port was not specified.
The text was updated successfully, but these errors were encountered:
This issue has not had much activity in six months. It isn't likely to get acted on due to this report.
Thanks for the suggestion. It is quite a lot of work robustly supporting option interactions in Commander. There are lots of possible constraints, and not many requests. Not planning to add more without clarity that it is solving a problem that enough people would benefit from.
Feel free to open a new issue if it comes up again, with new information and renewed interest.
Current Behavior
In the above example, if both
--port
and--disable-server
are provided, it shows conflicting error as expected. However, if only--disable-server
is provided, it throws an error that says--port
was not specified.If
--port
is not marked as mandatory, the program runs if neither option is provided.Desired Behavior
A way to specify either of two conflicting options as mandatory. In the above example,
--port
should be mandatory only if--disable-server
is not provided.--port
and--disable-server
are provided, it should show conflicting error as expected.--disable-server
is provided, it should not throw any error.--port
is provided, it should not throw any error.--port
was not specified.The text was updated successfully, but these errors were encountered: