Issue Details (XML | Word | Printable)

Key: CLI-29
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Peter Mularien
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons CLI

Options should not be able to be added more than once

Created: 23/Nov/02 06:58 AM   Updated: 15/Mar/07 04:49 PM
Return to search
Component/s: CLI-1.x
Affects Version/s: 1.0
Fix Version/s: 1.1

Time Tracking:
Not Specified

Environment:
Operating System: other
Platform: Other

Bugzilla Id: 14786


 Description  « Hide
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).



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
John Keyes added a comment - 17/Jan/03 05:31 AM
The rule is now LIFO, so the last time an Option is added that is the option
that takes precedent.