Java – only one parameter is required in Apache commons cli?
•
Java
I just want to know if there is any method in the Apache commons cli library that specifies that a parameter must be provided?
For example I have 2 command line arguments, but must provide one (no more or no less)? I want IP or MSISDN, but not both, not both:
OptionBuilder.hasArg(true); OptionBuilder.withDescription("Bla bla"); OptionBuilder.isrequired(false); commandLineOptions.addOption(OptionBuilder.create("ip")); OptionBuilder.hasArg(true); OptionBuilder.withDescription("Bla bla"); OptionBuilder.isrequired(false); commandLineOptions.addOption(OptionBuilder.create("msisdn"));
Thank you.
Solution
It looks like you want a required OptionGroup with two mutually exclusive option values Add the option group to commandlineoptions
(this is just a document based guess. I've never actually used the project myself...)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码