Skip to content

Fixes for CLI-321#215

Closed
Claudenw wants to merge 3 commits into
apache:masterfrom
Claudenw:BeanUtil_Converter
Closed

Fixes for CLI-321#215
Claudenw wants to merge 3 commits into
apache:masterfrom
Claudenw:BeanUtil_Converter

Conversation

@Claudenw

Copy link
Copy Markdown
Contributor

Adds BeanUtils dependency to POM and implements TypeHandler using the BeanUtils classes.

Handles all methods that were in the original TypeHandler as well as other default classes provided by BeanUtils. Test updated to show proper parsing of types that previously were not implemented.

Includes new cli.converters package that may be better handled by BeanUtils as it moves forward to support FunctionalInterfaces.

Adds BeanUtils dependency to POM and implements TypeHandler using the BeanUtils classes.

Handles all methods that were in the original TypeHandler as well as other default classes provided by BeanUtils.
Test updated to show proper parsing of types that previously were not implemented.

Includes new cli.converters package that may be better handled by BeanUtils as it moves forward to support FunctionalInterfaces.
@Claudenw Claudenw marked this pull request as draft December 29, 2023 13:15
@Claudenw Claudenw self-assigned this Dec 29, 2023
@codecov-commenter

codecov-commenter commented Dec 29, 2023

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.27273% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.72%. Comparing base (c1f473c) to head (ad8466c).
⚠️ Report is 752 commits behind head on master.

Files with missing lines Patch % Lines
.../main/java/org/apache/commons/cli/TypeHandler.java 65.00% 13 Missing and 1 partial ⚠️
...apache/commons/cli/converters/SimpleConverter.java 62.50% 2 Missing and 1 partial ⚠️
.../main/java/org/apache/commons/cli/CommandLine.java 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #215      +/-   ##
============================================
- Coverage     93.20%   91.72%   -1.49%     
+ Complexity      570      560      -10     
============================================
  Files            21       22       +1     
  Lines          1207     1220      +13     
  Branches        215      209       -6     
============================================
- Hits           1125     1119       -6     
- Misses           46       63      +17     
- Partials         36       38       +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@garydgregory

Copy link
Copy Markdown
Member

I doubt we want to add a dependency on anything for Commons CLI, especially for what was meant to be a lightweight library. This would add Commons BeanUtils, Commons Logging, Commons Collections, and Commons Lang. It's a lot compared to JCommander and picocli...

Added getParsedOptionValues methods with default values.
Fixed som javadoc,
@Claudenw

Copy link
Copy Markdown
Contributor Author

Added getParsedOptionValue methods with default values. Switched to ConvertUtilsBean2 for conversions.

@Claudenw

Claudenw commented Dec 29, 2023

Copy link
Copy Markdown
Contributor Author

@garydgregory The code note was there and there is a lot of work in BeanUtils to make the conversions work cleanly. Might it be reasonable to make the dependency Optional so that if there is a wish to do BeanUtils (and other classes) are added, but for most cases it is not?

Alternatively, we could remove the TypeHandler implementation and add a Predicate and a Function into the Option definition. The Predicate would be used to verify that the string argument is proper for the Function (a precheck if you will) to catch the error early. The Function to convert from String to Object. This should probably be the Func interface I added as it allows Exceptions to be thrown. I think this might be a lighter weight option. If this sounds reasonable I will work on it.

@garydgregory

Copy link
Copy Markdown
Member

Hello @Claudenw
Let's see what other folks think.

@Claudenw

Claudenw commented Jan 3, 2024

Copy link
Copy Markdown
Contributor Author

Reworked without BeanUtils as pull #216 I think that is a better solution. Will move forward with whichever version the community is happiest with.

@Claudenw Claudenw closed this Jan 17, 2024
@Claudenw

Copy link
Copy Markdown
Contributor Author

Closed in favor of #216

@Claudenw Claudenw deleted the BeanUtil_Converter branch February 19, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants