| name | design-cli-output |
| locale | wenyan-ultra |
| source_locale | en |
| source_commit | 2630b6e9 |
| translator | Julius Brussee homage — caveman |
| translation_date | 2026-07-30 |
| description | Design terminal output for a CLI tool with chalk colors, Unicode glyphs, multiple verbosity levels (human, verbose, quiet, JSON), and consistent voice rules. Covers color palette selection, status indicator design, reporter function architecture, ceremony/narrative output variants, and cross-terminal compatibility. Use when building a new CLI reporter module, adding warm narrative output to an existing tool, standardizing output across multiple commands, or designing machine-readable JSON alongside human-readable text.
|
| license | MIT |
| allowed-tools | Read Write Edit Bash Grep Glob |
| metadata | {"author":"Philipp Thoss","version":"1.0","domain":"cli","complexity":"basic","language":"TypeScript","tags":["cli","terminal","ux","chalk","unicode"]} |
設計 CLI 輸出
為命令行工具設一致多級終端輸出。
用
- 構 CLI 新報告者模組
- 加暖敘事輸出於標事務輸出
- 標準化多命令輸出格式
- 設並行機可讀 JSON+人可讀輸出
- 擇色、符、冗繁級予新終端工具
入
- 必:CLI 名+主受眾(開發者、運維、終用戶)
- 必:需格式化輸出之命令
- 可:是否欲「儀式」或敘事變體
- 可:品牌限(色板、調)
法
一:定色板
以 chalk 建名板對象。
載 chalk 須置無色退於後。 退須代板所用諸調用形,僅過字串不足:
const FACTORIES = new Set(['ansi256', 'bgAnsi256', 'bgHex', 'bgRgb', 'hex',
'rgb', 'underlineAnsi256', 'underlineHex', 'underlineRgb']);
function makeChalkStub() {
return new Proxy((text) => text, {
get(target, prop) {
if (prop === 'then') return undefined;
if (prop === 'level') return 0;
if ( prop === ) .(target, prop);
.(prop) ? () : ();
},
});
}
chalk;
{ chalk = ( ()).; }
{ chalk = (); }