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

MissingOptionException.getMessage() changed from CLI 1.0 > 1.1

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2
    • Component/s: CLI-1.x
    • Labels:
      None

      Description

      The MissingOptionException.getMessage() string changed from CLI 1.0 > 1.1.

      CLI 1.0 was poorly formatted but readable:
      Missing required options: -format-source-properties

      CLI 1.1 is almost unreadable:
      Missing required options: formatsourceproperties

      In CLI 1.0 Options.addOption(Option) prefixed the stored options with a "-" and in CLI 1.1 it doesn't.

      I would suggest changing Parser.checkRequiredOptions() to add the options to the error message with a prefix of " -":

      OLD:
      // loop through the required options
      while (iter.hasNext())

      { buff.append(iter.next()); }

      NEW:
      // loop through the required options
      while (iter.hasNext())

      { buff.append(" -" + iter.next()); }

      Resulting in:
      Missing required options: -format -source -properties

        Activity

        Hide
        alexandru Alexandru Luchian added a comment -

        Also, there are no spaces between option names.

        It should be something like:

        NEW:
        // loop through the required options
        while (iter.hasNext())

        { buff.append(" -" + iter.next() + " "); }

        OR

        NEW:
        // loop through the required options
        while (iter.hasNext())

        { buff.append(iter.next() + " "); }
        Show
        alexandru Alexandru Luchian added a comment - Also, there are no spaces between option names. It should be something like: NEW: // loop through the required options while (iter.hasNext()) { buff.append(" -" + iter.next() + " "); } OR NEW: // loop through the required options while (iter.hasNext()) { buff.append(iter.next() + " "); }
        Hide
        bayard Henri Yandell added a comment - - edited

        Agreed on the whitespace. I don't see why it shouldn't be:

        Missing required options: format, source, properties

        Show
        bayard Henri Yandell added a comment - - edited Agreed on the whitespace. I don't see why it shouldn't be: Missing required options: format, source, properties
        Hide
        bayard Henri Yandell added a comment -

        svn ci -m "Adding comma delimited whitespace to the exception message that lists missing required options as requested in CLI-149. I didn't add the requested -, as it could be – or some other prefix. Unit tests also added. "

        Sending src/java/org/apache/commons/cli/Parser.java
        Sending src/test/org/apache/commons/cli/OptionsTest.java
        Sending src/test/org/apache/commons/cli/ParseRequiredTest.java
        Transmitting file data ...
        Committed revision 654431.

        Show
        bayard Henri Yandell added a comment - svn ci -m "Adding comma delimited whitespace to the exception message that lists missing required options as requested in CLI-149 . I didn't add the requested -, as it could be – or some other prefix. Unit tests also added. " Sending src/java/org/apache/commons/cli/Parser.java Sending src/test/org/apache/commons/cli/OptionsTest.java Sending src/test/org/apache/commons/cli/ParseRequiredTest.java Transmitting file data ... Committed revision 654431.

          People

          • Assignee:
            Unassigned
            Reporter:
            nathann@objectfx.com Nathan Niesen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development