zdog-template-cli
Z-Template 的命令行 —— 用来快速体验双向模板。
完全建立在 zdog-template Python SDK 之上:不碰 ctypes、不碰 .so。
CLI 做不到的事就说明 SDK 缺东西 —— 这是对 SDK 能力面的一道约束。
安装
make -C .. build # 先构建 libztpl.so
uv sync
uv run ztpl demo # 跑一个完整例子
命令
| 命令 | 作用 |
|---|---|
ztpl parse |
源文本 → 结构化绑定(JSON 岛会被解码) |
ztpl convert |
源文本 → 目标文本(完整流水线) |
ztpl format |
NDJSON 绑定 → 目标文本 |
ztpl verify |
校验 round-trip 定律 A 与歧义 |
ztpl inspect |
展示模板编译成了什么 |
ztpl demo |
自带的完整例子,不需要输入 |
例子
ztpl parse -s '[${ts}] ${lv} ${msg}' --text '[T1] ERROR disk full'
cat app.log | ztpl convert \
-s '[${ts}] ${lv} ${msg}' \
-t '${level}|${text}' \
-m '{"level":"upper(lv)","text":"msg"}'
ztpl verify -s '[${ts}] ${lv}' -i app.log
ztpl inspect -s '[${ts}] ${lv} payload=${json|name=p}'
退出码
| 码 | 含义 |
|---|---|
| 0 | 成功 |
| 1 | 没有任何一行匹配 / 校验发现问题 |
| 2 | 用法或模板编译错误 |
| 3 | 运行期错误(如找不到共享库) |
错误信息一律走 stderr,stdout 只放结果 —— 可以放心接管道。 非 TTY 时自动关闭颜色。
Release files for zdog-template-cli 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zdog_template_cli-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / zdog_template_cli-0.1.0-py3-none-any.whl
| Download URL | zdog_template_cli-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6c45f10276d7ddcc22f2814c337a4fe0917276471c3544279e2be9f7e175dd4
|
|
BLAKE2b-256 checksum How to use checksums |
0d41b66244c748f691637e3f27ba2679f460072c7d4252e262bcfb4f63f48ccf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency log