Skip to content

Parse the correlator's command line with picocli - #8

Merged
lhotari merged 1 commit into
mainfrom
cli-picocli
Sep 23, 2026
Merged

lhotari merged 1 commit into
mainfrom
cli-picocli

Conversation

@lhotari

@lhotari lhotari commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

First of the 0.5.0 correlator stack (spec: cli-picocli.md). Moves every correlator command to picocli, so the later PRs can add the transform, top, summarize and export options as typed picocli options.

Stack: #8 (this) ← #10 stack transforms ← #11 SQL-friendly export ← #12 top/summarize ← #13 README. Independent: #9 (population estimate); its --max-accounted-loss needs porting to picocli when both land — a verified resolution is on branch population-estimate-on-picocli.

What changes

  • Top-level command still correlates with the same options; correlate names it explicitly. stacks, merge, export, dump are subcommands; --dump --source FILE stays as a deprecated alias.
  • help <command> / <command> --help show each command's options and defaults; --version prints the build and the pinned async-profiler fork commit.
  • Option names, values, defaults and meanings are unchanged.
  • Behaviour change: an invalid command line now returns 64 (EX_USAGE) with the message, a "did you mean" hint and the command's usage on stderr, instead of throwing IllegalArgumentException out of run(). picocli's default of 2 would collide with "narrowed/partial". run() still never calls System.exit, and analysis failures still throw.
  • picocli 4.7.7 is embedded with a pinned SHA-256 and relocated under io.github.lhotari.jonoffcpu.correlator.internal.shaded.picocli.
  • Required options are checked by the command rather than picocli's required, because picocli reports a missing required option ahead of an unknown one, which would hide a typo such as stacks --stakc.

Verification

  • ./gradlew spotlessCheck :jonoffcpu-correlator:check passes.
  • New CommandLineTest: help snapshots per command (src/test/resources/help/*.txt), usage errors (64, usage shown, no stack trace), dump and --dump give identical output, run returns control on a failing correlation, and the README's option names and stated defaults are checked against the parser.
  • On the Pulsar broker fixture profile, stacks (default, launcher-style --package-names drop --summary --exclude-from, --stack java+kernel --reason blocked) and export (csv, jsonl) write files byte-identical to the published pre-picocli 0.5.0-SNAPSHOT JAR.
  • The shaded JAR contains no unrelocated picocli/ classes, and java -jar works on its own.

The correlator's options were parsed by hand: one stale usage string for every
command, the same "Unknown, duplicate or missing option" error thrown as a
stack trace for any mistake, and a special case for each repeatable option.
It is about to grow by some thirty options and two subcommands, so every
command is now a picocli command.

- The top-level command still correlates with the same options, and
  `correlate` names it explicitly. `stacks`, `merge`, `export` and `dump`
  are subcommands; `--dump --source FILE` is kept as a deprecated alias of
  `dump --source FILE`. `help <command>` and `<command> --help` print the
  command's options with their defaults, and `--version` the build and the
  pinned async-profiler fork commit.
- Option names, values, defaults and meanings are unchanged. Enumerated
  values are converted by type and an invalid one lists the valid values;
  comma-separated and repeatable options keep their forms and order.
- Behaviour change: an invalid command line returns 64 (EX_USAGE) with the
  message, a "did you mean" suggestion for a mistyped option and the
  command's usage on stderr, instead of throwing IllegalArgumentException
  out of run(). picocli's default of 2 would collide with "narrowed or
  partial". run() still returns the exit code and never calls System.exit,
  and a failure of the analysis itself still throws.
- picocli 4.7.7 is embedded with a pinned digest and relocated under the
  correlator's internal package, like the other bundled dependencies.

CommandLineTest checks each command's help against a snapshot in
src/test/resources/help, usage errors (exit 64, usage shown, no stack
trace), that dump and --dump agree, and that every option the README's
correlate, slicing and "Correlator options" sections name exists in the
parser with the default the table states. On the Pulsar broker fixture
profile, stacks and export write byte-identical files to the published
pre-picocli 0.5.0-SNAPSHOT.
@lhotari
lhotari merged commit 847e8b6 into main Sep 23, 2026
5 checks passed
@lhotari
lhotari deleted the cli-picocli branch September 24, 2026 13:12
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