@outfitter/cli 0.3.0 → 0.4.1
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 +48 -4
- package/dist/actions.js +0 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -2
- package/dist/{render → colors}/colors.d.ts +1 -1
- package/dist/{render → colors}/colors.js +2 -6
- package/dist/colors/index.d.ts +1 -1
- package/dist/colors/index.js +3 -4
- package/dist/command.d.ts +2 -2
- package/dist/command.js +11 -2
- package/dist/completion.d.ts +36 -0
- package/dist/completion.js +91 -0
- package/dist/flags.d.ts +167 -0
- package/dist/flags.js +31 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -4
- package/dist/input.d.ts +3 -26
- package/dist/input.js +1 -31
- package/dist/output.d.ts +2 -2
- package/dist/output.js +0 -1
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +0 -2
- package/dist/query.d.ts +50 -0
- package/dist/query.js +51 -0
- package/dist/shared/@outfitter/cli-b2zk8fb3.js +357 -0
- package/dist/shared/@outfitter/{cli-d9ad0rqj.js → cli-jbj78ac5.js} +1 -6
- package/dist/shared/@outfitter/{cli-e6yv2764.d.ts → cli-k0yvzn6d.d.ts} +1 -1
- package/dist/shared/@outfitter/{cli-ttt7r0j7.d.ts → cli-md9347gn.d.ts} +155 -13
- package/dist/shared/@outfitter/{cli-5g6rkv3d.js → cli-rk9zagkm.js} +24 -32
- package/dist/shared/@outfitter/{cli-4h4rpdra.js → cli-zahqsaby.js} +32 -10
- package/dist/terminal/detection.js +1 -5
- package/dist/terminal/index.js +1 -6
- package/dist/{shared/@outfitter/cli-4cb5g831.d.ts → text.d.ts} +1 -1
- package/dist/{shared/@outfitter/cli-mwxsh3sr.js → text.js} +15 -14
- package/dist/types.d.ts +2 -2
- package/dist/types.js +0 -2
- package/dist/verbs.d.ts +50 -0
- package/dist/verbs.js +61 -0
- package/package.json +50 -204
- package/dist/borders/index.d.ts +0 -3
- package/dist/borders/index.js +0 -13
- package/dist/box/index.d.ts +0 -4
- package/dist/box/index.js +0 -13
- package/dist/demo/index.d.ts +0 -78
- package/dist/demo/index.js +0 -148
- package/dist/demo/registry.d.ts +0 -7
- package/dist/demo/registry.js +0 -28
- package/dist/demo/renderers/borders.d.ts +0 -7
- package/dist/demo/renderers/borders.js +0 -17
- package/dist/demo/renderers/box.d.ts +0 -7
- package/dist/demo/renderers/box.js +0 -18
- package/dist/demo/renderers/colors.d.ts +0 -7
- package/dist/demo/renderers/colors.js +0 -18
- package/dist/demo/renderers/indicators.d.ts +0 -7
- package/dist/demo/renderers/indicators.js +0 -17
- package/dist/demo/renderers/list.d.ts +0 -7
- package/dist/demo/renderers/list.js +0 -19
- package/dist/demo/renderers/markdown.d.ts +0 -7
- package/dist/demo/renderers/markdown.js +0 -18
- package/dist/demo/renderers/progress.d.ts +0 -7
- package/dist/demo/renderers/progress.js +0 -17
- package/dist/demo/renderers/spinner.d.ts +0 -7
- package/dist/demo/renderers/spinner.js +0 -19
- package/dist/demo/renderers/table.d.ts +0 -7
- package/dist/demo/renderers/table.js +0 -19
- package/dist/demo/renderers/text.d.ts +0 -7
- package/dist/demo/renderers/text.js +0 -16
- package/dist/demo/renderers/tree.d.ts +0 -7
- package/dist/demo/renderers/tree.js +0 -18
- package/dist/demo/section.d.ts +0 -5
- package/dist/demo/section.js +0 -23
- package/dist/demo/templates.d.ts +0 -4
- package/dist/demo/templates.js +0 -10
- package/dist/demo/types.d.ts +0 -3
- package/dist/demo/types.js +0 -8
- package/dist/list/index.d.ts +0 -3
- package/dist/list/index.js +0 -9
- package/dist/preset/full.d.ts +0 -14
- package/dist/preset/full.js +0 -41
- package/dist/preset/standard.d.ts +0 -11
- package/dist/preset/standard.js +0 -30
- package/dist/prompt/confirm.d.ts +0 -4
- package/dist/prompt/confirm.js +0 -9
- package/dist/prompt/group.d.ts +0 -4
- package/dist/prompt/group.js +0 -9
- package/dist/prompt/index.d.ts +0 -7
- package/dist/prompt/index.js +0 -32
- package/dist/prompt/select.d.ts +0 -4
- package/dist/prompt/select.js +0 -11
- package/dist/prompt/text.d.ts +0 -4
- package/dist/prompt/text.js +0 -11
- package/dist/prompt/types.d.ts +0 -3
- package/dist/prompt/types.js +0 -8
- package/dist/prompt/validators.d.ts +0 -2
- package/dist/prompt/validators.js +0 -8
- package/dist/render/borders.d.ts +0 -2
- package/dist/render/borders.js +0 -15
- package/dist/render/box.d.ts +0 -3
- package/dist/render/box.js +0 -23
- package/dist/render/date.d.ts +0 -2
- package/dist/render/date.js +0 -12
- package/dist/render/format-relative.d.ts +0 -2
- package/dist/render/format-relative.js +0 -8
- package/dist/render/format.d.ts +0 -2
- package/dist/render/format.js +0 -10
- package/dist/render/heading.d.ts +0 -3
- package/dist/render/heading.js +0 -14
- package/dist/render/index.d.ts +0 -32
- package/dist/render/index.js +0 -235
- package/dist/render/indicators.d.ts +0 -2
- package/dist/render/indicators.js +0 -16
- package/dist/render/json.d.ts +0 -2
- package/dist/render/json.js +0 -10
- package/dist/render/layout.d.ts +0 -5
- package/dist/render/layout.js +0 -25
- package/dist/render/list.d.ts +0 -2
- package/dist/render/list.js +0 -8
- package/dist/render/markdown.d.ts +0 -2
- package/dist/render/markdown.js +0 -10
- package/dist/render/progress.d.ts +0 -2
- package/dist/render/progress.js +0 -8
- package/dist/render/separator.d.ts +0 -3
- package/dist/render/separator.js +0 -14
- package/dist/render/shapes.d.ts +0 -2
- package/dist/render/shapes.js +0 -35
- package/dist/render/spinner.d.ts +0 -2
- package/dist/render/spinner.js +0 -12
- package/dist/render/stack.d.ts +0 -3
- package/dist/render/stack.js +0 -38
- package/dist/render/table.d.ts +0 -3
- package/dist/render/table.js +0 -12
- package/dist/render/text.d.ts +0 -2
- package/dist/render/text.js +0 -27
- package/dist/render/tree.d.ts +0 -2
- package/dist/render/tree.js +0 -10
- package/dist/render/types.d.ts +0 -2
- package/dist/shared/@outfitter/cli-0djg8q91.js +0 -7
- package/dist/shared/@outfitter/cli-0w242qtv.d.ts +0 -48
- package/dist/shared/@outfitter/cli-1g8tt31a.d.ts +0 -119
- package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +0 -45
- package/dist/shared/@outfitter/cli-1sb3xvnw.js +0 -95
- package/dist/shared/@outfitter/cli-1vy0vtga.js +0 -135
- package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +0 -50
- package/dist/shared/@outfitter/cli-33e97cjs.d.ts +0 -42
- package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +0 -97
- package/dist/shared/@outfitter/cli-3hk2xf3c.js +0 -82
- package/dist/shared/@outfitter/cli-3hp8qwx3.js +0 -11
- package/dist/shared/@outfitter/cli-47yw5h6a.js +0 -7
- package/dist/shared/@outfitter/cli-4b6tbp68.d.ts +0 -36
- package/dist/shared/@outfitter/cli-4fcz51qa.js +0 -70
- package/dist/shared/@outfitter/cli-4x6pqnez.js +0 -20
- package/dist/shared/@outfitter/cli-4zk2y4a2.d.ts +0 -61
- package/dist/shared/@outfitter/cli-60b5xh1r.js +0 -20
- package/dist/shared/@outfitter/cli-6bztk73z.d.ts +0 -51
- package/dist/shared/@outfitter/cli-6fxffp8k.js +0 -1
- package/dist/shared/@outfitter/cli-6hg0sg2d.d.ts +0 -93
- package/dist/shared/@outfitter/cli-6r3m2knf.js +0 -62
- package/dist/shared/@outfitter/cli-6ty1nvws.js +0 -179
- package/dist/shared/@outfitter/cli-7n610r63.js +0 -20
- package/dist/shared/@outfitter/cli-7na6p4fs.d.ts +0 -59
- package/dist/shared/@outfitter/cli-83jwvj1t.d.ts +0 -17
- package/dist/shared/@outfitter/cli-85fg2vr5.js +0 -123
- package/dist/shared/@outfitter/cli-8bwaw3pz.js +0 -7
- package/dist/shared/@outfitter/cli-8hngbjyr.d.ts +0 -164
- package/dist/shared/@outfitter/cli-8j5k6mr3.js +0 -71
- package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +0 -223
- package/dist/shared/@outfitter/cli-914d47mt.js +0 -20
- package/dist/shared/@outfitter/cli-9bcm4zhf.d.ts +0 -87
- package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +0 -190
- package/dist/shared/@outfitter/cli-a4q87517.d.ts +0 -64
- package/dist/shared/@outfitter/cli-aem6v4c8.js +0 -146
- package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +0 -132
- package/dist/shared/@outfitter/cli-b5c2k0d7.js +0 -39
- package/dist/shared/@outfitter/cli-b5epywry.js +0 -1
- package/dist/shared/@outfitter/cli-bc17qeh2.js +0 -19
- package/dist/shared/@outfitter/cli-bcmcaz1b.js +0 -23
- package/dist/shared/@outfitter/cli-bv09nme3.d.ts +0 -56
- package/dist/shared/@outfitter/cli-c6pbxpw0.d.ts +0 -112
- package/dist/shared/@outfitter/cli-c8fqdaes.js +0 -117
- package/dist/shared/@outfitter/cli-c8q4f71g.js +0 -144
- package/dist/shared/@outfitter/cli-c9knfqn5.d.ts +0 -30
- package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +0 -53
- package/dist/shared/@outfitter/cli-cf2s94s1.d.ts +0 -42
- package/dist/shared/@outfitter/cli-cwgj6mcs.js +0 -214
- package/dist/shared/@outfitter/cli-d8ahdd9d.js +0 -272
- package/dist/shared/@outfitter/cli-dbyteh27.d.ts +0 -24
- package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +0 -91
- package/dist/shared/@outfitter/cli-en6zn6sj.js +0 -1
- package/dist/shared/@outfitter/cli-evx7qcp1.d.ts +0 -300
- package/dist/shared/@outfitter/cli-f6fsaayd.js +0 -94
- package/dist/shared/@outfitter/cli-fakncnjp.d.ts +0 -106
- package/dist/shared/@outfitter/cli-ffa0jwb7.js +0 -122
- package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +0 -66
- package/dist/shared/@outfitter/cli-h3jz0bxz.js +0 -48
- package/dist/shared/@outfitter/cli-h4wpzb3f.js +0 -67
- package/dist/shared/@outfitter/cli-hda6mc28.js +0 -126
- package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +0 -328
- package/dist/shared/@outfitter/cli-j19a91ck.js +0 -30
- package/dist/shared/@outfitter/cli-jejfypgf.js +0 -85
- package/dist/shared/@outfitter/cli-jp0k3qd9.js +0 -279
- package/dist/shared/@outfitter/cli-k76e7173.js +0 -128
- package/dist/shared/@outfitter/cli-kc3ffp1v.d.ts +0 -23
- package/dist/shared/@outfitter/cli-kk5hnndk.d.ts +0 -128
- package/dist/shared/@outfitter/cli-ktqme80d.js +0 -7
- package/dist/shared/@outfitter/cli-mq0jp15z.js +0 -1
- package/dist/shared/@outfitter/cli-n0c33vba.js +0 -25
- package/dist/shared/@outfitter/cli-n17gt1dz.js +0 -19
- package/dist/shared/@outfitter/cli-n9dbh0hp.js +0 -51
- package/dist/shared/@outfitter/cli-ndem6tz8.js +0 -63
- package/dist/shared/@outfitter/cli-nj4nqy1h.d.ts +0 -24
- package/dist/shared/@outfitter/cli-nkns8p4r.js +0 -61
- package/dist/shared/@outfitter/cli-p3dqm1vd.js +0 -22
- package/dist/shared/@outfitter/cli-pndwprz8.js +0 -118
- package/dist/shared/@outfitter/cli-pvrwv6rb.js +0 -352
- package/dist/shared/@outfitter/cli-py02m79x.d.ts +0 -20
- package/dist/shared/@outfitter/cli-qj83y5wj.d.ts +0 -71
- package/dist/shared/@outfitter/cli-regjbef6.d.ts +0 -26
- package/dist/shared/@outfitter/cli-s1tx5kha.d.ts +0 -59
- package/dist/shared/@outfitter/cli-sam2sq50.js +0 -37
- package/dist/shared/@outfitter/cli-snxj55n6.js +0 -43
- package/dist/shared/@outfitter/cli-symyxb0z.js +0 -20
- package/dist/shared/@outfitter/cli-tvw1xrdj.js +0 -20
- package/dist/shared/@outfitter/cli-v1tzwxkt.js +0 -32
- package/dist/shared/@outfitter/cli-vd60dj65.js +0 -1
- package/dist/shared/@outfitter/cli-vfcrskfj.d.ts +0 -41
- package/dist/shared/@outfitter/cli-vstbkzky.d.ts +0 -74
- package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +0 -54
- package/dist/shared/@outfitter/cli-x4cavvc0.js +0 -1
- package/dist/shared/@outfitter/cli-xep6v2c0.js +0 -52
- package/dist/shared/@outfitter/cli-xg5y5fhk.js +0 -86
- package/dist/shared/@outfitter/cli-y7k1t81k.js +0 -30
- package/dist/shared/@outfitter/cli-yfyzy95c.js +0 -67
- package/dist/shared/@outfitter/cli-z78mkrc7.js +0 -59
- package/dist/shared/@outfitter/cli-znc47004.js +0 -134
- package/dist/shared/@outfitter/cli-zx598p8q.d.ts +0 -26
- package/dist/streaming/ansi.d.ts +0 -2
- package/dist/streaming/ansi.js +0 -8
- package/dist/streaming/index.d.ts +0 -4
- package/dist/streaming/index.js +0 -17
- package/dist/streaming/spinner.d.ts +0 -3
- package/dist/streaming/spinner.js +0 -10
- package/dist/streaming/writer.d.ts +0 -2
- package/dist/streaming/writer.js +0 -9
- package/dist/table/index.d.ts +0 -4
- package/dist/table/index.js +0 -13
- package/dist/theme/context.d.ts +0 -9
- package/dist/theme/context.js +0 -14
- package/dist/theme/create.d.ts +0 -8
- package/dist/theme/create.js +0 -12
- package/dist/theme/index.d.ts +0 -17
- package/dist/theme/index.js +0 -42
- package/dist/theme/presets/bold.d.ts +0 -8
- package/dist/theme/presets/bold.js +0 -12
- package/dist/theme/presets/default.d.ts +0 -8
- package/dist/theme/presets/default.js +0 -11
- package/dist/theme/presets/index.d.ts +0 -12
- package/dist/theme/presets/index.js +0 -24
- package/dist/theme/presets/minimal.d.ts +0 -8
- package/dist/theme/presets/minimal.js +0 -12
- package/dist/theme/presets/rounded.d.ts +0 -8
- package/dist/theme/presets/rounded.js +0 -12
- package/dist/theme/resolve.d.ts +0 -8
- package/dist/theme/resolve.js +0 -11
- package/dist/theme/types.d.ts +0 -7
- package/dist/theme/types.js +0 -1
- package/dist/tree/index.d.ts +0 -3
- package/dist/tree/index.js +0 -11
- /package/dist/shared/@outfitter/{cli-ykxn7rb2.d.ts → cli-xppg982q.d.ts} +0 -0
- /package/dist/{render/types.js → shared/@outfitter/cli-zw75pdk8.js} +0 -0
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Indicator primitives for CLI output.
|
|
3
|
-
*
|
|
4
|
-
* Provides status symbols, selection indicators, list bullets, and progress
|
|
5
|
-
* markers with unicode and ASCII fallback support.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Categories of indicators available.
|
|
11
|
-
*/
|
|
12
|
-
type IndicatorCategory = "status" | "marker" | "progress" | "triangle" | "special" | "directional" | "math";
|
|
13
|
-
/**
|
|
14
|
-
* An indicator with unicode and fallback representations.
|
|
15
|
-
*/
|
|
16
|
-
interface IndicatorSet {
|
|
17
|
-
/** Unicode character for modern terminals */
|
|
18
|
-
unicode: string;
|
|
19
|
-
/** ASCII fallback for limited terminals */
|
|
20
|
-
fallback: string;
|
|
21
|
-
/** Optional semantic color name */
|
|
22
|
-
color?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* All available indicators organized by category.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* import { INDICATORS, getIndicator } from "@outfitter/cli/render";
|
|
30
|
-
*
|
|
31
|
-
* // Access directly
|
|
32
|
-
* console.log(INDICATORS.status.success.unicode); // "✔"
|
|
33
|
-
*
|
|
34
|
-
* // Or use helper
|
|
35
|
-
* console.log(getIndicator("status", "success")); // "✔" or "[ok]"
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
declare const INDICATORS: Record<IndicatorCategory, Record<string, IndicatorSet>>;
|
|
39
|
-
/**
|
|
40
|
-
* Detects if the terminal supports Unicode characters.
|
|
41
|
-
*
|
|
42
|
-
* Checks for:
|
|
43
|
-
* - CI environments (usually support unicode)
|
|
44
|
-
* - Windows Terminal / ConEmu
|
|
45
|
-
* - TERM containing xterm/vt100
|
|
46
|
-
* - Locale settings
|
|
47
|
-
*
|
|
48
|
-
* @returns true if unicode is likely supported
|
|
49
|
-
*/
|
|
50
|
-
declare function isUnicodeSupported(): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Gets an indicator character with automatic unicode/fallback selection.
|
|
53
|
-
*
|
|
54
|
-
* @param category - The indicator category
|
|
55
|
-
* @param name - The indicator name within the category
|
|
56
|
-
* @param forceUnicode - Override unicode detection (useful for testing)
|
|
57
|
-
* @returns The appropriate character for the current terminal
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* // Automatic detection
|
|
62
|
-
* console.log(getIndicator("status", "success"));
|
|
63
|
-
*
|
|
64
|
-
* // Force unicode
|
|
65
|
-
* console.log(getIndicator("status", "success", true)); // "✔"
|
|
66
|
-
*
|
|
67
|
-
* // Force fallback
|
|
68
|
-
* console.log(getIndicator("status", "success", false)); // "[ok]"
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
declare function getIndicator(category: IndicatorCategory, name: string, forceUnicode?: boolean): string;
|
|
72
|
-
/**
|
|
73
|
-
* Progress indicator styles.
|
|
74
|
-
*/
|
|
75
|
-
type ProgressStyle = "circle" | "vertical" | "horizontal" | "shade";
|
|
76
|
-
/**
|
|
77
|
-
* Gets a progress indicator based on current/max values.
|
|
78
|
-
*
|
|
79
|
-
* @param style - The progress style (circle, vertical, horizontal, shade)
|
|
80
|
-
* @param current - Current progress value
|
|
81
|
-
* @param max - Maximum progress value
|
|
82
|
-
* @param forceUnicode - Override unicode detection
|
|
83
|
-
* @returns The appropriate progress indicator character
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* // Circle progress at 50%
|
|
88
|
-
* getProgressIndicator("circle", 50, 100); // "◑"
|
|
89
|
-
*
|
|
90
|
-
* // Vertical block at 75%
|
|
91
|
-
* getProgressIndicator("vertical", 6, 8); // "▆"
|
|
92
|
-
*
|
|
93
|
-
* // Horizontal bar at 100%
|
|
94
|
-
* getProgressIndicator("horizontal", 1, 1); // "█"
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
declare function getProgressIndicator(style: ProgressStyle, current: number, max: number, forceUnicode?: boolean): string;
|
|
98
|
-
/**
|
|
99
|
-
* Severity levels for escalating indicators.
|
|
100
|
-
*
|
|
101
|
-
* Uses the diamond family: ◇ (minor) → ◆ (moderate) → ◈ (severe)
|
|
102
|
-
*/
|
|
103
|
-
type SeverityLevel = "minor" | "moderate" | "severe";
|
|
104
|
-
/**
|
|
105
|
-
* Gets a severity indicator for the given level.
|
|
106
|
-
*
|
|
107
|
-
* @param level - The severity level
|
|
108
|
-
* @param forceUnicode - Override unicode detection
|
|
109
|
-
* @returns The appropriate severity indicator character
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* getSeverityIndicator("minor"); // "◇"
|
|
114
|
-
* getSeverityIndicator("moderate"); // "◆"
|
|
115
|
-
* getSeverityIndicator("severe"); // "◈"
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
declare function getSeverityIndicator(level: SeverityLevel, forceUnicode?: boolean): string;
|
|
119
|
-
export { IndicatorCategory, IndicatorSet, INDICATORS, isUnicodeSupported, getIndicator, ProgressStyle, getProgressIndicator, SeverityLevel, getSeverityIndicator };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { WidthMode } from "./cli-2g8bx1aq";
|
|
2
|
-
/**
|
|
3
|
-
* Width mode for separators.
|
|
4
|
-
*
|
|
5
|
-
* Separators only support "text", "full", and numeric widths.
|
|
6
|
-
* Container-relative modes require context, which separators don't use.
|
|
7
|
-
*/
|
|
8
|
-
type SeparatorWidthMode = Extract<WidthMode, "text" | "full" | number>;
|
|
9
|
-
/**
|
|
10
|
-
* Separator style for dividers.
|
|
11
|
-
* Single characters repeat to fill width.
|
|
12
|
-
* Two-character patterns (like "- ") alternate to create dashed effect.
|
|
13
|
-
*/
|
|
14
|
-
type DividerStyle = "─" | "━" | "═" | "- " | "· ";
|
|
15
|
-
/**
|
|
16
|
-
* Options for rendering a separator.
|
|
17
|
-
*/
|
|
18
|
-
interface SeparatorOptions {
|
|
19
|
-
/** Separator style (default: "─") */
|
|
20
|
-
style?: DividerStyle;
|
|
21
|
-
/** Width mode (default: 40) */
|
|
22
|
-
width?: SeparatorWidthMode;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Renders a horizontal separator line.
|
|
26
|
-
*
|
|
27
|
-
* @param options - Rendering options
|
|
28
|
-
* @returns Formatted separator string
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { renderSeparator } from "@outfitter/cli/render";
|
|
33
|
-
*
|
|
34
|
-
* console.log(renderSeparator());
|
|
35
|
-
* // ────────────────────────────────────────
|
|
36
|
-
*
|
|
37
|
-
* console.log(renderSeparator({ style: "━", width: 20 }));
|
|
38
|
-
* // ━━━━━━━━━━━━━━━━━━━━
|
|
39
|
-
*
|
|
40
|
-
* console.log(renderSeparator({ style: "- ", width: 20 }));
|
|
41
|
-
* // - - - - - - - - - -
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
declare function renderSeparator(options?: SeparatorOptions): string;
|
|
45
|
-
export { DividerStyle, SeparatorOptions, renderSeparator };
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
ANSI
|
|
4
|
-
} from "./cli-p3dqm1vd.js";
|
|
5
|
-
import {
|
|
6
|
-
getIndicator
|
|
7
|
-
} from "./cli-6ty1nvws.js";
|
|
8
|
-
|
|
9
|
-
// packages/cli/src/streaming/spinner.ts
|
|
10
|
-
var SPINNER_FRAMES = {
|
|
11
|
-
dots: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
|
|
12
|
-
line: ["-", "\\", "|", "/"],
|
|
13
|
-
simple: ["\u25D0", "\u25D3", "\u25D1", "\u25D2"]
|
|
14
|
-
};
|
|
15
|
-
function createSpinner(message, options = {}) {
|
|
16
|
-
const stream = options.stream ?? process.stdout;
|
|
17
|
-
const isTTY = stream.isTTY ?? false;
|
|
18
|
-
const style = options.style ?? "dots";
|
|
19
|
-
const interval = options.interval ?? 80;
|
|
20
|
-
const frames = SPINNER_FRAMES[style];
|
|
21
|
-
let frameIndex = 0;
|
|
22
|
-
let currentMessage = message;
|
|
23
|
-
let timer = null;
|
|
24
|
-
let isRunning = false;
|
|
25
|
-
const render = () => {
|
|
26
|
-
if (!isTTY) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const frame = frames[frameIndex % frames.length];
|
|
30
|
-
stream.write(`${ANSI.carriageReturn}${ANSI.clearLine}${frame} ${currentMessage}`);
|
|
31
|
-
frameIndex++;
|
|
32
|
-
};
|
|
33
|
-
const start = () => {
|
|
34
|
-
if (isRunning)
|
|
35
|
-
return;
|
|
36
|
-
isRunning = true;
|
|
37
|
-
if (!isTTY) {
|
|
38
|
-
stream.write(`- ${currentMessage}
|
|
39
|
-
`);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
stream.write(ANSI.hideCursor);
|
|
43
|
-
render();
|
|
44
|
-
timer = setInterval(render, interval);
|
|
45
|
-
};
|
|
46
|
-
const update = (newMessage) => {
|
|
47
|
-
currentMessage = newMessage;
|
|
48
|
-
if (!isTTY) {
|
|
49
|
-
stream.write(`- ${currentMessage}
|
|
50
|
-
`);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (isRunning) {
|
|
54
|
-
render();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const stopWith = (symbol, finalMessage) => {
|
|
58
|
-
if (timer) {
|
|
59
|
-
clearInterval(timer);
|
|
60
|
-
timer = null;
|
|
61
|
-
}
|
|
62
|
-
const msg = finalMessage ?? currentMessage;
|
|
63
|
-
if (isTTY) {
|
|
64
|
-
stream.write(`${ANSI.carriageReturn}${ANSI.clearLine}${symbol} ${msg}
|
|
65
|
-
`);
|
|
66
|
-
stream.write(ANSI.showCursor);
|
|
67
|
-
} else {
|
|
68
|
-
stream.write(`${symbol} ${msg}
|
|
69
|
-
`);
|
|
70
|
-
}
|
|
71
|
-
isRunning = false;
|
|
72
|
-
};
|
|
73
|
-
const succeed = (finalMessage) => {
|
|
74
|
-
const symbol = getIndicator("status", "success", isTTY);
|
|
75
|
-
stopWith(symbol, finalMessage);
|
|
76
|
-
};
|
|
77
|
-
const fail = (finalMessage) => {
|
|
78
|
-
const symbol = getIndicator("status", "error", isTTY);
|
|
79
|
-
stopWith(symbol, finalMessage);
|
|
80
|
-
};
|
|
81
|
-
const stop = () => {
|
|
82
|
-
if (timer) {
|
|
83
|
-
clearInterval(timer);
|
|
84
|
-
timer = null;
|
|
85
|
-
}
|
|
86
|
-
if (isTTY && isRunning) {
|
|
87
|
-
stream.write(`${ANSI.carriageReturn}${ANSI.clearLine}`);
|
|
88
|
-
stream.write(ANSI.showCursor);
|
|
89
|
-
}
|
|
90
|
-
isRunning = false;
|
|
91
|
-
};
|
|
92
|
-
return { start, update, succeed, fail, stop };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { createSpinner };
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
renderJson,
|
|
4
|
-
renderText
|
|
5
|
-
} from "./cli-3hp8qwx3.js";
|
|
6
|
-
import {
|
|
7
|
-
renderTree
|
|
8
|
-
} from "./cli-b5c2k0d7.js";
|
|
9
|
-
import {
|
|
10
|
-
renderList
|
|
11
|
-
} from "./cli-xg5y5fhk.js";
|
|
12
|
-
import {
|
|
13
|
-
renderTable
|
|
14
|
-
} from "./cli-c8fqdaes.js";
|
|
15
|
-
import {
|
|
16
|
-
renderMarkdown
|
|
17
|
-
} from "./cli-ndem6tz8.js";
|
|
18
|
-
|
|
19
|
-
// packages/cli/src/render/shapes.ts
|
|
20
|
-
function isCollection(shape) {
|
|
21
|
-
return shape.type === "collection";
|
|
22
|
-
}
|
|
23
|
-
function isHierarchy(shape) {
|
|
24
|
-
return shape.type === "hierarchy";
|
|
25
|
-
}
|
|
26
|
-
function isKeyValue(shape) {
|
|
27
|
-
return shape.type === "keyvalue";
|
|
28
|
-
}
|
|
29
|
-
function isResource(shape) {
|
|
30
|
-
return shape.type === "resource";
|
|
31
|
-
}
|
|
32
|
-
function treeNodeToRecord(node) {
|
|
33
|
-
if (node.children.length === 0) {
|
|
34
|
-
return { [node.name]: null };
|
|
35
|
-
}
|
|
36
|
-
const childRecord = {};
|
|
37
|
-
for (const child of node.children) {
|
|
38
|
-
const childObj = treeNodeToRecord(child);
|
|
39
|
-
Object.assign(childRecord, childObj);
|
|
40
|
-
}
|
|
41
|
-
return { [node.name]: childRecord };
|
|
42
|
-
}
|
|
43
|
-
function isPlainObject(item) {
|
|
44
|
-
return item !== null && typeof item === "object" && !Array.isArray(item);
|
|
45
|
-
}
|
|
46
|
-
var customRenderers = new Map;
|
|
47
|
-
function registerRenderer(shapeType, renderer) {
|
|
48
|
-
customRenderers.set(shapeType, renderer);
|
|
49
|
-
}
|
|
50
|
-
function unregisterRenderer(shapeType) {
|
|
51
|
-
return customRenderers.delete(shapeType);
|
|
52
|
-
}
|
|
53
|
-
function clearRenderers() {
|
|
54
|
-
customRenderers.clear();
|
|
55
|
-
}
|
|
56
|
-
function render(shape, options) {
|
|
57
|
-
const customRenderer = customRenderers.get(shape.type);
|
|
58
|
-
if (customRenderer) {
|
|
59
|
-
return customRenderer(shape, options);
|
|
60
|
-
}
|
|
61
|
-
const format = options?.format;
|
|
62
|
-
if (format === "json") {
|
|
63
|
-
if (isCollection(shape)) {
|
|
64
|
-
return renderJson(shape.items);
|
|
65
|
-
}
|
|
66
|
-
if (isHierarchy(shape)) {
|
|
67
|
-
return renderJson(treeNodeToRecord(shape.root));
|
|
68
|
-
}
|
|
69
|
-
if (isKeyValue(shape)) {
|
|
70
|
-
return renderJson(shape.entries);
|
|
71
|
-
}
|
|
72
|
-
if (isResource(shape)) {
|
|
73
|
-
return renderJson(shape.data);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (format === "list" && isCollection(shape)) {
|
|
77
|
-
const listItems = shape.items.map((item) => {
|
|
78
|
-
if (typeof item === "string") {
|
|
79
|
-
return item;
|
|
80
|
-
}
|
|
81
|
-
if (isPlainObject(item)) {
|
|
82
|
-
const name = item.name;
|
|
83
|
-
if (typeof name === "string") {
|
|
84
|
-
return name;
|
|
85
|
-
}
|
|
86
|
-
return JSON.stringify(item);
|
|
87
|
-
}
|
|
88
|
-
return String(item);
|
|
89
|
-
});
|
|
90
|
-
return renderList(listItems);
|
|
91
|
-
}
|
|
92
|
-
if (format === "table" && isCollection(shape)) {
|
|
93
|
-
const items = shape.items.filter(isPlainObject);
|
|
94
|
-
return renderTable(items, shape.headers ? { headers: shape.headers } : undefined);
|
|
95
|
-
}
|
|
96
|
-
if (format === "tree" && isHierarchy(shape)) {
|
|
97
|
-
return renderTree(treeNodeToRecord(shape.root));
|
|
98
|
-
}
|
|
99
|
-
if (format === "text" && isResource(shape)) {
|
|
100
|
-
return renderText(String(shape.data));
|
|
101
|
-
}
|
|
102
|
-
if (isCollection(shape)) {
|
|
103
|
-
const hasObjectItems = shape.items.every(isPlainObject);
|
|
104
|
-
if (hasObjectItems) {
|
|
105
|
-
const items = shape.items;
|
|
106
|
-
return renderTable(items, shape.headers ? { headers: shape.headers } : undefined);
|
|
107
|
-
}
|
|
108
|
-
const listItems = shape.items.map((item) => {
|
|
109
|
-
if (typeof item === "string") {
|
|
110
|
-
return item;
|
|
111
|
-
}
|
|
112
|
-
return String(item);
|
|
113
|
-
});
|
|
114
|
-
return renderList(listItems);
|
|
115
|
-
}
|
|
116
|
-
if (isHierarchy(shape)) {
|
|
117
|
-
return renderTree(treeNodeToRecord(shape.root));
|
|
118
|
-
}
|
|
119
|
-
if (isKeyValue(shape)) {
|
|
120
|
-
return renderJson(shape.entries);
|
|
121
|
-
}
|
|
122
|
-
if (isResource(shape)) {
|
|
123
|
-
const resourceFormat = shape.format ?? "json";
|
|
124
|
-
if (resourceFormat === "markdown") {
|
|
125
|
-
return renderMarkdown(String(shape.data));
|
|
126
|
-
}
|
|
127
|
-
if (resourceFormat === "text") {
|
|
128
|
-
return renderText(String(shape.data));
|
|
129
|
-
}
|
|
130
|
-
return renderJson(shape.data);
|
|
131
|
-
}
|
|
132
|
-
return renderJson(shape);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export { isCollection, isHierarchy, isKeyValue, isResource, treeNodeToRecord, isPlainObject, registerRenderer, unregisterRenderer, clearRenderers, render };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared types for render utilities.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Width mode for layout calculations.
|
|
8
|
-
*
|
|
9
|
-
* - `"text"` - Fit to text content (returns 0 to indicate no width constraint)
|
|
10
|
-
* - `"full"` - Full terminal width
|
|
11
|
-
* - `"container"` - Available container width (requires LayoutContext)
|
|
12
|
-
* - `number` - Fixed character width
|
|
13
|
-
* - `"${number}%"` - Percentage of container/terminal width
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { resolveWidth } from "@outfitter/cli/render";
|
|
18
|
-
*
|
|
19
|
-
* resolveWidth("full"); // → terminal width (e.g., 120)
|
|
20
|
-
* resolveWidth(50); // → 50
|
|
21
|
-
* resolveWidth("50%"); // → half of terminal width
|
|
22
|
-
* resolveWidth("container", ctx); // → context width
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
type WidthMode = "text" | "full" | "container" | number | `${number}%`;
|
|
26
|
-
/**
|
|
27
|
-
* Layout context for container-aware width calculations.
|
|
28
|
-
*
|
|
29
|
-
* Provides width information to nested components so they can size
|
|
30
|
-
* themselves relative to their container. Create contexts with
|
|
31
|
-
* `createLayoutContext()` and pass them through component hierarchies.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* import { createLayoutContext, resolveWidth } from "@outfitter/cli/render";
|
|
36
|
-
*
|
|
37
|
-
* const outerCtx = createLayoutContext({ width: 80, padding: 1 });
|
|
38
|
-
* // outerCtx.width = 76 (80 - 4 overhead)
|
|
39
|
-
*
|
|
40
|
-
* const innerWidth = resolveWidth("50%", outerCtx);
|
|
41
|
-
* // innerWidth = 38 (50% of 76)
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
interface LayoutContext {
|
|
45
|
-
/** Available content width in characters */
|
|
46
|
-
readonly width: number;
|
|
47
|
-
/** Parent context for chained calculations */
|
|
48
|
-
readonly parent?: LayoutContext;
|
|
49
|
-
}
|
|
50
|
-
export { WidthMode, LayoutContext };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON and text rendering utilities.
|
|
3
|
-
*
|
|
4
|
-
* Simple renderers for JSON and plain text output.
|
|
5
|
-
*
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Renders data as pretty-printed JSON.
|
|
10
|
-
*
|
|
11
|
-
* Uses `JSON.stringify` with 2-space indentation.
|
|
12
|
-
* Suitable for displaying structured data in terminal output.
|
|
13
|
-
*
|
|
14
|
-
* @param data - Data to render as JSON
|
|
15
|
-
* @returns Pretty-printed JSON string
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* console.log(renderJson({ name: "test", value: 42 }));
|
|
20
|
-
* // {
|
|
21
|
-
* // "name": "test",
|
|
22
|
-
* // "value": 42
|
|
23
|
-
* // }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
declare function renderJson(data: unknown): string;
|
|
27
|
-
/**
|
|
28
|
-
* Renders plain text unchanged.
|
|
29
|
-
*
|
|
30
|
-
* This is a pass-through function that returns the input text as-is.
|
|
31
|
-
* Useful as a placeholder or for consistent API across render functions.
|
|
32
|
-
*
|
|
33
|
-
* @param text - Text to render
|
|
34
|
-
* @returns The input text unchanged
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* renderText("Hello, World!"); // "Hello, World!"
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
declare function renderText(text: string): string;
|
|
42
|
-
export { renderJson, renderText };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tree rendering utilities.
|
|
3
|
-
*
|
|
4
|
-
* Renders hierarchical data as ASCII trees with box-drawing characters.
|
|
5
|
-
*
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Available tree guide styles.
|
|
10
|
-
*
|
|
11
|
-
* - `single`: Standard Unicode box-drawing (default)
|
|
12
|
-
* - `heavy`: Thick/bold box-drawing characters
|
|
13
|
-
* - `double`: Double-line box-drawing characters
|
|
14
|
-
* - `rounded`: Rounded corners (╰ instead of └)
|
|
15
|
-
*/
|
|
16
|
-
type TreeGuideStyle = "single" | "heavy" | "double" | "rounded";
|
|
17
|
-
/**
|
|
18
|
-
* Tree guide character sets for different visual styles.
|
|
19
|
-
*/
|
|
20
|
-
declare const TREE_GUIDES: Record<TreeGuideStyle, {
|
|
21
|
-
vertical: string;
|
|
22
|
-
fork: string;
|
|
23
|
-
end: string;
|
|
24
|
-
}>;
|
|
25
|
-
/**
|
|
26
|
-
* Options for customizing tree rendering.
|
|
27
|
-
*/
|
|
28
|
-
interface TreeOptions {
|
|
29
|
-
/**
|
|
30
|
-
* Guide style for tree branches.
|
|
31
|
-
* @default "single"
|
|
32
|
-
*/
|
|
33
|
-
guide?: TreeGuideStyle;
|
|
34
|
-
/**
|
|
35
|
-
* Maximum depth to render (1 = root children only).
|
|
36
|
-
* @default undefined (unlimited)
|
|
37
|
-
*/
|
|
38
|
-
maxDepth?: number;
|
|
39
|
-
/**
|
|
40
|
-
* Custom function to render node labels.
|
|
41
|
-
* Receives the key, value, and current depth.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* renderLabel: (key, value, depth) => {
|
|
46
|
-
* if (value && typeof value === "object") {
|
|
47
|
-
* return `📁 ${key}/`;
|
|
48
|
-
* }
|
|
49
|
-
* return `📄 ${key}`;
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
renderLabel?: (key: string, value: unknown, depth: number) => string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Renders hierarchical data as a tree with unicode box-drawing characters.
|
|
57
|
-
*
|
|
58
|
-
* Uses unicode characters for tree structure.
|
|
59
|
-
* Nested objects are rendered as child nodes; leaf values (null, primitives)
|
|
60
|
-
* are rendered as terminal nodes.
|
|
61
|
-
*
|
|
62
|
-
* @param tree - Hierarchical object to render
|
|
63
|
-
* @param options - Customization options
|
|
64
|
-
* @returns Formatted tree string with box-drawing characters
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* const tree = {
|
|
69
|
-
* src: {
|
|
70
|
-
* components: {
|
|
71
|
-
* Button: null,
|
|
72
|
-
* Input: null,
|
|
73
|
-
* },
|
|
74
|
-
* utils: null,
|
|
75
|
-
* },
|
|
76
|
-
* tests: null,
|
|
77
|
-
* };
|
|
78
|
-
*
|
|
79
|
-
* console.log(renderTree(tree));
|
|
80
|
-
* // ├── src
|
|
81
|
-
* // │ ├── components
|
|
82
|
-
* // │ │ ├── Button
|
|
83
|
-
* // │ │ └── Input
|
|
84
|
-
* // │ └── utils
|
|
85
|
-
* // └── tests
|
|
86
|
-
*
|
|
87
|
-
* console.log(renderTree(tree, { guide: "rounded" }));
|
|
88
|
-
* // ├── src
|
|
89
|
-
* // │ ├── components
|
|
90
|
-
* // │ │ ├── Button
|
|
91
|
-
* // │ │ ╰── Input
|
|
92
|
-
* // │ ╰── utils
|
|
93
|
-
* // ╰── tests
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
declare function renderTree(tree: Record<string, unknown>, options?: TreeOptions): string;
|
|
97
|
-
export { TreeGuideStyle, TREE_GUIDES, TreeOptions, renderTree };
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
getTerminalWidth
|
|
4
|
-
} from "./cli-aem6v4c8.js";
|
|
5
|
-
|
|
6
|
-
// packages/cli/src/render/heading.ts
|
|
7
|
-
var ANSI_PATTERN = /\x1b\[[0-9;]*m/g;
|
|
8
|
-
function toTitleCase(text) {
|
|
9
|
-
return text.replace(/\w\S*/g, (word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase());
|
|
10
|
-
}
|
|
11
|
-
function applyCase(text, caseMode) {
|
|
12
|
-
if (caseMode === "none") {
|
|
13
|
-
return text;
|
|
14
|
-
}
|
|
15
|
-
const hasAnsi = ANSI_PATTERN.test(text);
|
|
16
|
-
ANSI_PATTERN.lastIndex = 0;
|
|
17
|
-
if (!hasAnsi) {
|
|
18
|
-
switch (caseMode) {
|
|
19
|
-
case "upper":
|
|
20
|
-
return text.toUpperCase();
|
|
21
|
-
case "lower":
|
|
22
|
-
return text.toLowerCase();
|
|
23
|
-
case "title":
|
|
24
|
-
return toTitleCase(text);
|
|
25
|
-
default: {
|
|
26
|
-
const _exhaustive = caseMode;
|
|
27
|
-
return _exhaustive;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const sequences = [];
|
|
32
|
-
for (const match of text.matchAll(ANSI_PATTERN)) {
|
|
33
|
-
sequences.push({ index: match.index, seq: match[0] });
|
|
34
|
-
}
|
|
35
|
-
const stripped = Bun.stripANSI(text);
|
|
36
|
-
let transformed;
|
|
37
|
-
switch (caseMode) {
|
|
38
|
-
case "upper":
|
|
39
|
-
transformed = stripped.toUpperCase();
|
|
40
|
-
break;
|
|
41
|
-
case "lower":
|
|
42
|
-
transformed = stripped.toLowerCase();
|
|
43
|
-
break;
|
|
44
|
-
case "title":
|
|
45
|
-
transformed = toTitleCase(stripped);
|
|
46
|
-
break;
|
|
47
|
-
default: {
|
|
48
|
-
const _exhaustive = caseMode;
|
|
49
|
-
return _exhaustive;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
let result = transformed;
|
|
53
|
-
let offset = 0;
|
|
54
|
-
for (const { index, seq } of sequences) {
|
|
55
|
-
const insertPos = index + offset;
|
|
56
|
-
result = result.slice(0, insertPos) + seq + result.slice(insertPos);
|
|
57
|
-
offset += seq.length;
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
function getTextWidth(text) {
|
|
62
|
-
return Bun.stringWidth(text);
|
|
63
|
-
}
|
|
64
|
-
function renderHeading(text, options) {
|
|
65
|
-
const separator = options?.separator ?? "=";
|
|
66
|
-
const widthMode = options?.width ?? "text";
|
|
67
|
-
const caseMode = options?.case ?? "upper";
|
|
68
|
-
const transformedText = applyCase(text, caseMode);
|
|
69
|
-
let width;
|
|
70
|
-
if (widthMode === "text") {
|
|
71
|
-
width = getTextWidth(transformedText);
|
|
72
|
-
} else if (widthMode === "full") {
|
|
73
|
-
width = getTerminalWidth();
|
|
74
|
-
} else {
|
|
75
|
-
width = widthMode;
|
|
76
|
-
}
|
|
77
|
-
const separatorLine = separator.repeat(width);
|
|
78
|
-
return `${transformedText}
|
|
79
|
-
${separatorLine}`;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export { renderHeading };
|