Half your users don't have eyes
说明与用途
CLI 工具通常只输出人类可读文本,导致脚本和 CI 失效。通过添加 --output json 标志并将结果包装在稳定的 JSON 封装中,程序获得可靠的合同,而人类可读输出可以自由改进。
问题
CLI tools often output only human‑readable text, breaking scripts, CI pipelines, and automation that rely on parsing that output.
结果
Automated consumers no longer break when human output changes; scripts can reliably check status and extract data. Human output becomes more readable and maintainable.
工作流
- 1. Add a
--outputflag to every command using the framework. - 2. When
--output jsonis requested, serialize the command result into aResponseenvelope. - 3. Scripts and CI jobs call the command with
--output jsonand parse the JSON payload. - 4. Human users run the command without the flag to see the friendly text.
- 5. Maintain the envelope shape across all commands to keep the contract stable.
证据
The consumer-side payoff is the whole point. A script can check .status without ever touching .data.
Machines get a stable, explicit, learn-it-once contract; humans get output that's now free to be properly readable.
- 记录日期: 2026-09-20T11:15:23.153Z