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

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1
    • Component/s: CLI-1.x
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

    • Bugzilla Id:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: