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

LongOpt falsely detected as ambiguous

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.3.1
    • Component/s: Parser
    • Labels:
      None
    • Environment:

      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

            • Assignee:
              britter Benedikt Ritter
              Reporter:
              sharrer Simon Harrer
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: