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

Add function similar to getOptionValue() that returns last value

    Details

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

      Description

      Often, you can invoke command with the same option multiple time. For example
      java -cp test1 -cp test2

      even though the option only accepts one value.
      I believe, that the majority of programs then use the last value (test2 in this case).
      However, getOptionValue() return the first value for some weired reason.

      I believe, you should add a function called getLastOptionValue() (in class CommandLine) and getLastValue() (in class Option) to allow easy access to the last value.

        Activity

        Hide
        sven.koehler Sven added a comment -

        Also, the documentation of getOptionValue() doesn't even mention whether the last or first value is returned. This should be fixed as well.

        Show
        sven.koehler Sven added a comment - Also, the documentation of getOptionValue() doesn't even mention whether the last or first value is returned. This should be fixed as well.
        Hide
        tn Thomas Neidhart added a comment -

        In r1444365 a clarification has been added to the javadoc of CommandLine.getOptionValue methods.

        To retrieve all specified arguments for an option, use the CommandLine.getOptionValues() method, which returns an array of all specified arguments.

        Show
        tn Thomas Neidhart added a comment - In r1444365 a clarification has been added to the javadoc of CommandLine.getOptionValue methods. To retrieve all specified arguments for an option, use the CommandLine.getOptionValues() method, which returns an array of all specified arguments.

          People

          • Assignee:
            Unassigned
            Reporter:
            sven.koehler Sven
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development