Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-29

Options should not be able to be added more than once

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0
    • 1.1
    • CLI-1.x
    • None
    • Operating System: other
      Platform: Other

    • 14786

    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).

      Attachments

        Activity

          People

            Unassigned Unassigned
            pmularien@deploy.com Peter Mularien
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: