Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI-323] Added Supplier<T> defaults for getParsedOptionValue #229

Merged

Conversation

Claudenw
Copy link
Contributor

@Claudenw Claudenw commented Feb 8, 2024

@Claudenw Claudenw changed the title Added Supplier<T> defaults for getParsedOptionValue CLI-323: Added Supplier<T> defaults for getParsedOptionValue Feb 8, 2024
Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

Hi @Claudenw
Thank you for your PR.
You'll need to add tests to cover the new feature.

@Claudenw
Copy link
Contributor Author

I think I have this fixed now.

src/main/java/org/apache/commons/cli/CommandLine.java Outdated Show resolved Hide resolved

try {
return res == null ? defaultValue : (T) option.getConverter().apply(res);
return res == null ? defaultValue.get() : (T) option.getConverter().apply(res);
Copy link
Member

Choose a reason for hiding this comment

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

Hi @Claudenw
You're missing a test for when defaultValue is null.


assertEquals(123, ((Number) cmd.getParsedOptionValue(optI)).intValue());
assertEquals("foo", cmd.getParsedOptionValue(optF, "foo"));
assertEquals("foo", cmd.getParsedOptionValue(optF, ()-> "foo"));
Copy link
Member

Choose a reason for hiding this comment

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

() -> ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you know how to fix the checkstyle to look for this error I would appreciate it.

Copy link
Member

Choose a reason for hiding this comment

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

If you know how to fix the checkstyle to look for this error I would appreciate it.

Hi @Claudenw
Done. Please rebase on git master.

@Claudenw Claudenw self-assigned this Feb 15, 2024
Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

@Claudenw
TY for your updates. Please see my comment.

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9f6b23b) 91.90% compared to head (c36c7f7) 92.11%.
Report is 12 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #229      +/-   ##
============================================
+ Coverage     91.90%   92.11%   +0.21%     
- Complexity      575      586      +11     
============================================
  Files            22       22              
  Lines          1247     1255       +8     
  Branches        210      212       +2     
============================================
+ Hits           1146     1156      +10     
+ Misses           63       61       -2     
  Partials         38       38              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Claudenw Claudenw force-pushed the CLI-323_Supplier_for_getParsedOptionValue branch from 4f53cba to c36c7f7 Compare February 16, 2024 14:08
@garydgregory garydgregory changed the title CLI-323: Added Supplier<T> defaults for getParsedOptionValue [CLI-323] Added Supplier<T> defaults for getParsedOptionValue Feb 16, 2024
@garydgregory garydgregory merged commit 8eb7b89 into apache:master Feb 16, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants