GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [CLI-340] Add CommandLine.getParsedOptionValues() by Claudenw · Pull Request #334 · apache/commons-cli Conversation
|
|
|
||
| /** | ||
| * Gets a version of this {@code Option} converted to an array of a particular type. | ||
| * |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can the method return null? If so, when? What happens if the option does not exist?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
As with all the value getter methods if the option is not in the command line null is returned unless the default value is defined.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
OK, then please update the Javadoc instead of writing it up here ;-)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * @see PatternOptionBuilder | ||
| * @since 1.10.0 | ||
| */ | ||
| public <T> T[] getParsedOptionValues(final char opt) throws ParseException { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
No need to abbreviate IMO: opt -> option. Also, using opt in Javadoc makes for awkward reading.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I am following the pattern used in the class. Methods from earlier versions used opt, I elected to do the same.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Well, it's slightly awkward (to me) to read "@PARAM opt the name of the option." If 'opt' is the name, then why not call it 'name' or 'optionName'? Might as well do the best we can for new code. We can fix the rest separately if you want or do it all in this PR since.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I updated the javadoc to reflect the null or default value return as appropriate. I also updated the javadoc for the
There are all here because they follow the same pattern as getParsedOptionValue() methods. I think they need to be here because V1 supports all those access methods for getOptionValue, getParsedOptionValue, and getOptionValues. I think that in V2 I would limit each set to 4 implementations getOptionValue(Option), getOptionValue(OptionGroup), getOptionValue(Option, default), and getOptionValue(OptionGroup, default). The char and String versions are just fluff. I think that since the application has to create the Options it can keep them around and use them directly without referring to the char or String versions keys. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Hi @Claudenw
I've added 3 comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
|
||
| /** | ||
| * Gets a version of this {@code Option} converted to an array of a particular type. | ||
| * |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
OK, then please update the Javadoc instead of writing it up here ;-)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * @see PatternOptionBuilder | ||
| * @since 1.10.0 | ||
| */ | ||
| public <T> T[] getParsedOptionValues(final char opt) throws ParseException { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Well, it's slightly awkward (to me) to read "@PARAM opt the name of the option." If 'opt' is the name, then why not call it 'name' or 'optionName'? Might as well do the best we can for new code. We can fix the rest separately if you want or do it all in this PR since.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d1df605 to
a55b1ff
Compare
|
If you want me to change "opt" to "option" throughout the CommandLine class I'll do it. But having some method params be "opt" and others be "option" seems sloppy. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Hi @Claudenw |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@garydgregory Let's fix the naming in V2. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'll make the trivial changes mentioned later.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Specifically we'll need this feature from the upcoming v1.10 of commons-cli: apache/commons-cli#334 The assumption here is that the release should be available *reasonably soon*. No release date has been announced, but going by the pace of previous releases and the activity/minor version diff it seems . It was either this or patch the class implementation temporarily, doing this seemed like the better option. Collaborators/testers need to obtain a prebuilt package or build from source in the meantime.
### What changes were proposed in this pull request? This PR aims to upgrade `commons-cli` to 1.10.0 which is the first release tested with **Java 25-ea**. ### Why are the changes needed? To bring the latest improvements and bug fixes. - https://commons.apache.org/proper/commons-cli/changes.html#a1.10.0 (2025-07-30) - [Run Java 24 and 25-ea](apache/commons-cli@e6a611f) - [[CLI-333] org.apache.commons.cli.Option.Builder implements](apache/commons-cli@c9698e6) - apache/commons-cli#314 - apache/commons-cli#334 - [[CLI-341] HelpFormatter infinite loop with 0 width input](apache/commons-cli@bce0f6a) - [[CLI-343] OptionFormatter.getBothOpt() lacks validation for Options](apache/commons-cli@859d5e5) - [[CLI-344] Option.processValue() throws NullPointerException when passed](apache/commons-cli@4e0cdd0) - [[CLI-347] Options.addOptionGroup(OptionGroup) does not remove required](apache/commons-cli@42be792) - [[CLI-349] DefaultParser.parse() throws NullPointerException when options](apache/commons-cli@ff678b0) ### Does this PR introduce _any_ user-facing change? No behavior change. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #51816 from dongjoon-hyun/SPARK-53102. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
### What changes were proposed in this pull request? This PR aims to upgrade `commons-cli` to 1.10.0 which is the first release tested with Java 25-ea. ### Why are the changes needed? To bring the latest improvements and bug fixes. - https://commons.apache.org/proper/commons-cli/changes.html#a1.10.0 (2025-07-30) - [Run Java 24 and 25-ea](apache/commons-cli@e6a611f) - [[CLI-333] org.apache.commons.cli.Option.Builder implements](apache/commons-cli@c9698e6) - apache/commons-cli#314 - apache/commons-cli#334 - [[CLI-341] HelpFormatter infinite loop with 0 width input](apache/commons-cli@bce0f6a) - [[CLI-343] OptionFormatter.getBothOpt() lacks validation for Options](apache/commons-cli@859d5e5) - [[CLI-344] Option.processValue() throws NullPointerException when passed](apache/commons-cli@4e0cdd0) - [[CLI-347] Options.addOptionGroup(OptionGroup) does not remove required](apache/commons-cli@42be792) - [[CLI-349] DefaultParser.parse() throws NullPointerException when options](apache/commons-cli@ff678b0) ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #2349 from dongjoon-hyun/ORC-1968. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
### What changes were proposed in this pull request? This PR aims to upgrade `commons-cli` to 1.10.0 which is the first release tested with Java 25-ea. ### Why are the changes needed? To bring the latest improvements and bug fixes. - https://commons.apache.org/proper/commons-cli/changes.html#a1.10.0 (2025-07-30) - [Run Java 24 and 25-ea](apache/commons-cli@e6a611f) - [[CLI-333] org.apache.commons.cli.Option.Builder implements](apache/commons-cli@c9698e6) - apache/commons-cli#314 - apache/commons-cli#334 - [[CLI-341] HelpFormatter infinite loop with 0 width input](apache/commons-cli@bce0f6a) - [[CLI-343] OptionFormatter.getBothOpt() lacks validation for Options](apache/commons-cli@859d5e5) - [[CLI-344] Option.processValue() throws NullPointerException when passed](apache/commons-cli@4e0cdd0) - [[CLI-347] Options.addOptionGroup(OptionGroup) does not remove required](apache/commons-cli@42be792) - [[CLI-349] DefaultParser.parse() throws NullPointerException when options](apache/commons-cli@ff678b0) ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #2349 from dongjoon-hyun/ORC-1968. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 7a1a34f) Signed-off-by: Dongjoon Hyun <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.