fix(cli): correct displayed application name and deprecations in help text#8496
Open
chadlwilson wants to merge 2 commits into
Open
fix(cli): correct displayed application name and deprecations in help text#8496chadlwilson wants to merge 2 commits into
chadlwilson wants to merge 2 commits into
Conversation
…ersion and other commands that don't fully parse settings Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
c7b6456 to
18eb836
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the CLI’s help/usage output to display a clearer executable name (rather than the default Settings.KEYS.APPLICATION_NAME), and migrates the CLI help generation to the newer (non-deprecated) Apache Commons CLI help.HelpFormatter API. It also adjusts where the application name is initialized so it’s available earlier in the CLI lifecycle.
Changes:
- Migrate CLI help output to
org.apache.commons.cli.help.HelpFormatterand support writing help to anAppendable. - Initialize
Settings.KEYS.APPLICATION_NAMEearlier inAppvia a newdetermineName()helper. - Update CLI parser tests to validate help/version output via captured writers and Hamcrest matchers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cli/src/main/java/org/owasp/dependencycheck/CliParser.java | Switches to the new Commons CLI help formatter, changes help printing API, and tweaks several help strings. |
| cli/src/main/java/org/owasp/dependencycheck/App.java | Moves application-name initialization to the constructor (via env ODC_NAME) and updates help printing call sites. |
| cli/src/test/java/org/owasp/dependencycheck/CliParserTest.java | Refactors tests to use StringWriter/Hamcrest assertions for help output and updates parsing calls for varargs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of Change
Currently the help text tends to display
usage: Dependency-Check Corefrom the defaultSettings.KEYS.APPLICATION_NAMEwhich is mildly confusing. Generally the actual entry point isdependency-checkordependency-check.sh.The Application Name was overridden lateish in the process from env for telemetry purposes; but it is actually used earlier so moved the value setting earlier. In any case, the help/usage should probably indicate something approximating the script/executable name. I haven't gone so far as to detect the actual name from shell script; nor to disambiguate between Homebrew variant without
.sh, or running within Docker - so this is "better but not perfect".Also migrated to the newer non-deprecated
HelpFormatter. it looks basically the same as the old one:Related issues
N/A
Have test cases been added to cover the new functionality?
yes