refactor(cmd): split commands.rs into per-domain modules - #48
Open
duyet wants to merge 1 commit into
Open
Conversation
Move auth, login, models, usage, config TUI, launch, account, keys, menu, and dispatch into src/cmd/. commands.rs becomes a thin re-export shim. No behavior change. Closes #24 Co-authored-by: Duyet Le <me@duyet.net> Co-authored-by: duyetbot <bot@duyet.net>
Contributor
anyr size and startupStartup is wall time for a cold Size budget:
Budget check: ok raw timings[
{
"asset": "anyr-darwin-arm64",
"kind": "native",
"path": "/Users/runner/work/cli/cli/anyr-darwin-arm64",
"bytes": 2905848,
"size": "2.8 MiB",
"version": "0.1.11 (built 2026-09-03 18:24:36)",
"target": "aarch64-apple-darwin",
"os": "macos-latest",
"startup_version": {
"n": 21,
"min_ms": 3.89,
"median_ms": 4.1,
"p95_ms": 5.69,
"mean_ms": 4.63
},
"startup_help": {
"n": 21,
"min_ms": 3.06,
"median_ms": 3.53,
"p95_ms": 3.91,
"mean_ms": 3.49
}
},
{
"asset": "anyr-darwin-x86_64",
"kind": "native",
"path": "/Users/runner/work/cli/cli/anyr-darwin-x86_64",
"bytes": 3120192,
"size": "3.0 MiB",
"version": "0.1.11 (built 2026-09-03 18:24:53)",
"target": "x86_64-apple-darwin",
"os": "macos-latest",
"startup_version": {
"n": 21,
"min_ms": 38.01,
"median_ms": 41.24,
"p95_ms": 49.43,
"mean_ms": 42.17
},
"startup_help": {
"n": 21,
"min_ms": 35.42,
"median_ms": 40.45,
"p95_ms": 52.0,
"mean_ms": 41.93
}
},
{
"asset": "anyr-linux-arm64",
"kind": "native",
"path": "/home/runner/work/cli/cli/anyr-linux-arm64",
"bytes": 2888744,
"size": "2.8 MiB",
"version": "0.1.11 (built 2026-09-03 18:23:58)",
"target": "aarch64-unknown-linux-gnu",
"os": "ubuntu-24.04-arm",
"startup_version": {
"n": 21,
"min_ms": 0.69,
"median_ms": 0.79,
"p95_ms": 0.87,
"mean_ms": 0.79
},
"startup_help": {
"n": 21,
"min_ms": 0.74,
"median_ms": 0.8,
"p95_ms": 0.84,
"mean_ms": 0.8
}
},
{
"asset": "anyr-linux-x86_64",
"kind": "native",
"path": "/home/runner/work/cli/cli/anyr-linux-x86_64",
"bytes": 3216904,
"size": "3.1 MiB",
"version": "0.1.11 (built 2026-09-03 18:24:03)",
"target": "x86_64-unknown-linux-gnu",
"os": "ubuntu-latest",
"startup_version": {
"n": 21,
"min_ms": 0.94,
"median_ms": 0.95,
"p95_ms": 0.97,
"mean_ms": 0.95
},
"startup_help": {
"n": 21,
"min_ms": 0.93,
"median_ms": 0.94,
"p95_ms": 1.03,
"mean_ms": 0.95
}
},
{
"asset": "anyr-windows-x86_64.exe",
"kind": "native",
"path": "D:\\a\\cli\\cli\\anyr-windows-x86_64.exe",
"bytes": 2665984,
"size": "2.5 MiB",
"version": "0.1.11 (built 2026-09-03T18:24:43Z)",
"target": "x86_64-pc-windows-msvc",
"os": "windows-latest",
"startup_version": {
"n": 21,
"min_ms": 5.83,
"median_ms": 6.06,
"p95_ms": 6.23,
"mean_ms": 6.06
},
"startup_help": {
"n": 21,
"min_ms": 5.83,
"median_ms": 5.93,
"p95_ms": 6.08,
"mean_ms": 5.95
}
},
{
"asset": "anyr.wasm",
"kind": "wasm",
"path": "/home/runner/work/cli/cli/target/wasm-pkg/anyr_cli_bg.wasm",
"bytes": 180713,
"size": "176.5 KiB",
"version": "wasm",
"target": "wasm32-unknown-unknown",
"os": ""
}
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
src/commands.rsheld every command plus TUI plumbing in one 4,271-line file. Concurrent features collided there, and reviews mixed unrelated domains. The internal seams were alreadyrun_*per command, so this is a mechanical split with no behavior change.Closes #24.
Scope
src/cmd/withauth,login,models,usage,config_tui,launch,account,keys,menu, anddispatch.src/commands.rsis a 154-line shim:run(),dispatch(), and thecmdimports. Target was ≤ 300 lines.pub mod cmd;insrc/lib.rs(alphabetically betweenchannelandcommands). Public entry stayscommands::run.persist_login_testsinlogin.rs, picker catalog tests inmodels.rs, launcher tests indispatch.rs.Tradeoffs
Shared helpers that would cycle
menu↔config_tuiormodels↔launchlive indispatch.rsas a leaf:config_path,CreditsCache,catalog_lookup_enabled,tool_command_for,persist_tool_command,launcher_last_tool.RoutingFieldlives next totoggle_agent_routing_fieldinmodels.rs.pub(crate)on moved items is the crate-internal surface; nothing new is public outside the crate.Blast Radius
Every CLI command still enters through
commands::run. Callers insrc/main.rsare unchanged. Reviewers should spot-check a few function bodies againstmain(ignorepub(crate)and rustfmt wraps on longer signatures). Do not merge release-please #15.Verification
wc -l src/commands.rs→ 154cargo test --locked --all-targets→ 186 lib + 68 cli + 7 release_lockcargo fmt --check→ exit 0cargo clippy --locked --all-targets -- -D warnings→ no new hits undersrc/cmd/orsrc/commands.rs(baseline warnings remain inupgrade.rs/spawn.rs/http.rs, owned by chore(dx): enforce clippy and rustfmt in CI #45)cargo build --locked --target wasm32-unknown-unknown --no-default-features→ exit 0control-anyr launch+doctor→ allokDriven isolated
anyr --help,--version,whoami,menu --dump-tui,config --dump-tui,auth --help→ exit 0; help still lists CORE COMMANDS / LAUNCH; whoami masks the fixture key; menu dump shows LAUNCH / claude / CONFIGURE; config dump shows ACCOUNT / MODEL / AGENT / GENERALVersion stays on 0.1.x (do not introduce 0.2 / 1.0)
Do not auto-merge release-please PRs