Skip to content

fix(cli): subcommand --help, bad-PID exit code, jcmd PID-echo leakage#165

Merged
rlaope merged 1 commit into
masterfrom
fix/cli-ux-followups
May 8, 2026
Merged

fix(cli): subcommand --help, bad-PID exit code, jcmd PID-echo leakage#165
rlaope merged 1 commit into
masterfrom
fix/cli-ux-followups

Conversation

@rlaope
Copy link
Copy Markdown
Owner

@rlaope rlaope commented May 8, 2026

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:

  • `ProcessHandle.of(pid).isPresent()` check at the top β†’ `CommandExitException(1)` on miss with a clear "PID not found, run argus ps to list running JVMs" message.
  • 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. Parity verified: 530 keys Γ— 4 locales, identical key sets.

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

Case Before After
`argus threads --help` "잘λͺ»λœ PID: --help" exit 0, description + usage printed
`argus info 999999` (no such PID) empty card, exit 0 exit 1, "PID 999999 not found. Run `argus ps` to list running JVMs."
`argus info 87913` (live JVM) VM Name: "87913:" VM Name: "OpenJDK 64-Bit Server VM version 21.0.10+7-LTS"

`./gradlew compileJava :argus-cli:test` β†’ BUILD SUCCESSFUL.

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>
@rlaope rlaope merged commit 8e38b42 into master May 8, 2026
7 checks passed
@rlaope rlaope deleted the fix/cli-ux-followups branch May 8, 2026 06:31
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.

1 participant