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

Negative numbers mistaken for options

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: CLI-2.x, Parser
    • Labels:
      None
    • Environment:

      Sun JDK 1.6, Ubuntu 7.04

      Description

      If an option has a negative numerical argument, the parser mistakes it for another option and throws an error. For example, consider:

      Argument numArg = aBuilder.withValidator(NumberValidator.getNumberInstance()).withMinimum(1).withMaximum(1).create();
      Option numOpt = oBuilder.withLongName("num").withArgument(numArg).create();
      Group options = gBuilder.withOption(numOpt).create();

      Then parsing --num -0.1 results in:

      Unexpected -0.1 while processing --num

        Attachments

        1. BugCLI150Test.java
          2 kB
          Oliver Heger
        2. patchCL150.patch
          5 kB
          Oliver Heger

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dioktos Dioktos
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: