Skip to main content

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for zdog-template-cli 0.1.1
File Interpreter ABI Platform
zdog_template_cli-0.1.1-py3-none-any.whl Python 3 none any Details

Release files / zdog_template_cli-0.1.1-py3-none-any.whl

Download URL zdog_template_cli-0.1.1-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
464c27b146e02694589e89ec973a837e4d9845571009ee2ab7310fa75e4fd207
BLAKE2b-256 checksum
How to use checksums
c04bf3d142ee563a0c23847855db905bec277109480f1c123209092632a8fe5f
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

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page