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)只需:

  1. 创建 src/commands/<module>/mod.rs,实现 pub fn handle(args) -> Result<()> 和模块逻辑
  2. 在 src/commands/mod.rs 中添加 pub mod <module>;
  3. 在 src/cli.rs 的 Commands 枚举中新增变体,使用 i18n key 作为 about 文本(如 #[command(about = "clap.docker_about")])
  4. 在 i18n/en.toml 和 i18n/zh_CN.toml 中添加对应翻译
  5. 在 src/main.rs 的 match cli.command 中添加分发分支

CLI 帮助文本的本地化由 i18n::localize_clap() 自动递归处理,新增命令无需额外代码。

仓库描述
无详细信息
自述文档 119 KiB
v1.0.1 最新版本
2026-05-30 13:54:00 +00:00
编程语言
Rust 100%