When I repeat some options by command line are wrongly accepted
private static void buildMyCliOptions() {
optionsMyAdd.addOption(Option.builder()
.longOpt("my-address")
.argName("property=value")
.hasArg()
.desc("Specify Address")
.required()
.build());
optionsMyAdd.addOption(Option.builder()
.longOpt("my-port")
.argName("property=value")
.hasArgs()
.valueSeparator()
.desc("Specify port")
.required()
.build());
}
tempOptions = ParseCommand.getOptionsMyAdd();
commandLine = cmdLineParser.parse(tempOptions, ParseCommand.args,true);
for instance: add --my-address=addr1 --my-address=addr2 --my-port=port1
But I would like an error for --my-address=addr2, since it is duplicated.