@outfitter/cli 0.1.0-rc.2 → 0.1.0
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.d.ts +12 -1
- package/dist/actions.js +170 -3
- 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.js +1 -1
- package/dist/colors/index.d.ts +3 -0
- package/dist/colors/index.js +18 -0
- package/dist/command.d.ts +40 -3
- package/dist/command.js +45 -3
- 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 -8
- package/dist/index.js +9 -43
- package/dist/input.d.ts +163 -2
- package/dist/input.js +425 -11
- package/dist/list/index.d.ts +3 -0
- package/dist/list/index.js +9 -0
- package/dist/output.js +1 -1
- package/dist/pagination.d.ts +62 -2
- package/dist/pagination.js +84 -6
- 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 +1 -1
- package/dist/render/colors.js +6 -3
- package/dist/render/date.js +1 -1
- package/dist/render/format-relative.js +1 -1
- package/dist/render/format.js +1 -1
- package/dist/render/heading.d.ts +3 -0
- package/dist/render/heading.js +14 -0
- package/dist/render/index.d.ts +26 -7
- package/dist/render/index.js +160 -26
- package/dist/render/indicators.d.ts +2 -0
- package/dist/render/indicators.js +14 -0
- package/dist/render/json.js +1 -1
- package/dist/render/layout.d.ts +5 -0
- package/dist/render/layout.js +25 -0
- package/dist/render/list.d.ts +2 -2
- package/dist/render/list.js +2 -2
- package/dist/render/markdown.js +4 -4
- package/dist/render/progress.js +1 -1
- package/dist/render/separator.d.ts +3 -0
- package/dist/render/separator.js +14 -0
- package/dist/render/shapes.js +10 -9
- 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 +2 -1
- package/dist/render/table.js +6 -5
- package/dist/render/text.d.ts +1 -1
- package/dist/render/text.js +7 -4
- package/dist/render/tree.d.ts +2 -2
- package/dist/render/tree.js +5 -3
- 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-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-3t2zaenc.d.ts +59 -0
- package/dist/shared/@outfitter/{cli-dds0qqvm.d.ts → cli-4cb5g831.d.ts} +2 -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-74ba31gz.js +134 -0
- package/dist/shared/@outfitter/cli-7gnrb8cr.js +214 -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-8bwaw3pz.js +7 -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-ag0w4pk0.js → cli-9nbyj2bt.js} +60 -21
- package/dist/shared/@outfitter/{cli-azzk8a1d.js → cli-afhjqmg3.js} +7 -3
- 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-bcmcaz1b.js +23 -0
- package/dist/shared/@outfitter/cli-bf3vma4q.js +61 -0
- package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +53 -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-jbj78ac5.js → cli-d9ad0rqj.js} +6 -1
- 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-en6zn6sj.js +1 -0
- package/dist/shared/@outfitter/cli-ep2cvtk8.js +48 -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-j4n8gaf3.js +95 -0
- package/dist/shared/@outfitter/cli-jejfypgf.js +85 -0
- package/dist/shared/@outfitter/{cli-wqc652mx.js → cli-jhcdwvpn.js} +8 -8
- package/dist/shared/@outfitter/{cli-v9mjsvjh.js → cli-jjemfdta.js} +13 -46
- package/dist/shared/@outfitter/cli-kc84wmch.js +267 -0
- package/dist/shared/@outfitter/cli-ktqme80d.js +7 -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-2y3kxew8.d.ts → cli-qj83y5wj.d.ts} +22 -9
- 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-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-n51t773m.d.ts → cli-xsaheemc.d.ts} +44 -4
- package/dist/shared/@outfitter/cli-xvqtqjxk.js +82 -0
- package/dist/shared/@outfitter/cli-y25tt8nc.d.ts +48 -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.js +5 -2
- package/dist/terminal/index.js +6 -2
- 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.js +1 -1
- package/package.json +168 -54
- package/dist/shared/@outfitter/cli-2vs2gxa8.js +0 -429
- package/dist/shared/@outfitter/cli-2yq94zst.d.ts +0 -39
- package/dist/shared/@outfitter/cli-6xc869x1.js +0 -26
- package/dist/shared/@outfitter/cli-7km1e58p.js +0 -85
- package/dist/shared/@outfitter/cli-8r0bnyyx.js +0 -43
- package/dist/shared/@outfitter/cli-afecwfrn.d.ts +0 -13
- package/dist/shared/@outfitter/cli-bt423m6y.js +0 -4
- package/dist/shared/@outfitter/cli-d4fegbad.d.ts +0 -66
- package/dist/shared/@outfitter/cli-e0ecw3x1.js +0 -64
- package/dist/shared/@outfitter/cli-fheaaa6b.js +0 -25
- package/dist/shared/@outfitter/cli-j361wp3g.d.ts +0 -41
- package/dist/shared/@outfitter/cli-p0m2fc51.js +0 -172
- package/dist/shared/@outfitter/cli-tyajr8qa.d.ts +0 -63
- package/dist/shared/@outfitter/cli-zs6jy1am.d.ts +0 -164
|
@@ -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,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 };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
__esm
|
|
4
|
+
} from "./cli-v1tzwxkt.js";
|
|
5
|
+
|
|
6
|
+
// packages/cli/src/render/borders.ts
|
|
7
|
+
function getBorderCharacters(style) {
|
|
8
|
+
return BORDERS[style];
|
|
9
|
+
}
|
|
10
|
+
function drawHorizontalLine(width, chars, position, columnWidths) {
|
|
11
|
+
if (!chars.horizontal) {
|
|
12
|
+
return "";
|
|
13
|
+
}
|
|
14
|
+
const positionChars = {
|
|
15
|
+
top: { left: chars.topLeft, right: chars.topRight, cross: chars.topT },
|
|
16
|
+
middle: { left: chars.leftT, right: chars.rightT, cross: chars.cross },
|
|
17
|
+
bottom: {
|
|
18
|
+
left: chars.bottomLeft,
|
|
19
|
+
right: chars.bottomRight,
|
|
20
|
+
cross: chars.bottomT
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const { left, right, cross: intersection } = positionChars[position];
|
|
24
|
+
if (!columnWidths || columnWidths.length <= 1) {
|
|
25
|
+
return `${left}${chars.horizontal.repeat(width)}${right}`;
|
|
26
|
+
}
|
|
27
|
+
const columnsWidth = columnWidths.reduce((sum, w) => sum + w, 0);
|
|
28
|
+
const intersectionsWidth = columnWidths.length - 1;
|
|
29
|
+
const actualWidth = columnsWidth + intersectionsWidth;
|
|
30
|
+
const adjustedWidths = [...columnWidths];
|
|
31
|
+
if (actualWidth !== width && adjustedWidths.length > 0) {
|
|
32
|
+
const lastIndex = adjustedWidths.length - 1;
|
|
33
|
+
const lastWidth = adjustedWidths[lastIndex] ?? 0;
|
|
34
|
+
adjustedWidths[lastIndex] = Math.max(0, lastWidth + (width - actualWidth));
|
|
35
|
+
}
|
|
36
|
+
const segments = adjustedWidths.map((colWidth) => chars.horizontal.repeat(colWidth));
|
|
37
|
+
return `${left}${segments.join(intersection)}${right}`;
|
|
38
|
+
}
|
|
39
|
+
var BORDERS;
|
|
40
|
+
var init_borders = __esm(() => {
|
|
41
|
+
BORDERS = {
|
|
42
|
+
single: {
|
|
43
|
+
topLeft: "\u250C",
|
|
44
|
+
topRight: "\u2510",
|
|
45
|
+
bottomLeft: "\u2514",
|
|
46
|
+
bottomRight: "\u2518",
|
|
47
|
+
horizontal: "\u2500",
|
|
48
|
+
vertical: "\u2502",
|
|
49
|
+
topT: "\u252C",
|
|
50
|
+
bottomT: "\u2534",
|
|
51
|
+
leftT: "\u251C",
|
|
52
|
+
rightT: "\u2524",
|
|
53
|
+
cross: "\u253C"
|
|
54
|
+
},
|
|
55
|
+
double: {
|
|
56
|
+
topLeft: "\u2554",
|
|
57
|
+
topRight: "\u2557",
|
|
58
|
+
bottomLeft: "\u255A",
|
|
59
|
+
bottomRight: "\u255D",
|
|
60
|
+
horizontal: "\u2550",
|
|
61
|
+
vertical: "\u2551",
|
|
62
|
+
topT: "\u2566",
|
|
63
|
+
bottomT: "\u2569",
|
|
64
|
+
leftT: "\u2560",
|
|
65
|
+
rightT: "\u2563",
|
|
66
|
+
cross: "\u256C"
|
|
67
|
+
},
|
|
68
|
+
rounded: {
|
|
69
|
+
topLeft: "\u256D",
|
|
70
|
+
topRight: "\u256E",
|
|
71
|
+
bottomLeft: "\u2570",
|
|
72
|
+
bottomRight: "\u256F",
|
|
73
|
+
horizontal: "\u2500",
|
|
74
|
+
vertical: "\u2502",
|
|
75
|
+
topT: "\u252C",
|
|
76
|
+
bottomT: "\u2534",
|
|
77
|
+
leftT: "\u251C",
|
|
78
|
+
rightT: "\u2524",
|
|
79
|
+
cross: "\u253C"
|
|
80
|
+
},
|
|
81
|
+
heavy: {
|
|
82
|
+
topLeft: "\u250F",
|
|
83
|
+
topRight: "\u2513",
|
|
84
|
+
bottomLeft: "\u2517",
|
|
85
|
+
bottomRight: "\u251B",
|
|
86
|
+
horizontal: "\u2501",
|
|
87
|
+
vertical: "\u2503",
|
|
88
|
+
topT: "\u2533",
|
|
89
|
+
bottomT: "\u253B",
|
|
90
|
+
leftT: "\u2523",
|
|
91
|
+
rightT: "\u252B",
|
|
92
|
+
cross: "\u254B"
|
|
93
|
+
},
|
|
94
|
+
ascii: {
|
|
95
|
+
topLeft: "+",
|
|
96
|
+
topRight: "+",
|
|
97
|
+
bottomLeft: "+",
|
|
98
|
+
bottomRight: "+",
|
|
99
|
+
horizontal: "-",
|
|
100
|
+
vertical: "|",
|
|
101
|
+
topT: "+",
|
|
102
|
+
bottomT: "+",
|
|
103
|
+
leftT: "+",
|
|
104
|
+
rightT: "+",
|
|
105
|
+
cross: "+"
|
|
106
|
+
},
|
|
107
|
+
none: {
|
|
108
|
+
topLeft: "",
|
|
109
|
+
topRight: "",
|
|
110
|
+
bottomLeft: "",
|
|
111
|
+
bottomRight: "",
|
|
112
|
+
horizontal: "",
|
|
113
|
+
vertical: "",
|
|
114
|
+
topT: "",
|
|
115
|
+
bottomT: "",
|
|
116
|
+
leftT: "",
|
|
117
|
+
rightT: "",
|
|
118
|
+
cross: ""
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export { BORDERS, getBorderCharacters, drawHorizontalLine, init_borders };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
defaultTheme
|
|
4
|
+
} from "./cli-cs45xd6q.js";
|
|
5
|
+
import {
|
|
6
|
+
BORDERS,
|
|
7
|
+
init_borders
|
|
8
|
+
} from "./cli-85fg2vr5.js";
|
|
9
|
+
|
|
10
|
+
// packages/cli/src/theme/presets/bold.ts
|
|
11
|
+
init_borders();
|
|
12
|
+
var boldTheme = {
|
|
13
|
+
...defaultTheme,
|
|
14
|
+
name: "bold",
|
|
15
|
+
border: "heavy",
|
|
16
|
+
borderChars: BORDERS.heavy,
|
|
17
|
+
treeGuide: "heavy"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { boldTheme };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PasswordPromptOptions, PromptResult, TextPromptOptions } from "./cli-3f12z5kf";
|
|
2
|
+
/**
|
|
3
|
+
* Prompts for text input with Result wrapping.
|
|
4
|
+
*
|
|
5
|
+
* @param options - Text prompt options
|
|
6
|
+
* @returns Ok with value or Err with CancelledError
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { promptText } from "@outfitter/cli/prompt";
|
|
11
|
+
*
|
|
12
|
+
* const result = await promptText({
|
|
13
|
+
* message: "What is your name?",
|
|
14
|
+
* placeholder: "Enter your name",
|
|
15
|
+
* validate: (v) => v.length > 0 || "Name is required",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* if (result.isOk()) {
|
|
19
|
+
* console.log(`Hello, ${result.value}!`);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare function promptText(options: TextPromptOptions): PromptResult<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Prompts for password input with Result wrapping.
|
|
26
|
+
*
|
|
27
|
+
* @param options - Password prompt options
|
|
28
|
+
* @returns Ok with value or Err with CancelledError
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { promptPassword } from "@outfitter/cli/prompt";
|
|
33
|
+
*
|
|
34
|
+
* const result = await promptPassword({
|
|
35
|
+
* message: "Enter your password:",
|
|
36
|
+
* validate: (v) => v.length >= 8 || "Password too short",
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare function promptPassword(options: PasswordPromptOptions): PromptResult<string>;
|
|
41
|
+
export { promptText, promptPassword };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { BorderStyle } from "./cli-fakncnjp";
|
|
2
|
+
/**
|
|
3
|
+
* Text alignment options for box content.
|
|
4
|
+
*/
|
|
5
|
+
type BoxAlign = "left" | "center" | "right";
|
|
6
|
+
/**
|
|
7
|
+
* Options for customizing box rendering.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Box with title and rounded corners
|
|
12
|
+
* renderBox("Content", {
|
|
13
|
+
* title: "Status",
|
|
14
|
+
* border: "rounded",
|
|
15
|
+
* padding: 1,
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Fixed-width centered box
|
|
19
|
+
* renderBox("Centered", {
|
|
20
|
+
* width: 40,
|
|
21
|
+
* align: "center",
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Spacing configuration for individual sides.
|
|
27
|
+
*/
|
|
28
|
+
interface BoxSpacing {
|
|
29
|
+
top?: number;
|
|
30
|
+
right?: number;
|
|
31
|
+
bottom?: number;
|
|
32
|
+
left?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Border visibility configuration for individual sides.
|
|
36
|
+
*/
|
|
37
|
+
interface BoxBorders {
|
|
38
|
+
top?: boolean;
|
|
39
|
+
right?: boolean;
|
|
40
|
+
bottom?: boolean;
|
|
41
|
+
left?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface BoxOptions {
|
|
44
|
+
/**
|
|
45
|
+
* Border style to use.
|
|
46
|
+
* @default "single"
|
|
47
|
+
*/
|
|
48
|
+
border?: BorderStyle;
|
|
49
|
+
/**
|
|
50
|
+
* Control which borders to render.
|
|
51
|
+
* @default { top: true, right: true, bottom: true, left: true }
|
|
52
|
+
*/
|
|
53
|
+
borders?: BoxBorders;
|
|
54
|
+
/**
|
|
55
|
+
* Internal padding (spaces between border and content).
|
|
56
|
+
* Can be a single number for all sides or an object for individual sides.
|
|
57
|
+
* @default 1
|
|
58
|
+
*/
|
|
59
|
+
padding?: number | BoxSpacing;
|
|
60
|
+
/**
|
|
61
|
+
* External margin (spacing outside the box).
|
|
62
|
+
* Can be a single number for all sides or an object for individual sides.
|
|
63
|
+
*/
|
|
64
|
+
margin?: number | BoxSpacing;
|
|
65
|
+
/**
|
|
66
|
+
* Fixed width for the box. If not specified, auto-fits to content.
|
|
67
|
+
*/
|
|
68
|
+
width?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Optional title to display in the top border.
|
|
71
|
+
*/
|
|
72
|
+
title?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Content alignment within the box.
|
|
75
|
+
* @default "left"
|
|
76
|
+
*/
|
|
77
|
+
align?: BoxAlign;
|
|
78
|
+
/**
|
|
79
|
+
* Content sections separated by internal dividers.
|
|
80
|
+
* Each section can be a string or string[].
|
|
81
|
+
* When provided, takes precedence over the content parameter.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* renderBox("", {
|
|
86
|
+
* sections: [
|
|
87
|
+
* "Header",
|
|
88
|
+
* ["Line 1", "Line 2"],
|
|
89
|
+
* "Footer"
|
|
90
|
+
* ],
|
|
91
|
+
* border: "single"
|
|
92
|
+
* });
|
|
93
|
+
* // ┌─────────────────┐
|
|
94
|
+
* // │ Header │
|
|
95
|
+
* // ├─────────────────┤
|
|
96
|
+
* // │ Line 1 │
|
|
97
|
+
* // │ Line 2 │
|
|
98
|
+
* // ├─────────────────┤
|
|
99
|
+
* // │ Footer │
|
|
100
|
+
* // └─────────────────┘
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
sections?: Array<string | string[]>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A rendered box with metadata for composition.
|
|
107
|
+
*/
|
|
108
|
+
interface Box {
|
|
109
|
+
/** Rendered string representation */
|
|
110
|
+
readonly output: string;
|
|
111
|
+
/** Width in characters */
|
|
112
|
+
readonly width: number;
|
|
113
|
+
/** Height in lines */
|
|
114
|
+
readonly height: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Content that can be rendered inside a box.
|
|
118
|
+
* - string: Plain text content
|
|
119
|
+
* - string[]: Multi-line content
|
|
120
|
+
* - Box: Nested box (rendered string with metadata)
|
|
121
|
+
*/
|
|
122
|
+
type BoxContent = string | string[] | Box;
|
|
123
|
+
/**
|
|
124
|
+
* Normalized spacing with all four sides defined.
|
|
125
|
+
*/
|
|
126
|
+
interface NormalizedSpacing {
|
|
127
|
+
top: number;
|
|
128
|
+
right: number;
|
|
129
|
+
bottom: number;
|
|
130
|
+
left: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Normalized borders with all four sides defined.
|
|
134
|
+
*/
|
|
135
|
+
interface NormalizedBorders {
|
|
136
|
+
top: boolean;
|
|
137
|
+
right: boolean;
|
|
138
|
+
bottom: boolean;
|
|
139
|
+
left: boolean;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Normalizes padding input to have all four sides.
|
|
143
|
+
* For backward compatibility, when padding is a number it only applies to horizontal (left/right).
|
|
144
|
+
* When padding is an object, all sides can be specified.
|
|
145
|
+
*/
|
|
146
|
+
declare function normalizePadding(padding: number | BoxSpacing | undefined, defaultValue: number): NormalizedSpacing;
|
|
147
|
+
/**
|
|
148
|
+
* Normalizes margin input to have all four sides.
|
|
149
|
+
* When margin is a number, it applies to all sides.
|
|
150
|
+
*/
|
|
151
|
+
declare function normalizeMargin(margin: number | BoxSpacing | undefined, defaultValue: number): NormalizedSpacing;
|
|
152
|
+
/**
|
|
153
|
+
* Normalizes borders input to have all four sides.
|
|
154
|
+
*/
|
|
155
|
+
declare function normalizeBorders(borders: BoxBorders | undefined): NormalizedBorders;
|
|
156
|
+
/**
|
|
157
|
+
* Renders content within a bordered panel.
|
|
158
|
+
*
|
|
159
|
+
* Creates a box with Unicode borders around the content. Supports multiple
|
|
160
|
+
* border styles, titles, padding, and alignment options.
|
|
161
|
+
*
|
|
162
|
+
* @param content - The content to render (string or array of strings)
|
|
163
|
+
* @param options - Optional configuration for border style, padding, etc.
|
|
164
|
+
* @returns Formatted box string
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* // Simple box
|
|
169
|
+
* console.log(renderBox("Hello, world!"));
|
|
170
|
+
* // ┌───────────────┐
|
|
171
|
+
* // │ Hello, world! │
|
|
172
|
+
* // └───────────────┘
|
|
173
|
+
*
|
|
174
|
+
* // Box with title
|
|
175
|
+
* console.log(renderBox("All systems go", { title: "Status" }));
|
|
176
|
+
* // ┌─ Status ──────┐
|
|
177
|
+
* // │ All systems go │
|
|
178
|
+
* // └────────────────┘
|
|
179
|
+
*
|
|
180
|
+
* // Rounded box with padding
|
|
181
|
+
* console.log(renderBox(["Line 1", "Line 2"], {
|
|
182
|
+
* border: "rounded",
|
|
183
|
+
* padding: 2,
|
|
184
|
+
* }));
|
|
185
|
+
* // ╭──────────────╮
|
|
186
|
+
* // │ │
|
|
187
|
+
* // │ Line 1 │
|
|
188
|
+
* // │ Line 2 │
|
|
189
|
+
* // │ │
|
|
190
|
+
* // ╰──────────────╯
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare function renderBox(content: string | string[], options?: BoxOptions): string;
|
|
194
|
+
/**
|
|
195
|
+
* Creates a Box object that can be composed with other boxes.
|
|
196
|
+
*
|
|
197
|
+
* Unlike `renderBox` which returns a string, `createBox` returns a Box object
|
|
198
|
+
* with metadata (width, height) that enables nested composition.
|
|
199
|
+
*
|
|
200
|
+
* @param content - The content to render (string, string[], Box, or array of mixed)
|
|
201
|
+
* @param options - Optional configuration for border style, padding, etc.
|
|
202
|
+
* @returns Box object with output, width, and height
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* // Simple box
|
|
207
|
+
* const box = createBox("Hello");
|
|
208
|
+
* console.log(box.output);
|
|
209
|
+
* console.log(`Width: ${box.width}, Height: ${box.height}`);
|
|
210
|
+
*
|
|
211
|
+
* // Nested boxes
|
|
212
|
+
* const inner = createBox("Inner", { border: "rounded" });
|
|
213
|
+
* const outer = createBox(inner, { border: "double", title: "Container" });
|
|
214
|
+
* console.log(outer.output);
|
|
215
|
+
* // ╔═ Container ═══════════════╗
|
|
216
|
+
* // ║ ╭───────────────────────╮ ║
|
|
217
|
+
* // ║ │ Inner │ ║
|
|
218
|
+
* // ║ ╰───────────────────────╯ ║
|
|
219
|
+
* // ╚═══════════════════════════╝
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
declare function createBox(content: BoxContent | BoxContent[], options?: BoxOptions): Box;
|
|
223
|
+
export { BoxAlign, BoxSpacing, BoxBorders, BoxOptions, Box, BoxContent, NormalizedSpacing, NormalizedBorders, normalizePadding, normalizeMargin, normalizeBorders, renderBox, createBox };
|