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.

        Activity

        Hide
        britter Benedikt Ritter added a comment -

        Thank you for the report. Patches welcome!

        Show
        britter Benedikt Ritter added a comment - Thank you for the report. Patches welcome!
        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user simonharrer opened a pull request:

        https://github.com/apache/commons-cli/pull/2

        Fixes CLI-252 exact matches are not ambiquous

        https://issues.apache.org/jira/browse/CLI-252

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/simonharrer/commons-cli fix-CLI-252

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/commons-cli/pull/2.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #2



        Show
        githubbot ASF GitHub Bot added a comment - GitHub user simonharrer opened a pull request: https://github.com/apache/commons-cli/pull/2 Fixes CLI-252 exact matches are not ambiquous https://issues.apache.org/jira/browse/CLI-252 You can merge this pull request into a Git repository by running: $ git pull https://github.com/simonharrer/commons-cli fix- CLI-252 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/commons-cli/pull/2.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2
        Hide
        sharrer Simon Harrer added a comment -
        Show
        sharrer Simon Harrer added a comment - Patch available in https://github.com/apache/commons-cli/pull/2
        Hide
        britter Benedikt Ritter added a comment -
        $ svn ci -m "CLI-252: LongOpt falsely detected as ambiguous. This closes #2 from github. Thanks to Simon Harrer."
        Sending        src/changes/changes.xml
        Sending        src/main/java/org/apache/commons/cli/Options.java
        Adding         src/test/java/org/apache/commons/cli/bug/BugCLI252Test.java
        Transmitting file data ...
        Committed revision 1684315.
        

        Thank you!

        Show
        britter Benedikt Ritter added a comment - $ svn ci -m "CLI-252: LongOpt falsely detected as ambiguous. This closes #2 from github. Thanks to Simon Harrer." Sending src/changes/changes.xml Sending src/main/java/org/apache/commons/cli/Options.java Adding src/test/java/org/apache/commons/cli/bug/BugCLI252Test.java Transmitting file data ... Committed revision 1684315. Thank you!
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/commons-cli/pull/2

        Show
        githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/commons-cli/pull/2

          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:

              Development