Skip to content

refactor: split cli.rs into focused submodules#1351

Open
fengmk2 wants to merge 2 commits intorefactor-cli.rsfrom
refactor-cli-others
Open

refactor: split cli.rs into focused submodules#1351
fengmk2 wants to merge 2 commits intorefactor-cli.rsfrom
refactor-cli-others

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Apr 9, 2026

Break the 1,314-line cli.rs into a cli/ directory with 6 files:

  • types.rs: all structs, enums, and type aliases
  • resolver.rs: SubcommandResolver and cache/env helpers
  • handler.rs: VitePlusCommandHandler and VitePlusConfigLoader
  • execution.rs: resolve_and_execute command variants
  • help.rs: CLI help, error formatting, vitest arg helpers, and tests
  • mod.rs: module declarations, re-exports, and entry points

Tightens visibility where possible (pub(super), pub(crate)) following
the patterns established in the check/ and exec/ modules.


Note

Low Risk
Primarily a code-organization refactor of the CLI with minimal behavior change; risk is limited to potential regressions from moved code/visibility tweaks and the new unified stdout/stderr filtering helper.

Overview
Replaces the monolithic packages/cli/binding/src/cli.rs with a packages/cli/binding/src/cli/ module (types, resolver, handler, execution, help, mod) while keeping the same CLI entrypoints and behavior.

As part of the split, tightens visibility (pub(super), pub(crate)) and consolidates stdout/stderr capture+rewrite into execution::resolve_and_execute_with_filter (used for suppressing init output and rewriting oxfmt --init hints). Tests for help/arg-parsing behavior move into help.rs and the run-config sync test remains in mod.rs.

Reviewed by Cursor Bugbot for commit 54a20cb. Configure here.

@fengmk2 fengmk2 self-assigned this Apr 9, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Apr 9, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label auto-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2 fengmk2 force-pushed the refactor-cli-others branch from 74678d6 to 69654e0 Compare April 9, 2026 08:46
@fengmk2 fengmk2 added the test: e2e Auto run e2e tests label Apr 9, 2026 — with Graphite App
@fengmk2 fengmk2 marked this pull request as ready for review April 9, 2026 08:51
@fengmk2 fengmk2 requested review from branchseer and cpojer April 9, 2026 08:51
Copy link
Copy Markdown
Member Author

fengmk2 commented Apr 9, 2026

@codex review

Copy link
Copy Markdown
Member

@cpojer cpojer left a comment

Choose a reason for hiding this comment

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

Approving assuming that you or codex will find any issues from splitting this up and that there is no new code.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fengmk2 fengmk2 force-pushed the refactor-cli-others branch from 69654e0 to cb441d1 Compare April 9, 2026 13:33
@fengmk2 fengmk2 force-pushed the refactor-cli-others branch from cb441d1 to 87a4ff7 Compare April 9, 2026 13:41
@fengmk2 fengmk2 force-pushed the refactor-cli.rs branch 2 times, most recently from 5ad7900 to e9cf38e Compare April 10, 2026 02:45
@fengmk2 fengmk2 force-pushed the refactor-cli-others branch from 87a4ff7 to 54a20cb Compare April 10, 2026 02:45
@fengmk2
Copy link
Copy Markdown
Member Author

fengmk2 commented Apr 10, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 54a20cb. Configure here.

@fengmk2 fengmk2 force-pushed the refactor-cli-others branch from 54a20cb to 08a95ab Compare April 10, 2026 03:10
fengmk2 added 2 commits April 10, 2026 14:00
Break the 1,314-line cli.rs into a cli/ directory with 6 files:
- types.rs: all structs, enums, and type aliases
- resolver.rs: SubcommandResolver and cache/env helpers
- handler.rs: VitePlusCommandHandler and VitePlusConfigLoader
- execution.rs: resolve_and_execute command variants
- help.rs: CLI help, error formatting, vitest arg helpers, and tests
- mod.rs: module declarations, re-exports, and entry points

Tightens visibility where possible (pub(super), pub(crate)) following
the patterns established in the check/ and exec/ modules.
…unctions

Extract repeated `self.cli_options.as_ref().ok_or_else(...)` pattern
(9 occurrences) into a `cli_options()` helper method on SubcommandResolver.

Merge `resolve_and_execute_with_stdout_filter` and
`resolve_and_execute_with_stderr_filter` into a single
`resolve_and_execute_with_filter` that takes a `FilterStream` enum.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: e2e Auto run e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants