GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [CLI-340] Add CommandLine.getParsedOptionValues() by Claudenw · Pull Request #334 · apache/commons-cli

Conversation

@Claudenw

@Claudenw Claudenw commented Nov 12, 2024 •
edited by garydgregory
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fix for CLI-340 (add getParsedOptionValues())
fix a minor formatting issue in Help javadoc.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Claudenw Claudenw self-assigned this Nov 12, 2024
@Claudenw
Claudenw marked this pull request as ready for review November 12, 2024 17:42
@Claudenw
Claudenw requested a review from garydgregory November 12, 2024 17:45
garydgregory
garydgregory requested changes Nov 12, 2024
View reviewed changes

@garydgregory garydgregory left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Claudenw

  • See exception management comment (rebase on git master svp)
  • For all Javadoc of new methods: Can the method return null? If so, when? What happens if the option does not exist?
  • Are all these APIs really needed? Couldn't we just add a minimal set following the YAGNI principle. Not my use case, so you tell me ;-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/commons/cli/CommandLine.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/main/java/org/apache/commons/cli/CommandLine.java

/**
* Gets a version of this {@code Option} converted to an array of a particular type.
*

@garydgregory garydgregory Nov 12, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Claudenw Claudenw Nov 12, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@garydgregory garydgregory Nov 12, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/commons/cli/CommandLine.java
* @see PatternOptionBuilder
* @since 1.10.0
*/
public <T> T[] getParsedOptionValues(final char opt) throws ParseException {

@garydgregory garydgregory Nov 12, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Claudenw Claudenw Nov 12, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@garydgregory garydgregory Nov 12, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Claudenw

Claudenw commented Nov 12, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

For all Javadoc of new methods: Can the method return null? If so, when? What happens if the option does not exist?

I updated the javadoc to reflect the null or default value return as appropriate. I also updated the javadoc for the getParsedOptionValue() methods.

Are all these APIs really needed? Couldn't we just add a minimal set following the YAGNI principle. Not my use case, so you tell me ;-)

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

garydgregory
garydgregory requested changes Nov 12, 2024
View reviewed changes

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/commons/cli/CommandLine.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/main/java/org/apache/commons/cli/CommandLine.java

/**
* Gets a version of this {@code Option} converted to an array of a particular type.
*

@garydgregory garydgregory Nov 12, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/commons/cli/CommandLine.java
* @see PatternOptionBuilder
* @since 1.10.0
*/
public <T> T[] getParsedOptionValues(final char opt) throws ParseException {

@garydgregory garydgregory Nov 12, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Claudenw added 4 commits November 13, 2024 00:00
@Claudenw
Fix for CLI-340
44a4fa2
@Claudenw
removed unused import
9a5ff69
@Claudenw
fixed javadocs and catch(Throwable) issues
d05f194
@Claudenw
rebased and fixed catch issue
a55b1ff
@Claudenw
Claudenw force-pushed the CLI-340_add_getParsedOptionValues branch from d1df605 to a55b1ff Compare November 13, 2024 00:04
@Claudenw
Claudenw requested a review from garydgregory November 15, 2024 16:25
@Claudenw

Claudenw commented Nov 15, 2024

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@garydgregory

garydgregory commented Nov 15, 2024

Copy link
Copy Markdown
Member

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.

Hi @Claudenw
I don't want to give you more work so I'll leave it up to you and it could be done later.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@garydgregory
Remove extra whitespace
a7f3e69
@Claudenw

Claudenw commented Nov 26, 2024

Copy link
Copy Markdown
Contributor Author

@garydgregory Let's fix the naming in V2.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

garydgregory
garydgregory approved these changes Nov 29, 2024
View reviewed changes

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@garydgregory
garydgregory merged commit 764c148 into apache:master Nov 29, 2024
@garydgregory garydgregory changed the title Fix for CLI-340 [CLI-340] CommandLine.getParsedOptionValues() Nov 29, 2024
@garydgregory garydgregory changed the title [CLI-340] CommandLine.getParsedOptionValues() [CLI-340] Add 'CommandLine.getParsedOptionValues() Nov 29, 2024
@garydgregory garydgregory changed the title [CLI-340] Add 'CommandLine.getParsedOptionValues() [CLI-340] Add CommandLine.getParsedOptionValues() Nov 29, 2024
asfgit pushed a commit that referenced this pull request Nov 29, 2024
@garydgregory
[CLI-340] Add CommandLine.getParsedOptionValues() #334
aad30ef
ann-hav added a commit to havochvatten/symphony-import that referenced this pull request Jun 27, 2025
@ann-hav
Use the 'snapshot' version of Commons-CLI
cc5f99e
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.
@ann-hav ann-hav mentioned this pull request Jun 30, 2025
SYM-684: Sensitivity matrix import, basic support havochvatten/symphony-import#2
Merged
This was referenced Aug 4, 2025
[SPARK-53102][BUILD] Upgrade commons-cli to 1.10.0 apache/spark#51816
Closed
ORC-1968: Upgrade commons-cli to 1.10.0 apache/orc#2349
Closed
dongjoon-hyun added a commit to apache/spark that referenced this pull request Aug 4, 2025
@dongjoon-hyun
[SPARK-53102][BUILD] Upgrade commons-cli to 1.10.0
e3cab3e
### 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]>
dongjoon-hyun added a commit to apache/orc that referenced this pull request Aug 4, 2025
@dongjoon-hyun
ORC-1968: Upgrade commons-cli to 1.10.0
7a1a34f
### 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]>
dongjoon-hyun added a commit to apache/orc that referenced this pull request Aug 4, 2025
@dongjoon-hyun
ORC-1968: Upgrade commons-cli to 1.10.0
7932d8e
### 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@garydgregory garydgregory garydgregory approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Claudenw Claudenw

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Claudenw @garydgregory
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.