| name | design-cli-output |
| locale | wenyan |
| 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 = (); }