Eris 是一个开发者 CLI 工具,它通过结构化的提交流程、项目级宏以及支持链式和否定的 Prolog 命令路由器来封装你的 git 工作流。
在日常工作中,你使用 eris 代替原始的 git 命令。
功能说明
eris init [name] — 在当前文件夹中创建 .eris/ 目录,写入宏文件,并将 .eris/ 添加到 git 的本地排除列表中,使其永远不会出现在你的仓库中。
eris commit / eris copush — 交互式提交并推送一步完成。提示你从菜单中选择一个常规提交类型(feat、fix、refactor 等),然后要求输入消息,格式化为 type: message,暂存所有内容,提交并推送。可在项目内的任何位置使用。
eris ignore <file> — 将文件添加到 .eris/.eris.ignore,使其在 copush 期间被跳过。按项目设置,非全局。
eris alias add <name> do <cmd> do <cmd> — 将命名宏(一系列 shell 命令)保存到 .eris/.eris.macros。
eris alias run <name> / eris run <name> — 运行已保存的宏。
eris rebuild — 使用 CMake 重新构建 eris 二进制文件本身。
eris root — 打印检测到的 eris 项目根目录。
命令链式操作
命令路由器使用 Prolog 编写。它直接在参数列表中支持 &&、|| 和 not:
eris init myapp && eris commit # 仅当 init 成功时才提交
eris init || true # 忽略失败
eris not init # 当 init 失败时成功
宏
宏存储在项目根目录的 .eris/.eris.macros 中:
[deploy]
make build
git push origin main
ssh prod "systemctl restart app"
使用 do 分隔符添加(无需引号):
eris alias add deploy do make build do git push origin main
使用引号添加(适用于包含分号或 shell 语法的命令):
eris alias add test "npm run lint" "npm test"
运行:
eris run deploy
安装
make install
这会构建二进制文件,将其复制到 /usr/local/bin/eris,并将别名追加到你的 .bashrc 或 .zshrc(自动检测)。然后:
source ~/.zshrc # 或 ~/.bashrc
依赖项(cmake、gcc、libcurl、libssl 等)在构建过程中会自动检查,如果缺失则自动安装。
从源码构建
make # 配置 + 构建(Debug)
make CONFIG=Release
make JOBS=8
需要:cmake、gcc/g++、libcurl-dev、libssl-dev、pkg-config。
可选:SWI-Prolog(libswipl-dev)用于 Prolog 路由器——如果不存在则回退到 C 路由器。
