@outfitter/cli 0.1.0-rc.1 → 0.1.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -32
- package/dist/actions.js +1 -1
- package/dist/borders/index.d.ts +3 -0
- package/dist/borders/index.js +13 -0
- package/dist/box/index.d.ts +4 -0
- package/dist/box/index.js +13 -0
- package/dist/cli.d.ts +2 -103
- package/dist/cli.js +4 -51
- package/dist/colors/index.d.ts +3 -0
- package/dist/colors/index.js +18 -0
- package/dist/command.d.ts +3 -37
- package/dist/command.js +5 -1
- package/dist/demo/index.d.ts +78 -0
- package/dist/demo/index.js +148 -0
- package/dist/demo/registry.d.ts +7 -0
- package/dist/demo/registry.js +28 -0
- package/dist/demo/renderers/borders.d.ts +7 -0
- package/dist/demo/renderers/borders.js +17 -0
- package/dist/demo/renderers/box.d.ts +7 -0
- package/dist/demo/renderers/box.js +18 -0
- package/dist/demo/renderers/colors.d.ts +7 -0
- package/dist/demo/renderers/colors.js +18 -0
- package/dist/demo/renderers/indicators.d.ts +7 -0
- package/dist/demo/renderers/indicators.js +17 -0
- package/dist/demo/renderers/list.d.ts +7 -0
- package/dist/demo/renderers/list.js +19 -0
- package/dist/demo/renderers/markdown.d.ts +7 -0
- package/dist/demo/renderers/markdown.js +18 -0
- package/dist/demo/renderers/progress.d.ts +7 -0
- package/dist/demo/renderers/progress.js +17 -0
- package/dist/demo/renderers/spinner.d.ts +7 -0
- package/dist/demo/renderers/spinner.js +19 -0
- package/dist/demo/renderers/table.d.ts +7 -0
- package/dist/demo/renderers/table.js +19 -0
- package/dist/demo/renderers/text.d.ts +7 -0
- package/dist/demo/renderers/text.js +16 -0
- package/dist/demo/renderers/tree.d.ts +7 -0
- package/dist/demo/renderers/tree.js +18 -0
- package/dist/demo/section.d.ts +5 -0
- package/dist/demo/section.js +23 -0
- package/dist/demo/templates.d.ts +4 -0
- package/dist/demo/templates.js +10 -0
- package/dist/demo/types.d.ts +3 -0
- package/dist/demo/types.js +8 -0
- package/dist/index.d.ts +5 -607
- package/dist/index.js +10 -44
- package/dist/input.d.ts +9 -123
- package/dist/input.js +2 -3
- package/dist/list/index.d.ts +3 -0
- package/dist/list/index.js +9 -0
- package/dist/output.d.ts +2 -68
- package/dist/output.js +4 -150
- package/dist/pagination.d.ts +1 -34
- package/dist/pagination.js +1 -1
- package/dist/preset/full.d.ts +14 -0
- package/dist/preset/full.js +41 -0
- package/dist/preset/standard.d.ts +11 -0
- package/dist/preset/standard.js +30 -0
- package/dist/prompt/confirm.d.ts +4 -0
- package/dist/prompt/confirm.js +9 -0
- package/dist/prompt/group.d.ts +4 -0
- package/dist/prompt/group.js +9 -0
- package/dist/prompt/index.d.ts +7 -0
- package/dist/prompt/index.js +32 -0
- package/dist/prompt/select.d.ts +4 -0
- package/dist/prompt/select.js +11 -0
- package/dist/prompt/text.d.ts +4 -0
- package/dist/prompt/text.js +11 -0
- package/dist/prompt/types.d.ts +3 -0
- package/dist/prompt/types.js +8 -0
- package/dist/prompt/validators.d.ts +2 -0
- package/dist/prompt/validators.js +8 -0
- package/dist/render/borders.d.ts +2 -0
- package/dist/render/borders.js +15 -0
- package/dist/render/box.d.ts +3 -0
- package/dist/render/box.js +23 -0
- package/dist/render/colors.d.ts +2 -0
- package/dist/render/colors.js +20 -0
- package/dist/render/date.d.ts +2 -0
- package/dist/render/date.js +12 -0
- package/dist/render/format-relative.d.ts +2 -0
- package/dist/render/format-relative.js +8 -0
- package/dist/render/format.d.ts +2 -0
- package/dist/render/format.js +10 -0
- package/dist/render/heading.d.ts +3 -0
- package/dist/render/heading.js +14 -0
- package/dist/render/index.d.ts +32 -0
- package/dist/render/index.js +235 -0
- package/dist/render/indicators.d.ts +2 -0
- package/dist/render/indicators.js +14 -0
- package/dist/render/json.d.ts +2 -0
- package/dist/render/json.js +10 -0
- package/dist/render/layout.d.ts +5 -0
- package/dist/render/layout.js +25 -0
- package/dist/render/list.d.ts +2 -0
- package/dist/render/list.js +8 -0
- package/dist/render/markdown.d.ts +2 -0
- package/dist/render/markdown.js +10 -0
- package/dist/render/progress.d.ts +2 -0
- package/dist/render/progress.js +8 -0
- package/dist/render/separator.d.ts +3 -0
- package/dist/render/separator.js +14 -0
- package/dist/render/shapes.d.ts +2 -0
- package/dist/render/shapes.js +35 -0
- package/dist/render/spinner.d.ts +2 -0
- package/dist/render/spinner.js +12 -0
- package/dist/render/stack.d.ts +3 -0
- package/dist/render/stack.js +38 -0
- package/dist/render/table.d.ts +3 -0
- package/dist/render/table.js +12 -0
- package/dist/render/text.d.ts +2 -0
- package/dist/render/text.js +27 -0
- package/dist/render/tree.d.ts +2 -0
- package/dist/render/tree.js +10 -0
- package/dist/render/types.d.ts +2 -0
- package/dist/render/types.js +1 -0
- package/dist/shared/@outfitter/cli-0ggcy7fa.js +20 -0
- package/dist/shared/@outfitter/cli-0psys2vm.js +7 -0
- package/dist/shared/@outfitter/cli-1bghjef6.js +352 -0
- package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +45 -0
- package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +50 -0
- package/dist/shared/@outfitter/cli-33e97cjs.d.ts +42 -0
- package/dist/shared/@outfitter/cli-34fqr7bp.js +37 -0
- package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +97 -0
- package/dist/shared/@outfitter/cli-3dxmmy4c.d.ts +20 -0
- package/dist/shared/@outfitter/cli-3f12z5kf.d.ts +83 -0
- package/dist/shared/@outfitter/cli-3hp8qwx3.js +11 -0
- package/dist/shared/@outfitter/cli-3t2zaenc.d.ts +59 -0
- package/dist/shared/@outfitter/cli-4cb5g831.d.ts +147 -0
- package/dist/shared/@outfitter/cli-4w2a1rfy.d.ts +23 -0
- package/dist/shared/@outfitter/cli-4x6pqnez.js +20 -0
- package/dist/shared/@outfitter/cli-671sxkhj.js +146 -0
- package/dist/shared/@outfitter/cli-6bztk73z.d.ts +51 -0
- package/dist/shared/@outfitter/cli-6fxffp8k.js +1 -0
- package/dist/shared/@outfitter/cli-6j9qynm8.js +118 -0
- package/dist/shared/@outfitter/cli-6m988kh0.d.ts +61 -0
- package/dist/shared/@outfitter/cli-72kg550t.d.ts +53 -0
- package/dist/shared/@outfitter/cli-74ba31gz.js +134 -0
- package/dist/shared/@outfitter/cli-7gnrb8cr.js +214 -0
- package/dist/shared/@outfitter/cli-7na6p4fs.d.ts +59 -0
- package/dist/shared/@outfitter/cli-7nm6edvh.d.ts +17 -0
- package/dist/shared/@outfitter/cli-85fg2vr5.js +123 -0
- package/dist/shared/@outfitter/cli-8a8xrzhy.js +20 -0
- package/dist/shared/@outfitter/cli-8aa1vhdn.d.ts +119 -0
- package/dist/shared/@outfitter/cli-8bwaw3pz.js +7 -0
- package/dist/shared/@outfitter/cli-8j5k6mr3.js +71 -0
- package/dist/shared/@outfitter/cli-8rx4g3s5.d.ts +41 -0
- package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +223 -0
- package/dist/shared/@outfitter/cli-96b2p4td.d.ts +56 -0
- package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +190 -0
- package/dist/shared/@outfitter/cli-9mtjjykw.js +67 -0
- package/dist/shared/@outfitter/cli-9nbyj2bt.js +128 -0
- package/dist/shared/@outfitter/cli-a4q87517.d.ts +64 -0
- package/dist/shared/@outfitter/cli-afhjqmg3.js +63 -0
- package/dist/shared/@outfitter/cli-an9j0h80.js +117 -0
- package/dist/shared/@outfitter/cli-ay411nbr.js +122 -0
- package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +132 -0
- package/dist/shared/@outfitter/cli-b5c2k0d7.js +39 -0
- package/dist/shared/@outfitter/cli-b5epywry.js +1 -0
- package/dist/shared/@outfitter/cli-bc17qeh2.js +19 -0
- package/dist/shared/@outfitter/cli-bcmcaz1b.js +23 -0
- package/dist/shared/@outfitter/cli-bf3vma4q.js +61 -0
- package/dist/shared/@outfitter/cli-c8q4f71g.js +144 -0
- package/dist/shared/@outfitter/cli-c9knfqn5.d.ts +30 -0
- package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +53 -0
- package/dist/shared/@outfitter/cli-cf2s94s1.d.ts +42 -0
- package/dist/shared/@outfitter/cli-cs45xd6q.js +59 -0
- package/dist/shared/@outfitter/cli-d7jpshq5.d.ts +128 -0
- package/dist/shared/@outfitter/cli-d9ad0rqj.js +75 -0
- package/dist/shared/@outfitter/cli-daw296mv.js +61 -0
- package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +91 -0
- package/dist/shared/@outfitter/cli-e73v3qqy.d.ts +93 -0
- package/dist/shared/@outfitter/cli-efy6jfcj.js +52 -0
- package/dist/shared/@outfitter/cli-en6zn6sj.js +1 -0
- package/dist/shared/@outfitter/cli-ep2cvtk8.js +48 -0
- package/dist/shared/@outfitter/cli-evx7qcp1.d.ts +300 -0
- package/dist/shared/@outfitter/cli-f75h8e94.js +7 -0
- package/dist/shared/@outfitter/cli-fakncnjp.d.ts +106 -0
- package/dist/shared/@outfitter/cli-feb5j90n.js +94 -0
- package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +66 -0
- package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +328 -0
- package/dist/shared/@outfitter/cli-j19a91ck.js +30 -0
- package/dist/shared/@outfitter/cli-j4n8gaf3.js +95 -0
- package/dist/shared/@outfitter/cli-jejfypgf.js +85 -0
- package/dist/shared/@outfitter/cli-jhcdwvpn.js +135 -0
- package/dist/shared/@outfitter/cli-jjemfdta.js +85 -0
- package/dist/shared/@outfitter/cli-kc84wmch.js +267 -0
- package/dist/shared/@outfitter/cli-ktqme80d.js +7 -0
- package/dist/shared/@outfitter/cli-mhamvbty.d.ts +34 -0
- package/dist/shared/@outfitter/cli-mq0jp15z.js +1 -0
- package/dist/shared/@outfitter/cli-mymyavvj.d.ts +26 -0
- package/dist/shared/@outfitter/cli-n17gt1dz.js +19 -0
- package/dist/shared/@outfitter/cli-n9dbh0hp.js +51 -0
- package/dist/shared/@outfitter/cli-nvvc92c8.js +128 -0
- package/dist/shared/@outfitter/cli-p1m5dhrs.js +169 -0
- package/dist/shared/@outfitter/cli-p38sfxyk.js +25 -0
- package/dist/shared/@outfitter/cli-p3dqm1vd.js +22 -0
- package/dist/shared/@outfitter/cli-p9j1phge.js +20 -0
- package/dist/shared/@outfitter/cli-pkxmzavm.js +62 -0
- package/dist/shared/@outfitter/cli-q8r6jarq.d.ts +24 -0
- package/dist/shared/@outfitter/cli-qj83y5wj.d.ts +71 -0
- package/dist/shared/@outfitter/cli-qjfc3j11.d.ts +112 -0
- package/dist/shared/@outfitter/cli-qp4cbhqr.js +70 -0
- package/dist/shared/@outfitter/cli-s0kkx9m1.d.ts +164 -0
- package/dist/shared/@outfitter/cli-snxj55n6.js +43 -0
- package/dist/shared/@outfitter/cli-swwxvjvm.d.ts +24 -0
- package/dist/shared/@outfitter/cli-sx67mmfx.d.ts +98 -0
- package/dist/shared/@outfitter/cli-tarpsa8a.js +30 -0
- package/dist/shared/@outfitter/cli-thvzhjd1.js +126 -0
- package/dist/shared/@outfitter/cli-tqewy503.d.ts +36 -0
- package/dist/shared/@outfitter/cli-ttt7r0j7.d.ts +253 -0
- package/dist/shared/@outfitter/cli-tvw1xrdj.js +20 -0
- package/dist/shared/@outfitter/cli-v1tzwxkt.js +32 -0
- package/dist/shared/@outfitter/cli-vd60dj65.js +1 -0
- package/dist/shared/@outfitter/cli-vp88gxev.js +279 -0
- package/dist/shared/@outfitter/cli-vstbkzky.d.ts +74 -0
- package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +54 -0
- package/dist/shared/@outfitter/cli-w5y3xepp.js +20 -0
- package/dist/shared/@outfitter/cli-x4cavvc0.js +1 -0
- package/dist/shared/@outfitter/cli-xep6v2c0.js +52 -0
- package/dist/shared/@outfitter/cli-xg5y5fhk.js +86 -0
- package/dist/shared/@outfitter/cli-xsaheemc.d.ts +248 -0
- package/dist/shared/@outfitter/cli-xvqtqjxk.js +82 -0
- package/dist/shared/@outfitter/cli-y25tt8nc.d.ts +48 -0
- package/dist/shared/@outfitter/cli-zact3325.js +152 -0
- package/dist/shared/@outfitter/cli-zx598p8q.d.ts +26 -0
- package/dist/streaming/ansi.d.ts +2 -0
- package/dist/streaming/ansi.js +8 -0
- package/dist/streaming/index.d.ts +4 -0
- package/dist/streaming/index.js +17 -0
- package/dist/streaming/spinner.d.ts +3 -0
- package/dist/streaming/spinner.js +10 -0
- package/dist/streaming/writer.d.ts +2 -0
- package/dist/streaming/writer.js +9 -0
- package/dist/table/index.d.ts +4 -0
- package/dist/table/index.js +13 -0
- package/dist/terminal/detection.d.ts +2 -0
- package/dist/terminal/detection.js +23 -0
- package/dist/terminal/index.d.ts +2 -0
- package/dist/terminal/index.js +24 -0
- package/dist/theme/context.d.ts +9 -0
- package/dist/theme/context.js +14 -0
- package/dist/theme/create.d.ts +8 -0
- package/dist/theme/create.js +12 -0
- package/dist/theme/index.d.ts +17 -0
- package/dist/theme/index.js +42 -0
- package/dist/theme/presets/bold.d.ts +8 -0
- package/dist/theme/presets/bold.js +12 -0
- package/dist/theme/presets/default.d.ts +8 -0
- package/dist/theme/presets/default.js +11 -0
- package/dist/theme/presets/index.d.ts +12 -0
- package/dist/theme/presets/index.js +24 -0
- package/dist/theme/presets/minimal.d.ts +8 -0
- package/dist/theme/presets/minimal.js +12 -0
- package/dist/theme/presets/rounded.d.ts +8 -0
- package/dist/theme/presets/rounded.js +12 -0
- package/dist/theme/resolve.d.ts +8 -0
- package/dist/theme/resolve.js +11 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/types.js +1 -0
- package/dist/tree/index.d.ts +3 -0
- package/dist/tree/index.js +11 -0
- package/dist/types.d.ts +1 -252
- package/dist/types.js +1 -1
- package/package.json +228 -20
- package/dist/shared/@outfitter/cli-4yy82cmp.js +0 -20
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
INDICATORS,
|
|
4
|
+
getIndicator,
|
|
5
|
+
getProgressIndicator
|
|
6
|
+
} from "./cli-p1m5dhrs.js";
|
|
7
|
+
import {
|
|
8
|
+
demoSection,
|
|
9
|
+
demoSubsection
|
|
10
|
+
} from "./cli-34fqr7bp.js";
|
|
11
|
+
|
|
12
|
+
// packages/cli/src/demo/renderers/indicators.ts
|
|
13
|
+
function renderIndicatorsDemo(config, _theme) {
|
|
14
|
+
const showCode = config.showCode ?? true;
|
|
15
|
+
const lines = [];
|
|
16
|
+
lines.push(demoSection("Indicators"));
|
|
17
|
+
lines.push("");
|
|
18
|
+
if (showCode) {
|
|
19
|
+
lines.push('import { getIndicator, getProgressIndicator, INDICATORS } from "@outfitter/cli/render";');
|
|
20
|
+
lines.push("");
|
|
21
|
+
}
|
|
22
|
+
lines.push("Semantic indicators with Unicode and ASCII fallback support.");
|
|
23
|
+
lines.push("");
|
|
24
|
+
lines.push(demoSubsection("Status"));
|
|
25
|
+
lines.push("");
|
|
26
|
+
for (const [name, indicator] of Object.entries(INDICATORS.status)) {
|
|
27
|
+
const colorInfo = indicator.color ? ` (${indicator.color})` : "";
|
|
28
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(10)} \u2192 ${indicator.fallback}${colorInfo}`);
|
|
29
|
+
}
|
|
30
|
+
lines.push("");
|
|
31
|
+
if (showCode) {
|
|
32
|
+
lines.push('getIndicator("status", "success") // ' + getIndicator("status", "success", true));
|
|
33
|
+
lines.push('getIndicator("status", "error") // ' + getIndicator("status", "error", true));
|
|
34
|
+
lines.push("");
|
|
35
|
+
}
|
|
36
|
+
lines.push(demoSubsection("Markers"));
|
|
37
|
+
lines.push("");
|
|
38
|
+
const markerGroups = {
|
|
39
|
+
Circles: [
|
|
40
|
+
"circle",
|
|
41
|
+
"circleOutline",
|
|
42
|
+
"circleDotted",
|
|
43
|
+
"circleSmall",
|
|
44
|
+
"circleDot",
|
|
45
|
+
"circleDotOutline"
|
|
46
|
+
],
|
|
47
|
+
Squares: ["square", "squareOutline", "squareSmall", "squareSmallOutline"],
|
|
48
|
+
Lozenges: ["lozenge", "lozengeOutline"],
|
|
49
|
+
Checkboxes: ["checkbox", "checkboxChecked", "checkboxCross"],
|
|
50
|
+
Pointers: ["pointer", "pointerSmall", "dash"]
|
|
51
|
+
};
|
|
52
|
+
for (const [groupName, names] of Object.entries(markerGroups)) {
|
|
53
|
+
lines.push(` ${groupName}:`);
|
|
54
|
+
for (const name of names) {
|
|
55
|
+
const indicator = INDICATORS.marker[name];
|
|
56
|
+
if (indicator) {
|
|
57
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(18)} \u2192 ${indicator.fallback}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
lines.push("");
|
|
61
|
+
}
|
|
62
|
+
lines.push(demoSubsection("Progress"));
|
|
63
|
+
lines.push("");
|
|
64
|
+
lines.push(" Circle: \u25CB \u25D4 \u25D1 \u25D5 \u25CF");
|
|
65
|
+
lines.push(" Vertical: \u2581 \u2582 \u2583 \u2584 \u2585 \u2586 \u2587 \u2588");
|
|
66
|
+
lines.push(" Horizontal: \u258F \u258E \u258D \u258C \u258B \u258A \u2589 \u2588");
|
|
67
|
+
lines.push(" Shade: \u2591 \u2592 \u2593");
|
|
68
|
+
lines.push("");
|
|
69
|
+
if (showCode) {
|
|
70
|
+
lines.push("// Get progress indicator by percentage:");
|
|
71
|
+
lines.push('getProgressIndicator("circle", 50, 100) // ' + getProgressIndicator("circle", 50, 100, true));
|
|
72
|
+
lines.push('getProgressIndicator("vertical", 6, 8) // ' + getProgressIndicator("vertical", 6, 8, true));
|
|
73
|
+
lines.push('getProgressIndicator("horizontal", 4, 8) // ' + getProgressIndicator("horizontal", 4, 8, true));
|
|
74
|
+
lines.push('getProgressIndicator("shade", 100, 100) // ' + getProgressIndicator("shade", 100, 100, true));
|
|
75
|
+
lines.push("");
|
|
76
|
+
}
|
|
77
|
+
lines.push(demoSubsection("Triangles"));
|
|
78
|
+
lines.push("");
|
|
79
|
+
const triangleGroups = {
|
|
80
|
+
Up: ["up", "upSmall", "upOutline"],
|
|
81
|
+
Down: ["down", "downSmall", "downOutline"],
|
|
82
|
+
Left: ["left", "leftSmall", "leftOutline"],
|
|
83
|
+
Right: ["right", "rightSmall", "rightOutline"]
|
|
84
|
+
};
|
|
85
|
+
for (const [groupName, names] of Object.entries(triangleGroups)) {
|
|
86
|
+
const indicators = names.map((n) => INDICATORS.triangle[n]?.unicode ?? "").join(" ");
|
|
87
|
+
lines.push(` ${groupName.padEnd(6)} ${indicators}`);
|
|
88
|
+
}
|
|
89
|
+
lines.push("");
|
|
90
|
+
lines.push(demoSubsection("Special"));
|
|
91
|
+
lines.push("");
|
|
92
|
+
for (const [name, indicator] of Object.entries(INDICATORS.special)) {
|
|
93
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(14)} \u2192 ${indicator.fallback}`);
|
|
94
|
+
}
|
|
95
|
+
lines.push("");
|
|
96
|
+
lines.push(demoSubsection("Directional"));
|
|
97
|
+
lines.push("");
|
|
98
|
+
for (const [name, indicator] of Object.entries(INDICATORS.directional)) {
|
|
99
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(16)} \u2192 ${indicator.fallback}`);
|
|
100
|
+
}
|
|
101
|
+
lines.push("");
|
|
102
|
+
lines.push(demoSubsection("Math"));
|
|
103
|
+
lines.push("");
|
|
104
|
+
for (const [name, indicator] of Object.entries(INDICATORS.math)) {
|
|
105
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(16)} \u2192 ${indicator.fallback}`);
|
|
106
|
+
}
|
|
107
|
+
lines.push("");
|
|
108
|
+
lines.push(demoSubsection("Usage"));
|
|
109
|
+
lines.push("");
|
|
110
|
+
lines.push("\u2022 getIndicator(category, name) \u2014 auto-detects Unicode support");
|
|
111
|
+
lines.push("\u2022 getProgressIndicator(style, current, max) \u2014 maps value to step");
|
|
112
|
+
lines.push("\u2022 INDICATORS[category][name] \u2014 direct access to unicode/fallback");
|
|
113
|
+
lines.push("\u2022 Status indicators include semantic color hints");
|
|
114
|
+
return lines.join(`
|
|
115
|
+
`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { renderIndicatorsDemo };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PartialVisualTheme, VisualTheme } from "./cli-s0kkx9m1";
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a visual theme.
|
|
4
|
+
*/
|
|
5
|
+
interface CreateVisualThemeOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Base theme to extend from.
|
|
8
|
+
* Properties not overridden will be inherited from this theme.
|
|
9
|
+
* @default defaultTheme
|
|
10
|
+
*/
|
|
11
|
+
extends?: VisualTheme;
|
|
12
|
+
/**
|
|
13
|
+
* Properties to override on the base/extended theme.
|
|
14
|
+
* Supports partial overrides for nested objects (colors, spacing, markers).
|
|
15
|
+
*/
|
|
16
|
+
overrides?: PartialVisualTheme;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a visual theme by extending and/or overriding a base theme.
|
|
20
|
+
*
|
|
21
|
+
* This is the primary factory for creating custom themes. You can:
|
|
22
|
+
* - Start from scratch (no options → defaultTheme)
|
|
23
|
+
* - Extend an existing preset
|
|
24
|
+
* - Override specific properties
|
|
25
|
+
* - Combine extension and overrides
|
|
26
|
+
*
|
|
27
|
+
* When changing the `border` property, `borderChars` is automatically
|
|
28
|
+
* updated to match the new border style.
|
|
29
|
+
*
|
|
30
|
+
* @param options - Configuration for theme creation
|
|
31
|
+
* @returns A complete VisualTheme
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Start with defaults
|
|
36
|
+
* const theme = createVisualTheme();
|
|
37
|
+
*
|
|
38
|
+
* // Extend a preset
|
|
39
|
+
* const rounded = createVisualTheme({ extends: roundedTheme });
|
|
40
|
+
*
|
|
41
|
+
* // Override specific properties
|
|
42
|
+
* const custom = createVisualTheme({
|
|
43
|
+
* overrides: {
|
|
44
|
+
* border: "double",
|
|
45
|
+
* colors: { success: "\x1b[38;5;82m" },
|
|
46
|
+
* spacing: { boxPadding: 2 }
|
|
47
|
+
* }
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Extend and override
|
|
51
|
+
* const brandTheme = createVisualTheme({
|
|
52
|
+
* extends: roundedTheme,
|
|
53
|
+
* overrides: {
|
|
54
|
+
* name: "brand",
|
|
55
|
+
* colors: { accent: "\x1b[38;5;39m" }
|
|
56
|
+
* }
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function createVisualTheme(options?: CreateVisualThemeOptions): VisualTheme;
|
|
61
|
+
export { CreateVisualThemeOptions, createVisualTheme };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { OutputOptions } from "./cli-ttt7r0j7";
|
|
2
|
+
/**
|
|
3
|
+
* Output data to the console with automatic mode selection.
|
|
4
|
+
*
|
|
5
|
+
* Respects --json, --jsonl, --tree, --table flags automatically.
|
|
6
|
+
* Defaults to human-friendly output when no flags are present.
|
|
7
|
+
*
|
|
8
|
+
* @param data - The data to output
|
|
9
|
+
* @param options - Output configuration options
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { output } from "@outfitter/cli";
|
|
14
|
+
*
|
|
15
|
+
* // Basic usage - mode auto-detected from flags
|
|
16
|
+
* output(results);
|
|
17
|
+
*
|
|
18
|
+
* // Force JSON mode
|
|
19
|
+
* output(results, { mode: "json" });
|
|
20
|
+
*
|
|
21
|
+
* // Pretty-print JSON
|
|
22
|
+
* output(results, { mode: "json", pretty: true });
|
|
23
|
+
*
|
|
24
|
+
* // Output to stderr
|
|
25
|
+
* output(errors, { stream: process.stderr });
|
|
26
|
+
*
|
|
27
|
+
* // Await for large outputs (recommended)
|
|
28
|
+
* await output(largeDataset, { mode: "jsonl" });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function output(data: unknown, options?: OutputOptions): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Exit the process with an error message.
|
|
34
|
+
*
|
|
35
|
+
* Formats the error according to the current output mode (human or JSON)
|
|
36
|
+
* and exits with an appropriate exit code.
|
|
37
|
+
*
|
|
38
|
+
* @param error - The error to display
|
|
39
|
+
* @returns Never returns (exits the process)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import { exitWithError } from "@outfitter/cli";
|
|
44
|
+
*
|
|
45
|
+
* try {
|
|
46
|
+
* await riskyOperation();
|
|
47
|
+
* } catch (error) {
|
|
48
|
+
* exitWithError(error instanceof Error ? error : new Error(String(error)));
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function exitWithError(error: Error, options?: OutputOptions): never;
|
|
53
|
+
export { output, exitWithError };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
getThemeMethodsByCategory
|
|
4
|
+
} from "./cli-kc84wmch.js";
|
|
5
|
+
import {
|
|
6
|
+
getExample
|
|
7
|
+
} from "./cli-xep6v2c0.js";
|
|
8
|
+
import {
|
|
9
|
+
demoSection
|
|
10
|
+
} from "./cli-34fqr7bp.js";
|
|
11
|
+
import {
|
|
12
|
+
ANSI,
|
|
13
|
+
applyColor,
|
|
14
|
+
createTokens,
|
|
15
|
+
init_colors,
|
|
16
|
+
resolveTokenColorEnabled
|
|
17
|
+
} from "./cli-9nbyj2bt.js";
|
|
18
|
+
import {
|
|
19
|
+
hasNoColorEnv,
|
|
20
|
+
init_detection,
|
|
21
|
+
resolveForceColorEnv
|
|
22
|
+
} from "./cli-d9ad0rqj.js";
|
|
23
|
+
|
|
24
|
+
// packages/cli/src/demo/renderers/colors.ts
|
|
25
|
+
init_colors();
|
|
26
|
+
init_detection();
|
|
27
|
+
function renderColorsDemo(config, theme) {
|
|
28
|
+
const showCode = config.showCode ?? true;
|
|
29
|
+
const tokens = createTokens();
|
|
30
|
+
const colorEnabled = resolveTokenColorEnabled();
|
|
31
|
+
const lines = [];
|
|
32
|
+
lines.push(demoSection("Theme Colors (createTheme)", { case: "none" }));
|
|
33
|
+
lines.push("");
|
|
34
|
+
if (showCode) {
|
|
35
|
+
lines.push('import { createTheme } from "@outfitter/cli/render";');
|
|
36
|
+
lines.push("const theme = createTheme();");
|
|
37
|
+
lines.push("");
|
|
38
|
+
}
|
|
39
|
+
const { semantic } = getThemeMethodsByCategory();
|
|
40
|
+
for (const method of semantic) {
|
|
41
|
+
const text = getExample(method, config.examples);
|
|
42
|
+
const fn = theme[method];
|
|
43
|
+
const output = fn(text);
|
|
44
|
+
const code = `theme.${method}("${text}")`;
|
|
45
|
+
lines.push(`${code.padEnd(42)} \u2192 ${output}`);
|
|
46
|
+
}
|
|
47
|
+
lines.push("");
|
|
48
|
+
lines.push(demoSection("Utility Methods"));
|
|
49
|
+
lines.push("");
|
|
50
|
+
const { utility } = getThemeMethodsByCategory();
|
|
51
|
+
for (const method of utility) {
|
|
52
|
+
const text = getExample(method, config.examples);
|
|
53
|
+
const fn = theme[method];
|
|
54
|
+
const output = fn(text);
|
|
55
|
+
const code = `theme.${method}("${text}")`;
|
|
56
|
+
lines.push(`${code.padEnd(42)} \u2192 ${output}`);
|
|
57
|
+
}
|
|
58
|
+
lines.push("");
|
|
59
|
+
lines.push(demoSection("Direct Colors (applyColor)", { case: "none" }));
|
|
60
|
+
lines.push("");
|
|
61
|
+
if (showCode) {
|
|
62
|
+
lines.push('import { applyColor } from "@outfitter/cli/render";');
|
|
63
|
+
lines.push("");
|
|
64
|
+
}
|
|
65
|
+
const colors = [
|
|
66
|
+
"green",
|
|
67
|
+
"yellow",
|
|
68
|
+
"red",
|
|
69
|
+
"blue",
|
|
70
|
+
"cyan",
|
|
71
|
+
"magenta",
|
|
72
|
+
"gray"
|
|
73
|
+
];
|
|
74
|
+
for (const color of colors) {
|
|
75
|
+
const code = `applyColor("text", "${color}")`;
|
|
76
|
+
const output = applyColor("text", color);
|
|
77
|
+
lines.push(`${code.padEnd(32)} \u2192 ${output}`);
|
|
78
|
+
}
|
|
79
|
+
lines.push("");
|
|
80
|
+
lines.push(demoSection("Raw Tokens (createTokens)", { case: "none" }));
|
|
81
|
+
lines.push("");
|
|
82
|
+
if (showCode) {
|
|
83
|
+
lines.push('import { createTokens, ANSI } from "@outfitter/cli/render";');
|
|
84
|
+
lines.push("const t = createTokens();");
|
|
85
|
+
lines.push("");
|
|
86
|
+
}
|
|
87
|
+
const d = "$";
|
|
88
|
+
const tokenExamples = [
|
|
89
|
+
{
|
|
90
|
+
code: `\`${d}{t.success}Done${d}{ANSI.reset}\``,
|
|
91
|
+
token: tokens.success,
|
|
92
|
+
text: "Done"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
code: `\`${d}{t.error}Fail${d}{ANSI.reset}\``,
|
|
96
|
+
token: tokens.error,
|
|
97
|
+
text: "Fail"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
code: `\`${d}{t.warning}Warn${d}{ANSI.reset}\``,
|
|
101
|
+
token: tokens.warning,
|
|
102
|
+
text: "Warn"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
code: `\`${d}{t.info}Info${d}{ANSI.reset}\``,
|
|
106
|
+
token: tokens.info,
|
|
107
|
+
text: "Info"
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
for (const example of tokenExamples) {
|
|
111
|
+
const reset = example.token ? ANSI.reset : "";
|
|
112
|
+
const output = `${example.token}${example.text}${reset}`;
|
|
113
|
+
lines.push(`${example.code.padEnd(36)} \u2192 ${output}`);
|
|
114
|
+
}
|
|
115
|
+
lines.push("");
|
|
116
|
+
lines.push(demoSection("Environment"));
|
|
117
|
+
const noColor = hasNoColorEnv();
|
|
118
|
+
const forceColor = resolveForceColorEnv();
|
|
119
|
+
let forceColorDisplay;
|
|
120
|
+
if (forceColor === true) {
|
|
121
|
+
forceColorDisplay = theme.success("enabled");
|
|
122
|
+
} else if (forceColor === false) {
|
|
123
|
+
forceColorDisplay = theme.error("disabled");
|
|
124
|
+
} else {
|
|
125
|
+
forceColorDisplay = theme.muted("not set");
|
|
126
|
+
}
|
|
127
|
+
lines.push(`Colors: ${colorEnabled ? theme.success("enabled") : theme.muted("disabled")} ${theme.muted(colorEnabled ? "(TTY detected)" : "(non-TTY or NO_COLOR set)")}`);
|
|
128
|
+
lines.push(`NO_COLOR: ${noColor ? theme.warning("set") : theme.muted("not set")}`);
|
|
129
|
+
lines.push(`FORCE_COLOR: ${forceColorDisplay}`);
|
|
130
|
+
return lines.join(`
|
|
131
|
+
`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { renderColorsDemo };
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
BORDER_STYLE_META,
|
|
4
|
+
getBorderStyles
|
|
5
|
+
} from "./cli-kc84wmch.js";
|
|
6
|
+
import {
|
|
7
|
+
getExample
|
|
8
|
+
} from "./cli-xep6v2c0.js";
|
|
9
|
+
import {
|
|
10
|
+
demoSection
|
|
11
|
+
} from "./cli-34fqr7bp.js";
|
|
12
|
+
import {
|
|
13
|
+
createBox,
|
|
14
|
+
init_box,
|
|
15
|
+
renderBox
|
|
16
|
+
} from "./cli-vp88gxev.js";
|
|
17
|
+
|
|
18
|
+
// packages/cli/src/demo/renderers/box.ts
|
|
19
|
+
init_box();
|
|
20
|
+
function renderBoxDemo(config, theme) {
|
|
21
|
+
const showCode = config.showCode ?? true;
|
|
22
|
+
const showDescriptions = config.showDescriptions ?? true;
|
|
23
|
+
const lines = [];
|
|
24
|
+
lines.push(demoSection("Basic Box"));
|
|
25
|
+
lines.push("");
|
|
26
|
+
if (showCode) {
|
|
27
|
+
lines.push('import { renderBox } from "@outfitter/cli/render";');
|
|
28
|
+
lines.push("");
|
|
29
|
+
}
|
|
30
|
+
const content = getExample("boxContent", config.examples);
|
|
31
|
+
if (showCode) {
|
|
32
|
+
lines.push(`renderBox("${content}")`);
|
|
33
|
+
lines.push("");
|
|
34
|
+
}
|
|
35
|
+
lines.push(renderBox(content));
|
|
36
|
+
lines.push("");
|
|
37
|
+
lines.push(demoSection("Box with Title"));
|
|
38
|
+
lines.push("");
|
|
39
|
+
const title = getExample("boxTitle", config.examples);
|
|
40
|
+
if (showCode) {
|
|
41
|
+
lines.push(`renderBox("${content}", { title: "${title}" })`);
|
|
42
|
+
lines.push("");
|
|
43
|
+
}
|
|
44
|
+
lines.push(renderBox(content, { title }));
|
|
45
|
+
lines.push("");
|
|
46
|
+
lines.push(demoSection("Border Styles"));
|
|
47
|
+
lines.push("");
|
|
48
|
+
const styles = getBorderStyles().filter((s) => s !== "none");
|
|
49
|
+
for (const style of styles) {
|
|
50
|
+
const meta = BORDER_STYLE_META[style];
|
|
51
|
+
lines.push(`${meta.label.toUpperCase()}`);
|
|
52
|
+
if (showDescriptions) {
|
|
53
|
+
lines.push(theme.muted(meta.description));
|
|
54
|
+
}
|
|
55
|
+
lines.push("");
|
|
56
|
+
lines.push(renderBox("Content", { border: style }));
|
|
57
|
+
lines.push("");
|
|
58
|
+
}
|
|
59
|
+
lines.push(demoSection("Alignment"));
|
|
60
|
+
lines.push("");
|
|
61
|
+
const alignments = [
|
|
62
|
+
"left",
|
|
63
|
+
"center",
|
|
64
|
+
"right"
|
|
65
|
+
];
|
|
66
|
+
for (const align of alignments) {
|
|
67
|
+
if (showCode) {
|
|
68
|
+
lines.push(`renderBox("${align}", { width: 30, align: "${align}" })`);
|
|
69
|
+
}
|
|
70
|
+
lines.push(renderBox(align, { width: 30, align }));
|
|
71
|
+
lines.push("");
|
|
72
|
+
}
|
|
73
|
+
lines.push(demoSection("Multi-Line Content"));
|
|
74
|
+
lines.push("");
|
|
75
|
+
const multiLine = ["Line one", "Line two", "Line three"];
|
|
76
|
+
if (showCode) {
|
|
77
|
+
lines.push('renderBox(["Line one", "Line two", "Line three"])');
|
|
78
|
+
lines.push("");
|
|
79
|
+
}
|
|
80
|
+
lines.push(renderBox(multiLine));
|
|
81
|
+
lines.push("");
|
|
82
|
+
lines.push(demoSection("Sections with Dividers"));
|
|
83
|
+
lines.push("");
|
|
84
|
+
if (showDescriptions) {
|
|
85
|
+
lines.push(theme.muted("Use sections to separate content with internal dividers."));
|
|
86
|
+
lines.push("");
|
|
87
|
+
}
|
|
88
|
+
if (showCode) {
|
|
89
|
+
lines.push('renderBox("", {');
|
|
90
|
+
lines.push(' sections: ["Header", ["Line 1", "Line 2"], "Footer"],');
|
|
91
|
+
lines.push(' border: "rounded",');
|
|
92
|
+
lines.push("})");
|
|
93
|
+
lines.push("");
|
|
94
|
+
}
|
|
95
|
+
lines.push(renderBox("", {
|
|
96
|
+
sections: ["Header", ["Line 1", "Line 2"], "Footer"],
|
|
97
|
+
border: "rounded"
|
|
98
|
+
}));
|
|
99
|
+
lines.push("");
|
|
100
|
+
if (showDescriptions) {
|
|
101
|
+
lines.push(theme.muted("Example: Status panel with sections"));
|
|
102
|
+
lines.push("");
|
|
103
|
+
}
|
|
104
|
+
if (showCode) {
|
|
105
|
+
lines.push('renderBox("", {');
|
|
106
|
+
lines.push(" sections: [");
|
|
107
|
+
lines.push(' "System Status",');
|
|
108
|
+
lines.push(' ["CPU: 45%", "Memory: 2.1 GB", "Disk: 120 GB free"],');
|
|
109
|
+
lines.push(' "Updated: 2 min ago"');
|
|
110
|
+
lines.push(" ],");
|
|
111
|
+
lines.push(' border: "single",');
|
|
112
|
+
lines.push(" width: 30,");
|
|
113
|
+
lines.push("})");
|
|
114
|
+
lines.push("");
|
|
115
|
+
}
|
|
116
|
+
lines.push(renderBox("", {
|
|
117
|
+
sections: [
|
|
118
|
+
"System Status",
|
|
119
|
+
["CPU: 45%", "Memory: 2.1 GB", "Disk: 120 GB free"],
|
|
120
|
+
"Updated: 2 min ago"
|
|
121
|
+
],
|
|
122
|
+
border: "single",
|
|
123
|
+
width: 30
|
|
124
|
+
}));
|
|
125
|
+
lines.push("");
|
|
126
|
+
lines.push(demoSection("Partial Borders"));
|
|
127
|
+
lines.push("");
|
|
128
|
+
if (showDescriptions) {
|
|
129
|
+
lines.push(theme.muted("Control which borders to render with the borders option."));
|
|
130
|
+
lines.push("");
|
|
131
|
+
}
|
|
132
|
+
if (showCode) {
|
|
133
|
+
lines.push('renderBox("Top and bottom only", {');
|
|
134
|
+
lines.push(" borders: { top: true, bottom: true, left: false, right: false }");
|
|
135
|
+
lines.push("})");
|
|
136
|
+
lines.push("");
|
|
137
|
+
}
|
|
138
|
+
lines.push(renderBox("Top and bottom only", {
|
|
139
|
+
borders: { top: true, bottom: true, left: false, right: false }
|
|
140
|
+
}));
|
|
141
|
+
lines.push("");
|
|
142
|
+
if (showCode) {
|
|
143
|
+
lines.push('renderBox("Left and right only", {');
|
|
144
|
+
lines.push(" borders: { top: false, bottom: false, left: true, right: true }");
|
|
145
|
+
lines.push("})");
|
|
146
|
+
lines.push("");
|
|
147
|
+
}
|
|
148
|
+
lines.push(renderBox("Left and right only", {
|
|
149
|
+
borders: { top: false, bottom: false, left: true, right: true }
|
|
150
|
+
}));
|
|
151
|
+
lines.push("");
|
|
152
|
+
lines.push(demoSection("Margin"));
|
|
153
|
+
lines.push("");
|
|
154
|
+
if (showDescriptions) {
|
|
155
|
+
lines.push(theme.muted("Add spacing outside the box with margin."));
|
|
156
|
+
lines.push("");
|
|
157
|
+
}
|
|
158
|
+
if (showCode) {
|
|
159
|
+
lines.push('renderBox("With margin", { margin: { left: 4 } })');
|
|
160
|
+
lines.push("");
|
|
161
|
+
}
|
|
162
|
+
lines.push(renderBox("With margin", { margin: { left: 4 } }));
|
|
163
|
+
lines.push("");
|
|
164
|
+
lines.push(demoSection("Individual Padding"));
|
|
165
|
+
lines.push("");
|
|
166
|
+
if (showDescriptions) {
|
|
167
|
+
lines.push(theme.muted("Control padding per side with an object."));
|
|
168
|
+
lines.push("");
|
|
169
|
+
}
|
|
170
|
+
if (showCode) {
|
|
171
|
+
lines.push('renderBox("Custom padding", {');
|
|
172
|
+
lines.push(" padding: { top: 1, bottom: 1, left: 3, right: 1 }");
|
|
173
|
+
lines.push("})");
|
|
174
|
+
lines.push("");
|
|
175
|
+
}
|
|
176
|
+
lines.push(renderBox("Custom padding", {
|
|
177
|
+
padding: { top: 1, bottom: 1, left: 3, right: 1 }
|
|
178
|
+
}));
|
|
179
|
+
lines.push("");
|
|
180
|
+
lines.push(demoSection("Nested Boxes"));
|
|
181
|
+
lines.push("");
|
|
182
|
+
if (showDescriptions) {
|
|
183
|
+
lines.push(theme.muted("Use createBox() to create composable boxes with metadata."));
|
|
184
|
+
lines.push("");
|
|
185
|
+
}
|
|
186
|
+
if (showCode) {
|
|
187
|
+
lines.push('const inner = createBox("Inner content", { border: "rounded" });');
|
|
188
|
+
lines.push('const outer = createBox(inner, { border: "double", title: "Container" });');
|
|
189
|
+
lines.push("console.log(outer.output);");
|
|
190
|
+
lines.push("");
|
|
191
|
+
}
|
|
192
|
+
const inner = createBox("Inner content", { border: "rounded" });
|
|
193
|
+
const outer = createBox(inner, { border: "double", title: "Container" });
|
|
194
|
+
lines.push(outer.output);
|
|
195
|
+
lines.push("");
|
|
196
|
+
if (showDescriptions) {
|
|
197
|
+
lines.push(theme.muted("Boxes can be nested to any depth."));
|
|
198
|
+
lines.push("");
|
|
199
|
+
}
|
|
200
|
+
if (showCode) {
|
|
201
|
+
lines.push('const level1 = createBox("Core", { border: "single" });');
|
|
202
|
+
lines.push('const level2 = createBox(level1, { border: "rounded", title: "Middle" });');
|
|
203
|
+
lines.push('const level3 = createBox(level2, { border: "double", title: "Outer" });');
|
|
204
|
+
lines.push("");
|
|
205
|
+
}
|
|
206
|
+
const level1 = createBox("Core", { border: "single" });
|
|
207
|
+
const level2 = createBox(level1, { border: "rounded", title: "Middle" });
|
|
208
|
+
const level3 = createBox(level2, { border: "double", title: "Outer" });
|
|
209
|
+
lines.push(level3.output);
|
|
210
|
+
return lines.join(`
|
|
211
|
+
`);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export { renderBoxDemo };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress bar rendering utilities.
|
|
3
|
+
*
|
|
4
|
+
* Renders progress bars with filled and empty segments.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options for {@link renderProgress}.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const options: ProgressOptions = {
|
|
14
|
+
* current: 75,
|
|
15
|
+
* total: 100,
|
|
16
|
+
* width: 20,
|
|
17
|
+
* showPercent: true,
|
|
18
|
+
* };
|
|
19
|
+
* // Renders: [###############.....] 75%
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
interface ProgressOptions {
|
|
23
|
+
/** Current progress value */
|
|
24
|
+
current: number;
|
|
25
|
+
/** Total value (100% when current equals total) */
|
|
26
|
+
total: number;
|
|
27
|
+
/** Width of the progress bar in characters (default: 20) */
|
|
28
|
+
width?: number;
|
|
29
|
+
/** Whether to show percentage after the bar (default: false) */
|
|
30
|
+
showPercent?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders a progress bar with filled and empty segments.
|
|
34
|
+
*
|
|
35
|
+
* Uses unicode block characters: filled segments, empty segments.
|
|
36
|
+
* Optionally displays percentage after the bar.
|
|
37
|
+
*
|
|
38
|
+
* Handles edge cases:
|
|
39
|
+
* - `total <= 0`: Returns empty bar with 0%
|
|
40
|
+
* - `current > total`: Caps at 100%
|
|
41
|
+
* - `current < 0`: Floors at 0%
|
|
42
|
+
*
|
|
43
|
+
* @param options - Progress bar configuration
|
|
44
|
+
* @returns Formatted progress bar string
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* renderProgress({ current: 50, total: 100 });
|
|
49
|
+
* // [##########..........]
|
|
50
|
+
*
|
|
51
|
+
* renderProgress({ current: 75, total: 100, showPercent: true });
|
|
52
|
+
* // [###############.....] 75%
|
|
53
|
+
*
|
|
54
|
+
* renderProgress({ current: 30, total: 100, width: 10 });
|
|
55
|
+
* // [###.......]
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare function renderProgress(options: ProgressOptions): string;
|
|
59
|
+
export { ProgressOptions, renderProgress };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExampleTexts } from "./cli-qjfc3j11";
|
|
2
|
+
/**
|
|
3
|
+
* Default example texts used when no custom examples are provided.
|
|
4
|
+
*
|
|
5
|
+
* These defaults are generic enough to work for any CLI while still
|
|
6
|
+
* being meaningful and demonstrative.
|
|
7
|
+
*/
|
|
8
|
+
declare const DEFAULT_EXAMPLES: ExampleTexts;
|
|
9
|
+
/**
|
|
10
|
+
* Resolves example text with custom overrides.
|
|
11
|
+
*
|
|
12
|
+
* @param key - The example text key
|
|
13
|
+
* @param custom - Optional custom examples
|
|
14
|
+
* @returns The example text (custom if provided, default otherwise)
|
|
15
|
+
*/
|
|
16
|
+
declare function getExample<K extends keyof ExampleTexts>(key: K, custom?: Partial<ExampleTexts>): ExampleTexts[K];
|
|
17
|
+
export { DEFAULT_EXAMPLES, getExample };
|