Skip to content

feat: make CLI dependencies optional - #421

Merged
SaladDay merged 3 commits into
SaladDay:mainfrom
botiverse:john/feature-gate-cli
Aug 21, 2026
Merged

feat: make CLI dependencies optional#421
SaladDay merged 3 commits into
SaladDay:mainfrom
botiverse:john/feature-gate-cli

Conversation

@cindyrui71

Copy link
Copy Markdown

Summary

  • add a default-enabled cli Cargo feature and require it for the cc-switch binary
  • gate CLI/TUI modules and their direct dependencies so library consumers can build with default-features = false
  • keep shared localization available to core library modules
  • add CI coverage for the library-only build, test compilation, and all-target direct dependency boundary

Default builds remain unchanged: the cli feature is enabled by default.

Validation

  • cargo check
  • cargo test --lib --no-run
  • cargo test --bin cc-switch --no-run
  • cargo check --lib --no-default-features
  • cargo check --lib --no-default-features --features test-hooks
  • cargo test --lib --no-default-features --no-run
  • cargo fmt --check
  • git diff --check
  • parsed .github/workflows/rust-ci.yml as YAML
  • verified the all-target, no-default direct dependency graph excludes every feature-gated CLI/TUI dependency

Notes

cargo clippy still reports the existing reversed-empty-range lint in src/cli/tui/ui/home_chart.rs; this change does not touch that code.

Signed-off-by: John <john@mail.build>
Signed-off-by: John <john@mail.build>
@bytemain

Copy link
Copy Markdown

@SaladDay 你好,非常感谢开发这么棒的一个项目,我们在基于 cc-switch-cli 封装一个 napi-rs 的包装层,方便 Node.js 调用,napi-rs 这层就可以不依赖于 cli feature(可以减小包体积),希望官方可以考虑下 cli feature optional 的这个 PR。

Signed-off-by: John <john@mail.build>
@SaladDay SaladDay closed this Aug 21, 2026
@SaladDay SaladDay reopened this Aug 21, 2026
@SaladDay
SaladDay merged commit 55751b8 into SaladDay:main Aug 21, 2026
@SaladDay

Copy link
Copy Markdown
Owner

@cindyrui71 @bytemain Thank you for the contribution and for explaining the napi-rs use case. This has now been merged.

The cli feature remains enabled by default for existing users, while library consumers can opt out with default-features = false. We also added Linux and Windows checks to protect this boundary.

Thanks again for helping improve cc-switch-cli!

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.

3 participants