perf(cli): defer bootstrap command tree - #11684
Conversation
📝 WalkthroughWalkthroughThe CLI now defers construction of the bootstrap command tree during normal parsing. It expands the tree for execution, validation, help rendering, usage generation, and command-effect tests while preserving bootstrap flags. ChangesDeferred bootstrap command
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant DeferredBootstrap
participant Bootstrap
participant CommandTreeInspector
CLI->>DeferredBootstrap: parse bootstrap arguments
DeferredBootstrap->>Bootstrap: delegate nested arguments
DeferredBootstrap->>Bootstrap: preserve dry_run and yes
DeferredBootstrap->>Bootstrap: run command
CommandTreeInspector->>CLI: request command tree
CLI->>CommandTreeInspector: expand deferred bootstrap
CommandTreeInspector->>CLI: inspect full bootstrap tree
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryDefers construction of the nested bootstrap command tree during ordinary CLI startup while explicitly expanding it for full-tree introspection.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (4): Last reviewed commit: "perf(cli): defer bootstrap command tree" | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/cli/bootstrap.rs (1)
40-80: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd direct test coverage for
dry_run/yespropagation throughDeferredBootstrap.The
FromArgMatchesimpl is hand-written, not derived, and it carries the flag-preservation logic that this PR is centered on. The existing testtest_bootstrap_command_tree_is_deferred_until_parsinginsrc/cli/mod.rsonly checks thatmise bootstrap status --jsonparses without error. It does not assert thatDeferredBootstrap::from_arg_matches(orupdate_from_arg_matches) actually setsdry_run/yestotruewhen--dry-run/--yesare passed. A regression in the manual|=merge logic (for example, reading the wrong matches, or an inverted flag) would not be caught by any visible test.Add a test that parses
mise bootstrap --dry-run --yes status --json(or similar) and asserts the resultingBootstrap/DeferredBootstrapfields.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/cli/bootstrap.rs` around lines 40 - 80, Add direct test coverage for the hand-written DeferredBootstrap::from_arg_matches and, if applicable, update_from_arg_matches paths by parsing a bootstrap command with both --dry-run and --yes, then asserting the resulting Bootstrap fields are true. Extend the existing bootstrap parsing tests near test_bootstrap_command_tree_is_deferred_until_parsing while preserving their current coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/cli/bootstrap.rs`:
- Around line 40-80: Add direct test coverage for the hand-written
DeferredBootstrap::from_arg_matches and, if applicable, update_from_arg_matches
paths by parsing a bootstrap command with both --dry-run and --yes, then
asserting the resulting Bootstrap fields are true. Extend the existing bootstrap
parsing tests near test_bootstrap_command_tree_is_deferred_until_parsing while
preserving their current coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 20ac801b-ff74-4489-ab24-0097f7f3da85
📒 Files selected for processing (5)
src/cli/bootstrap.rssrc/cli/command_effects.rssrc/cli/mod.rssrc/cli/render_help.rssrc/cli/usage.rs
Instruction counts
No instruction-count regression above 1%. Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.
|
94a1f2d to
c64a550
Compare
|
Addressed the latest review suggestion in c64a550: added direct coverage for both initial parsing and update parsing of the hand-written deferred --dry-run/--yes propagation.\n\nAI-assisted — Tool: Codex; model: openai/gpt-5; version: unavailable. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c64a550. Configure here.
c64a550 to
5a1a973
Compare
5a1a973 to
b587636
Compare

Summary
mise bootstrapis selected--dry-runand--yesbehavior unchangedValidation
cargo test cli::tests::test_bootstrap_command_tree_is_deferred_until_parsingcargo test cli::tests::test_subcommands_are_sortedcargo test cli::tests::test_config_target_options_accept_both_namescargo test cli::command_effects::testsmise run render:usage(no generated changes)cargo clippy --workspace --all-features --all-targets -- -D warningsAI-assisted — Tool: Codex; model: openai/gpt-5; version: unavailable.
Summary by CodeRabbit
New Features
--dry-runand--yesoptions during command parsing and execution.Bug Fixes
Note
Low Risk
Startup-only CLI wiring with explicit tests for deferred parsing, flag preservation, and expanded introspection; bootstrap runtime behavior is delegated unchanged to the existing
Bootstrapimplementation.Overview
Defers building the large nested
bootstrapCLI until the user actually runsmise bootstrap(orbs), so normalmisestartup no longer pays the cost of registering every bootstrap subcommand up front.A
DeferredBootstrapwrapper uses clap’s deferred parser for the fullBootstraptree whiledeferred_flagsstill exposes top-level--dry-run/--yes(and thebsalias) on the outer command; those flags are merged into the innerBootstrapstruct duringFromArgMatchesbecause they’re marked#[clap(skip)]onBootstrapitself.Full-tree introspection is unchanged via
expand_deferred_subcommands, which swaps inbootstrap::full_command()for usage generation, command-effect validation, rendered help, and tests that need the complete subcommand tree.Reviewed by Cursor Bugbot for commit b587636. Bugbot is set up for automated code reviews on this repo. Configure here.