Details
Description
One should not be able to add the same Option (by unique ID) to the Options
object multiple times. Specifically, this causes a problem with required options.
I performed the following set of steps, which resulted in the behavior that the
option I specified was not marked as set in the Parser.requiredOptions List:
Option o = OptionBuilder.isRequired().withDescription("test").create("test");
Options opts = new Options();
opts.addOption(o);
opts.addOption(o);
Now, if I parse a command line like this:
{program}-test
I get an MissingArgumentException thrown from Parser.checkRequiredOptions that
the option was not found. This is because the option has been added to
requiredOptions twice.
I believe that one should not be able to add the same option twice (or this
behavior should be ... er .... optional).