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

LongOpt falsely detected as ambiguous

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3
    • 1.3.1
    • Parser
    • None
    • Windows 7, JDK 1.8.0v45

    Description

      Options options = new Options();
      options.addOption(Option.builder().longOpt("importToOpen").hasArg().argName("FILE").build());
      options.addOption(Option.builder("i").longOpt("import").hasArg().argName("FILE").build());

      Parsing "--import=FILE" is not possible since 1.3 as it throws a AmbiguousOptionException stating that it cannot decide whether import is import or importToOpen. In 1.2 this is not an issue.

      The root lies in the new DefaultParser which does a startsWith check internally.

      Attachments

        Activity

          People

            britter Benedikt Ritter
            sharrer Simon Harrer
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: