Skip to content

Simplify dynamic clap configuration in benchmark_runner cli#8

Open
alamb wants to merge 1 commit into
Omega359:benchmark-runner-info-queryfrom
alamb:alamb/simplify-benchmark-runner-cli
Open

Simplify dynamic clap configuration in benchmark_runner cli#8
alamb wants to merge 1 commit into
Omega359:benchmark-runner-info-queryfrom
alamb:alamb/simplify-benchmark-runner-cli

Conversation

@alamb
Copy link
Copy Markdown

@alamb alamb commented May 26, 2026

Which issue does this PR close?

Rationale for this change

The dynamic clap configuration in benchmarks/src/benchmark_runner/cli.rs was confusing to me and I found I could simplify it with fewer levels of indirection

Here is a proposal for your consideration

Collapse the per-suite help-visibility machinery into a single command
builder. The `SelectorSuiteOptions` / `SelectorOptionVisibility` /
`SelectorCommand` types and the `build_cli_for_args_with_options` ->
`build_cli_with_help_options` -> `build_cli_with_selector_options` chain
existed only to narrow `info <suite> --help` / `query <suite> --help` to
the selected suite's options. That narrowing is redundant with the
richer curated `info <suite>` view rendered manually in output.rs, and
the narrowing behavior was untested.

Now `build_cli` registers the union of all suites' options once under a
single `Suite Options` heading. Suite-defined options are still
registered dynamically with clap, and multi-character short aliases
(e.g. `-sf`) are still normalized to their long form before parsing.

The only behavior change: `info <suite> --help` / `query <suite> --help`
list the union of suite options rather than just the selected suite's.
The curated `info <suite>` output is unchanged.

Net: removes 3 types and several builder/helper functions
(~180 fewer lines in cli.rs). Binary builds, clippy is clean, and all
benchmark_runner tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Author

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Omega359 I may be misunderstanding, but here is one proposal for simpification


/// Suite-option visibility used while constructing selector subcommands.
#[derive(Clone, Copy)]
enum SelectorSuiteOptions<'a> {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was a lot of extra runaround to avoid printing a few help items -- I think keeping the code simpler will be good

pub suite_options: BTreeMap<String, String>,
}

/// Per-subcommand suite-option visibility used for help rendering.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a lot of code that just seems to set a field on visibility 🤔

@alamb alamb marked this pull request as ready for review May 26, 2026 18:55
@alamb alamb force-pushed the alamb/simplify-benchmark-runner-cli branch from cddaf45 to 0dbdcd5 Compare May 26, 2026 19:00
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