fix(cli): correct displayed application name and deprecations in help text#8496
fix(cli): correct displayed application name and deprecations in help text#8496chadlwilson wants to merge 3 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
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.
|
I forgot to mention that I increased the width to 100 (from 74). Doesn't seem to have ability to adjust with shell, and 74 makes the advanced help more difficult to make sense of than it already is 😅 I retained the "sort by key" that was there in the deprecated formatter to make diff easier, but we could change that, or change to retain the native ordering with the new formatter. The "disable" options end up not grouped next to their analyzers, and the inconsistent naming of some options makes it sort a bit weirdly. |
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