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

[cli] Parameter value "-something" misinterpreted as a parameter

    Details

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

      Operating System: Windows NT
      Platform: PC

    • Bugzilla Id:
      34831

      Description

      If a parameter value is passed that contains a hyphen as the (delimited) first
      character, CLI parses this a parameter. For example using the call
      java myclass -t "-something"
      Results in the parser creating the invalid parameter -o (noting that it is
      skipping the 's')

      My code is using the Posix parser as follows
      Options options = buildCommandLineOptions();
      CommandLineParser parser = new PosixParser();
      CommandLine commandLine = null;
      try {

      commandLine = parser.parse(options, args);
      }
      catch (ParseException e) {

      System.out.println("Invalid parameters. " + e.getMessage() + NEW_LINE);
      System.exit(EXIT_CODE_ERROR);
      }

      This has been tested against the nightly build dated 20050503.

        Attachments

        1. CL51.patch
          6 kB
          Brian Egge
        2. CL51.patch
          2 kB
          Brian Egge
        There are no Sub-Tasks for this issue.

          Activity

            People

            • Assignee:
              bayard Henri Yandell
              Reporter:
              nigel_king@mlc.com.au Nigel King
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: