fix(cli): subcommand --help, bad-PID exit code, jcmd PID-echo leakage#165
Merged
Conversation
Three UX defects surfaced by post-release dogfooding:
1. \`argus <subcommand> --help\` printed "Invalid PID: --help"
because every subcommand parser treats the first positional as
<pid>. Add a short-circuit in ArgusCli right after the command
is resolved: if --help / -h appears in subArgs, print the
command's description plus a Usage hint and the docs URL, then
return. No per-command parser changes needed.
2. \`argus info 999999\` (non-existent PID) printed an empty info
card and exited 0, which silently passed in CI scripts. Add a
ProcessHandle.of(pid).isPresent() check at the top of the
command and throw CommandExitException(1) on miss. Numeric
parse failure now also exits 2 (was a silent return). New i18n
key \`error.pid.notfound\` added with translations in all four
locale files (530 keys Γ 4 locales, parity confirmed).
3. \`argus info <pid>\` displayed VM Name as "<pid>:" because
JdkInfoProvider took the first non-empty line of jcmd VM.version
output as vmName. jcmd echoes "<pid>:" as the first line of
every command's response; that line was being captured before
the actual VM name. Skip lines matching ^\\d+:$ explicitly.
All three verified on a live JVM:
- argus threads --help β exit 0, prints description + usage
- argus info 999999 β exit 1, prints "PID 999999 not found..."
- argus info <pid> β VM Name shows "OpenJDK 64-Bit Server VM
version 21.0.10+7-LTS" (was "<pid>:")
\`./gradlew compileJava :argus-cli:test\` β BUILD SUCCESSFUL.
Signed-off-by: rlaope <piyrw9754@gmail.com>
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.
Summary
Three UX defects surfaced by post-release dogfooding against a live JVM (PID 87913, Java 21).
1. `argus --help` printed "Invalid PID: --help"
Every subcommand parser treats the first positional as a ``. Passing `--help` to a subcommand was silently misparsed.
Fix: short-circuit in `ArgusCli` right after the command is resolved β if `--help`/`-h` appears anywhere in `subArgs`, print the command's description plus a Usage hint and the docs URL, then return. No per-command parser changes needed.
2. `argus info 999999` (non-existent PID) exited 0
The command produced an empty info card and a clean exit, which would silently pass in CI scripts.
Fix:
3. `argus info ` showed VM Name as ":"
`jcmd` echoes `:` as the first line of every command's response. `JdkInfoProvider` was taking that line as `vmName`.
Fix: skip leading lines matching `^\d+:$` before assigning to `vmName`.
Verification
`./gradlew compileJava :argus-cli:test` β BUILD SUCCESSFUL.