5e39feaa347d6bff192fe4b99abd555f381b7b9f
MUC Utils
MUC Utils 是一个可扩展的 CLI 工具集,采用 Rust 编写。目前提供 LaTeX 模板管理功能。
安装
cargo install --path .
快速开始
# 查看内置模板
muc latex list
# 创建模板
muc latex create URTP
# 添加远程模板源
muc latex source add official https://example.com/templates.json
# 同步源
muc latex sync
语言
MUC Utils 支持 GNU 风格的运行时 i18n。通过 LANG 环境变量切换语言:
LANG=zh_CN.UTF-8 muc latex list # 中文
LANG=en_US.UTF-8 muc latex list # 英文
翻译文件位于 i18n/ 目录,也可放入 ~/.config/muc/i18n/ 覆盖或扩展,无需重新编译。
项目结构
src/
├── main.rs # 入口
├── cli.rs # CLI 定义 (clap derive)
├── i18n.rs # 运行时 i18n 系统
└── commands/
├── mod.rs # 子命令模块注册
└── latex/ # LaTeX 模块
├── mod.rs # 命令处理 + list/create 逻辑
├── template.rs # 模板数据结构
├── source.rs # 源管理 (add/list/remove/sync)
└── config.rs # 持久化 (~/.config/muc/)
扩展
添加新模块(如 docker)只需:
- 创建
src/commands/<module>/mod.rs,实现pub fn handle(args) -> Result<()>和模块逻辑 - 在
src/commands/mod.rs中添加pub mod <module>; - 在
src/cli.rs的Commands枚举中新增变体,使用 i18n key 作为 about 文本(如#[command(about = "clap.docker_about")]) - 在
i18n/en.toml和i18n/zh_CN.toml中添加对应翻译 - 在
src/main.rs的match cli.command中添加分发分支
CLI 帮助文本的本地化由 i18n::localize_clap() 自动递归处理,新增命令无需额外代码。
仓库描述