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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • Nightly Builds
    • 1.1
    • CLI-1.x
    • None
    • Operating System: Windows NT
      Platform: PC

    • 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
          2 kB
          Brian Egge
        2. CL51.patch
          6 kB
          Brian Egge

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: