Skip to content

refactor(cli): extract dispatch handlers - #1102

Closed
cedric013 wants to merge 2 commits into
yvgude:mainfrom
cedric013:refactor/cli-dispatch-handlers
Closed

refactor(cli): extract dispatch handlers#1102
cedric013 wants to merge 2 commits into
yvgude:mainfrom
cedric013:refactor/cli-dispatch-handlers

Conversation

@cedric013

@cedric013 cedric013 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Closes #1103
Closes #1107

Summary

  • extract complex cli::dispatch::run branches into focused handler functions
  • deduplicate setup repair handling shared by install/bootstrap
  • replace internal runtime env mutation with centralized runtime flags while preserving env fallbacks
  • keep CI-required OCLA import formatting and unused import cleanup

Validation

  • cargo fmt --all -- --check
  • cargo clippy --lib -- -D warnings
  • cargo test cli::dispatch --lib

@yvgude yvgude left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Code Review: refactor(cli): extract dispatch handlers

Good architectural improvement — dispatch/mod.rs was overloaded and hard to navigate.

What it does:

  • Extracts CLI command handlers from a monolithic match in dispatch/mod.rs into domain-specific handler functions
  • Introduces core/runtime_flags.rs to replace direct env::set_var / env::var for LEAN_CTX_RAW, LEAN_CTX_COMPRESS, etc. (addresses #1107)
  • 21 files touched, but net +333/-267 is modest — mostly moving existing code

Quality:

  • Each handler becomes a self-contained function with clear responsibility
  • runtime_flags eliminates unsafe set_var calls in multi-threaded context
  • No logic changes in the extracted handlers — pure structural refactoring

Suggestion: Consider splitting runtime_flags into its own commit for a cleaner git history — it is orthogonal to the dispatch extraction.

Note: Import fixes overlap with main. Please rebase.

LGTM after rebase.

@yvgude

yvgude commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Merged to main via CLI rebase+merge.

@yvgude yvgude closed this Jul 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(runtime): replace internal env mutation with runtime flags refactor(cli): split dispatch run into focused handlers

2 participants