Skip to content
lotemPublic

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

rime-cli

Rime 輸入法配方管理器與數據構建工具, 集成 librime 編譯, 補丁與測試能力, 幫助輸入方案作者與用家以配方爲單位創作, 分發, 離線構建並安全部署 Rime 配置.

本倉庫以 Cargo Workspace 提供純庫包 (rime-plum, 位於 crates/rime-plum) 與命令行包 (rime-cli, 二進制名 rime), 可作爲圖形配置程序或 CI 流水線的後端, 並與未來的 rime 核心引擎庫無衝突並存. 完整架構設計與工作區管線詳見 DESIGN.md.

安裝

無需 Rust 工具鏈, 可直接通過 rime/plum 一鍵腳本從 GitHub Releases 下載最新預編譯版本至 ~/.rime/bin:

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/rime/plum/master/rime-install | bash
# Windows (PowerShell)
irm https://raw.githubusercontent.com/rime/plum/master/rime-install.ps1 | iex

亦可前往 Releases 手動下載對應平台的壓縮包 (Linux tar.gz, macOS tar.gz, Windows zip / 7z).

快速上手

1. 檢視環境與可用配方名錄

# 查看默認工作區 (~/.rime), 四個場地路徑與自動探測到的本地前端
rime env

# 列出當前工作區生效名錄中的全部配方 (按 TOML 源文件定義順序展示)
rime list

# 按關鍵字或元配方集過濾, 或加 -l 查看完整倉庫名片, 依賴與參數明細
rime list pinyin
rime list :preset
rime list -l :octagram luna-pinyin

2. 交互式選單安裝

# 打開終端方向鍵多選菜單 (支持空格勾選, / 即時篩選, 帶參配方自動引導填參)
rime install --select

# 先以 --dry-run (白跑) 預覽展開計劃, 或直接 --deploy 一鍵安裝 + 構建 + 測試 + 部署
rime install -s --dry-run :preset
rime install -s --deploy

3. 命令行直接安裝與傳參

# 安裝預設基礎配方集, 並一鍵構建, 測試與部署到自動探測的本地前端
rime install :preset --deploy --frontend auto

# 帶參數安裝 (參數以空格分隔緊跟在配方之後, 一條命令可同時裝多個配方)
rime install prelude luna-pinyin :octagram schema=luna_pinyin variant=hans

# 僅預覽執行計劃, 不改動工作區文件
rime install --dry-run :octagram schema=luna_pinyin variant=hans

# 安裝遠端倉庫及其子目錄子配方
rime install iDvel/rime-ice:others/recipes/full

4. 新建, 管理與分享配方倉庫

使用 rime new 快速生成起步 recipe.toml (空目錄或指定名稱生成個人配置模板; 已有 *.schema.yaml 的目錄自動生成方案倉庫模板, 既有文件絕不覆蓋):

# 新建個人配置目錄並生成起步 recipe.toml
rime new my-rime

# 在既有輸入方案倉庫根目錄下自動識別 *.schema.yaml 並生成方案倉庫模板
cd rime-wubi && rime new

將可分享的配方寫在個人倉庫的 recipe.toml 中 (禁止寫入本機路徑或 [profile.*]):

[recipe]
id = "my-rime"
name = "我的主力配置"
dependencies = [
  "prelude",
  "luna-pinyin",
  { recipe = ":octagram", params = { schema = "luna_pinyin", variant = "hant" } },
]

steps = [
  { add = ["luna_pinyin"] },
  { patch = { config = "default", key = "menu/page_size", value = "9" } },
  # { select = "luna_pinyin" },
]

本機前端與路徑偏好獨立保存在 ~/.rime/config.toml (不隨配方分享; 默認離線使用內置名錄, 如需疊加遠端名錄倉庫可配置 catalogs):

# 可選: 疊加遠端配方名錄倉庫
# catalogs = ["rime/plum"]

[profile.default]
frontend = "auto"

[profile.emacs-rime]
frontend = "emacs-rime"
target_dir = "~/.config/emacs-rime"

一鍵安裝並部署:

# 本機開發目錄一鍵執行 (自動讀取當前目錄 recipe.toml)
cd my-rime && rime install --deploy

# 換機或分享給他人時直接從遠端倉庫安裝
rime install alice/my-rime --deploy

# 指定本機配置檔
rime --profile emacs-rime install --deploy

5. 常用原子子命令

rime 亦支持分步執行四場地管線 (pkg/ -> src/ -> stage/ -> target/):

rime download :preset
rime install --no-download :preset
rime add luna_pinyin
rime patch default menu/page_size 9
rime build
rime test luna_pinyin
rime deploy --frontend auto
rime select luna_pinyin --frontend auto  # 就地更新目標目錄 user.yaml

開發構建與測試

推薦使用 cargo-make (詳見 Makefile.toml), 會自動注入各平台的 librime 路徑與編譯選項:

cargo make pre-build        # 下載或安裝對應平台的 librime 依賴
cargo make build            # 構建工作區 (rime-plum 與 rime-cli)
cargo make test             # 單線程運行全部單元測試 (避免 librime 單例競態)
cargo make clippy           # 嚴格靜態檢查 (-D warnings)
cargo make run list         # 運行 rime 命令行工具
cargo make package-release  # 打包當前平台發佈歸檔 (Linux/macOS tar.gz, Windows zip 與 7z)

若僅驗證純 Rust 庫 rime-plum (不依賴 C++ librime), 可關閉默認特性運行:

cargo test -p rime-plum --no-default-features -- --test-threads=1
RUSTDOCFLAGS="-D warnings" cargo doc -p rime-plum --no-default-features --no-deps

若不使用 cargo-make, macOS / Windows 手動執行 cargo 時需自行設置 LIBRIME_INCLUDE_DIR="${PWD}/librime/dist/include" 與 LIBRIME_LIB_DIR="${PWD}/librime/dist/lib" (macOS 另需 RUSTFLAGS="-C link-arg=-Wl,-rpath,@executable_path"; 直接運行 ./target/debug/rime 需設置 DYLD_FALLBACK_LIBRARY_PATH="${PWD}/librime/dist/lib"). Linux 預編譯二進制動態鏈接系統 librime, 運行前請安裝 librime1 (Debian/Ubuntu) 或對應發行版軟件包.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages