@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.
Files changed (269) hide show
  1. package/README.md +48 -4
  2. package/dist/actions.js +0 -2
  3. package/dist/cli.d.ts +1 -1
  4. package/dist/cli.js +1 -2
  5. package/dist/{render → colors}/colors.d.ts +1 -1
  6. package/dist/{render → colors}/colors.js +2 -6
  7. package/dist/colors/index.d.ts +1 -1
  8. package/dist/colors/index.js +3 -4
  9. package/dist/command.d.ts +2 -2
  10. package/dist/command.js +11 -2
  11. package/dist/completion.d.ts +36 -0
  12. package/dist/completion.js +91 -0
  13. package/dist/flags.d.ts +167 -0
  14. package/dist/flags.js +31 -0
  15. package/dist/index.d.ts +4 -4
  16. package/dist/index.js +5 -4
  17. package/dist/input.d.ts +3 -26
  18. package/dist/input.js +1 -31
  19. package/dist/output.d.ts +2 -2
  20. package/dist/output.js +0 -1
  21. package/dist/pagination.d.ts +1 -1
  22. package/dist/pagination.js +0 -2
  23. package/dist/query.d.ts +50 -0
  24. package/dist/query.js +51 -0
  25. package/dist/shared/@outfitter/cli-b2zk8fb3.js +357 -0
  26. package/dist/shared/@outfitter/{cli-d9ad0rqj.js → cli-jbj78ac5.js} +1 -6
  27. package/dist/shared/@outfitter/{cli-e6yv2764.d.ts → cli-k0yvzn6d.d.ts} +1 -1
  28. package/dist/shared/@outfitter/{cli-ttt7r0j7.d.ts → cli-md9347gn.d.ts} +155 -13
  29. package/dist/shared/@outfitter/{cli-5g6rkv3d.js → cli-rk9zagkm.js} +24 -32
  30. package/dist/shared/@outfitter/{cli-4h4rpdra.js → cli-zahqsaby.js} +32 -10
  31. package/dist/terminal/detection.js +1 -5
  32. package/dist/terminal/index.js +1 -6
  33. package/dist/{shared/@outfitter/cli-4cb5g831.d.ts → text.d.ts} +1 -1
  34. package/dist/{shared/@outfitter/cli-mwxsh3sr.js → text.js} +15 -14
  35. package/dist/types.d.ts +2 -2
  36. package/dist/types.js +0 -2
  37. package/dist/verbs.d.ts +50 -0
  38. package/dist/verbs.js +61 -0
  39. package/package.json +50 -204
  40. package/dist/borders/index.d.ts +0 -3
  41. package/dist/borders/index.js +0 -13
  42. package/dist/box/index.d.ts +0 -4
  43. package/dist/box/index.js +0 -13
  44. package/dist/demo/index.d.ts +0 -78
  45. package/dist/demo/index.js +0 -148
  46. package/dist/demo/registry.d.ts +0 -7
  47. package/dist/demo/registry.js +0 -28
  48. package/dist/demo/renderers/borders.d.ts +0 -7
  49. package/dist/demo/renderers/borders.js +0 -17
  50. package/dist/demo/renderers/box.d.ts +0 -7
  51. package/dist/demo/renderers/box.js +0 -18
  52. package/dist/demo/renderers/colors.d.ts +0 -7
  53. package/dist/demo/renderers/colors.js +0 -18
  54. package/dist/demo/renderers/indicators.d.ts +0 -7
  55. package/dist/demo/renderers/indicators.js +0 -17
  56. package/dist/demo/renderers/list.d.ts +0 -7
  57. package/dist/demo/renderers/list.js +0 -19
  58. package/dist/demo/renderers/markdown.d.ts +0 -7
  59. package/dist/demo/renderers/markdown.js +0 -18
  60. package/dist/demo/renderers/progress.d.ts +0 -7
  61. package/dist/demo/renderers/progress.js +0 -17
  62. package/dist/demo/renderers/spinner.d.ts +0 -7
  63. package/dist/demo/renderers/spinner.js +0 -19
  64. package/dist/demo/renderers/table.d.ts +0 -7
  65. package/dist/demo/renderers/table.js +0 -19
  66. package/dist/demo/renderers/text.d.ts +0 -7
  67. package/dist/demo/renderers/text.js +0 -16
  68. package/dist/demo/renderers/tree.d.ts +0 -7
  69. package/dist/demo/renderers/tree.js +0 -18
  70. package/dist/demo/section.d.ts +0 -5
  71. package/dist/demo/section.js +0 -23
  72. package/dist/demo/templates.d.ts +0 -4
  73. package/dist/demo/templates.js +0 -10
  74. package/dist/demo/types.d.ts +0 -3
  75. package/dist/demo/types.js +0 -8
  76. package/dist/list/index.d.ts +0 -3
  77. package/dist/list/index.js +0 -9
  78. package/dist/preset/full.d.ts +0 -14
  79. package/dist/preset/full.js +0 -41
  80. package/dist/preset/standard.d.ts +0 -11
  81. package/dist/preset/standard.js +0 -30
  82. package/dist/prompt/confirm.d.ts +0 -4
  83. package/dist/prompt/confirm.js +0 -9
  84. package/dist/prompt/group.d.ts +0 -4
  85. package/dist/prompt/group.js +0 -9
  86. package/dist/prompt/index.d.ts +0 -7
  87. package/dist/prompt/index.js +0 -32
  88. package/dist/prompt/select.d.ts +0 -4
  89. package/dist/prompt/select.js +0 -11
  90. package/dist/prompt/text.d.ts +0 -4
  91. package/dist/prompt/text.js +0 -11
  92. package/dist/prompt/types.d.ts +0 -3
  93. package/dist/prompt/types.js +0 -8
  94. package/dist/prompt/validators.d.ts +0 -2
  95. package/dist/prompt/validators.js +0 -8
  96. package/dist/render/borders.d.ts +0 -2
  97. package/dist/render/borders.js +0 -15
  98. package/dist/render/box.d.ts +0 -3
  99. package/dist/render/box.js +0 -23
  100. package/dist/render/date.d.ts +0 -2
  101. package/dist/render/date.js +0 -12
  102. package/dist/render/format-relative.d.ts +0 -2
  103. package/dist/render/format-relative.js +0 -8
  104. package/dist/render/format.d.ts +0 -2
  105. package/dist/render/format.js +0 -10
  106. package/dist/render/heading.d.ts +0 -3
  107. package/dist/render/heading.js +0 -14
  108. package/dist/render/index.d.ts +0 -32
  109. package/dist/render/index.js +0 -235
  110. package/dist/render/indicators.d.ts +0 -2
  111. package/dist/render/indicators.js +0 -16
  112. package/dist/render/json.d.ts +0 -2
  113. package/dist/render/json.js +0 -10
  114. package/dist/render/layout.d.ts +0 -5
  115. package/dist/render/layout.js +0 -25
  116. package/dist/render/list.d.ts +0 -2
  117. package/dist/render/list.js +0 -8
  118. package/dist/render/markdown.d.ts +0 -2
  119. package/dist/render/markdown.js +0 -10
  120. package/dist/render/progress.d.ts +0 -2
  121. package/dist/render/progress.js +0 -8
  122. package/dist/render/separator.d.ts +0 -3
  123. package/dist/render/separator.js +0 -14
  124. package/dist/render/shapes.d.ts +0 -2
  125. package/dist/render/shapes.js +0 -35
  126. package/dist/render/spinner.d.ts +0 -2
  127. package/dist/render/spinner.js +0 -12
  128. package/dist/render/stack.d.ts +0 -3
  129. package/dist/render/stack.js +0 -38
  130. package/dist/render/table.d.ts +0 -3
  131. package/dist/render/table.js +0 -12
  132. package/dist/render/text.d.ts +0 -2
  133. package/dist/render/text.js +0 -27
  134. package/dist/render/tree.d.ts +0 -2
  135. package/dist/render/tree.js +0 -10
  136. package/dist/render/types.d.ts +0 -2
  137. package/dist/shared/@outfitter/cli-0djg8q91.js +0 -7
  138. package/dist/shared/@outfitter/cli-0w242qtv.d.ts +0 -48
  139. package/dist/shared/@outfitter/cli-1g8tt31a.d.ts +0 -119
  140. package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +0 -45
  141. package/dist/shared/@outfitter/cli-1sb3xvnw.js +0 -95
  142. package/dist/shared/@outfitter/cli-1vy0vtga.js +0 -135
  143. package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +0 -50
  144. package/dist/shared/@outfitter/cli-33e97cjs.d.ts +0 -42
  145. package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +0 -97
  146. package/dist/shared/@outfitter/cli-3hk2xf3c.js +0 -82
  147. package/dist/shared/@outfitter/cli-3hp8qwx3.js +0 -11
  148. package/dist/shared/@outfitter/cli-47yw5h6a.js +0 -7
  149. package/dist/shared/@outfitter/cli-4b6tbp68.d.ts +0 -36
  150. package/dist/shared/@outfitter/cli-4fcz51qa.js +0 -70
  151. package/dist/shared/@outfitter/cli-4x6pqnez.js +0 -20
  152. package/dist/shared/@outfitter/cli-4zk2y4a2.d.ts +0 -61
  153. package/dist/shared/@outfitter/cli-60b5xh1r.js +0 -20
  154. package/dist/shared/@outfitter/cli-6bztk73z.d.ts +0 -51
  155. package/dist/shared/@outfitter/cli-6fxffp8k.js +0 -1
  156. package/dist/shared/@outfitter/cli-6hg0sg2d.d.ts +0 -93
  157. package/dist/shared/@outfitter/cli-6r3m2knf.js +0 -62
  158. package/dist/shared/@outfitter/cli-6ty1nvws.js +0 -179
  159. package/dist/shared/@outfitter/cli-7n610r63.js +0 -20
  160. package/dist/shared/@outfitter/cli-7na6p4fs.d.ts +0 -59
  161. package/dist/shared/@outfitter/cli-83jwvj1t.d.ts +0 -17
  162. package/dist/shared/@outfitter/cli-85fg2vr5.js +0 -123
  163. package/dist/shared/@outfitter/cli-8bwaw3pz.js +0 -7
  164. package/dist/shared/@outfitter/cli-8hngbjyr.d.ts +0 -164
  165. package/dist/shared/@outfitter/cli-8j5k6mr3.js +0 -71
  166. package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +0 -223
  167. package/dist/shared/@outfitter/cli-914d47mt.js +0 -20
  168. package/dist/shared/@outfitter/cli-9bcm4zhf.d.ts +0 -87
  169. package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +0 -190
  170. package/dist/shared/@outfitter/cli-a4q87517.d.ts +0 -64
  171. package/dist/shared/@outfitter/cli-aem6v4c8.js +0 -146
  172. package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +0 -132
  173. package/dist/shared/@outfitter/cli-b5c2k0d7.js +0 -39
  174. package/dist/shared/@outfitter/cli-b5epywry.js +0 -1
  175. package/dist/shared/@outfitter/cli-bc17qeh2.js +0 -19
  176. package/dist/shared/@outfitter/cli-bcmcaz1b.js +0 -23
  177. package/dist/shared/@outfitter/cli-bv09nme3.d.ts +0 -56
  178. package/dist/shared/@outfitter/cli-c6pbxpw0.d.ts +0 -112
  179. package/dist/shared/@outfitter/cli-c8fqdaes.js +0 -117
  180. package/dist/shared/@outfitter/cli-c8q4f71g.js +0 -144
  181. package/dist/shared/@outfitter/cli-c9knfqn5.d.ts +0 -30
  182. package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +0 -53
  183. package/dist/shared/@outfitter/cli-cf2s94s1.d.ts +0 -42
  184. package/dist/shared/@outfitter/cli-cwgj6mcs.js +0 -214
  185. package/dist/shared/@outfitter/cli-d8ahdd9d.js +0 -272
  186. package/dist/shared/@outfitter/cli-dbyteh27.d.ts +0 -24
  187. package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +0 -91
  188. package/dist/shared/@outfitter/cli-en6zn6sj.js +0 -1
  189. package/dist/shared/@outfitter/cli-evx7qcp1.d.ts +0 -300
  190. package/dist/shared/@outfitter/cli-f6fsaayd.js +0 -94
  191. package/dist/shared/@outfitter/cli-fakncnjp.d.ts +0 -106
  192. package/dist/shared/@outfitter/cli-ffa0jwb7.js +0 -122
  193. package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +0 -66
  194. package/dist/shared/@outfitter/cli-h3jz0bxz.js +0 -48
  195. package/dist/shared/@outfitter/cli-h4wpzb3f.js +0 -67
  196. package/dist/shared/@outfitter/cli-hda6mc28.js +0 -126
  197. package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +0 -328
  198. package/dist/shared/@outfitter/cli-j19a91ck.js +0 -30
  199. package/dist/shared/@outfitter/cli-jejfypgf.js +0 -85
  200. package/dist/shared/@outfitter/cli-jp0k3qd9.js +0 -279
  201. package/dist/shared/@outfitter/cli-k76e7173.js +0 -128
  202. package/dist/shared/@outfitter/cli-kc3ffp1v.d.ts +0 -23
  203. package/dist/shared/@outfitter/cli-kk5hnndk.d.ts +0 -128
  204. package/dist/shared/@outfitter/cli-ktqme80d.js +0 -7
  205. package/dist/shared/@outfitter/cli-mq0jp15z.js +0 -1
  206. package/dist/shared/@outfitter/cli-n0c33vba.js +0 -25
  207. package/dist/shared/@outfitter/cli-n17gt1dz.js +0 -19
  208. package/dist/shared/@outfitter/cli-n9dbh0hp.js +0 -51
  209. package/dist/shared/@outfitter/cli-ndem6tz8.js +0 -63
  210. package/dist/shared/@outfitter/cli-nj4nqy1h.d.ts +0 -24
  211. package/dist/shared/@outfitter/cli-nkns8p4r.js +0 -61
  212. package/dist/shared/@outfitter/cli-p3dqm1vd.js +0 -22
  213. package/dist/shared/@outfitter/cli-pndwprz8.js +0 -118
  214. package/dist/shared/@outfitter/cli-pvrwv6rb.js +0 -352
  215. package/dist/shared/@outfitter/cli-py02m79x.d.ts +0 -20
  216. package/dist/shared/@outfitter/cli-qj83y5wj.d.ts +0 -71
  217. package/dist/shared/@outfitter/cli-regjbef6.d.ts +0 -26
  218. package/dist/shared/@outfitter/cli-s1tx5kha.d.ts +0 -59
  219. package/dist/shared/@outfitter/cli-sam2sq50.js +0 -37
  220. package/dist/shared/@outfitter/cli-snxj55n6.js +0 -43
  221. package/dist/shared/@outfitter/cli-symyxb0z.js +0 -20
  222. package/dist/shared/@outfitter/cli-tvw1xrdj.js +0 -20
  223. package/dist/shared/@outfitter/cli-v1tzwxkt.js +0 -32
  224. package/dist/shared/@outfitter/cli-vd60dj65.js +0 -1
  225. package/dist/shared/@outfitter/cli-vfcrskfj.d.ts +0 -41
  226. package/dist/shared/@outfitter/cli-vstbkzky.d.ts +0 -74
  227. package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +0 -54
  228. package/dist/shared/@outfitter/cli-x4cavvc0.js +0 -1
  229. package/dist/shared/@outfitter/cli-xep6v2c0.js +0 -52
  230. package/dist/shared/@outfitter/cli-xg5y5fhk.js +0 -86
  231. package/dist/shared/@outfitter/cli-y7k1t81k.js +0 -30
  232. package/dist/shared/@outfitter/cli-yfyzy95c.js +0 -67
  233. package/dist/shared/@outfitter/cli-z78mkrc7.js +0 -59
  234. package/dist/shared/@outfitter/cli-znc47004.js +0 -134
  235. package/dist/shared/@outfitter/cli-zx598p8q.d.ts +0 -26
  236. package/dist/streaming/ansi.d.ts +0 -2
  237. package/dist/streaming/ansi.js +0 -8
  238. package/dist/streaming/index.d.ts +0 -4
  239. package/dist/streaming/index.js +0 -17
  240. package/dist/streaming/spinner.d.ts +0 -3
  241. package/dist/streaming/spinner.js +0 -10
  242. package/dist/streaming/writer.d.ts +0 -2
  243. package/dist/streaming/writer.js +0 -9
  244. package/dist/table/index.d.ts +0 -4
  245. package/dist/table/index.js +0 -13
  246. package/dist/theme/context.d.ts +0 -9
  247. package/dist/theme/context.js +0 -14
  248. package/dist/theme/create.d.ts +0 -8
  249. package/dist/theme/create.js +0 -12
  250. package/dist/theme/index.d.ts +0 -17
  251. package/dist/theme/index.js +0 -42
  252. package/dist/theme/presets/bold.d.ts +0 -8
  253. package/dist/theme/presets/bold.js +0 -12
  254. package/dist/theme/presets/default.d.ts +0 -8
  255. package/dist/theme/presets/default.js +0 -11
  256. package/dist/theme/presets/index.d.ts +0 -12
  257. package/dist/theme/presets/index.js +0 -24
  258. package/dist/theme/presets/minimal.d.ts +0 -8
  259. package/dist/theme/presets/minimal.js +0 -12
  260. package/dist/theme/presets/rounded.d.ts +0 -8
  261. package/dist/theme/presets/rounded.js +0 -12
  262. package/dist/theme/resolve.d.ts +0 -8
  263. package/dist/theme/resolve.js +0 -11
  264. package/dist/theme/types.d.ts +0 -7
  265. package/dist/theme/types.js +0 -1
  266. package/dist/tree/index.d.ts +0 -3
  267. package/dist/tree/index.js +0 -11
  268. /package/dist/shared/@outfitter/{cli-ykxn7rb2.d.ts → cli-xppg982q.d.ts} +0 -0
  269. /package/dist/{render/types.js → shared/@outfitter/cli-zw75pdk8.js} +0 -0
@@ -1,300 +0,0 @@
1
- /**
2
- * A tree node for hierarchical data structures.
3
- *
4
- * @example
5
- * ```typescript
6
- * const tree: TreeNode = {
7
- * name: "src",
8
- * children: [
9
- * { name: "index.ts", children: [] },
10
- * { name: "utils", children: [{ name: "helpers.ts", children: [] }] },
11
- * ],
12
- * };
13
- * ```
14
- */
15
- interface TreeNode {
16
- /** The name/label of this node */
17
- name: string;
18
- /** Child nodes (empty array for leaf nodes) */
19
- children: TreeNode[];
20
- }
21
- /**
22
- * A collection of items, rendered as table (objects) or list (primitives).
23
- *
24
- * @example
25
- * ```typescript
26
- * // Table rendering (array of objects)
27
- * const users: Collection = {
28
- * type: "collection",
29
- * items: [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }],
30
- * headers: { name: "Name", age: "Age" },
31
- * };
32
- *
33
- * // List rendering (array of primitives)
34
- * const tasks: Collection = {
35
- * type: "collection",
36
- * items: ["Task 1", "Task 2", "Task 3"],
37
- * };
38
- * ```
39
- */
40
- interface Collection {
41
- /** Discriminant for Collection type */
42
- type: "collection";
43
- /** Array of items to render */
44
- items: unknown[];
45
- /** Optional custom headers for table rendering */
46
- headers?: Record<string, string>;
47
- }
48
- /**
49
- * A hierarchical tree structure.
50
- *
51
- * @example
52
- * ```typescript
53
- * const fileTree: Hierarchy = {
54
- * type: "hierarchy",
55
- * root: {
56
- * name: "project",
57
- * children: [
58
- * { name: "src", children: [{ name: "index.ts", children: [] }] },
59
- * { name: "package.json", children: [] },
60
- * ],
61
- * },
62
- * };
63
- * ```
64
- */
65
- interface Hierarchy {
66
- /** Discriminant for Hierarchy type */
67
- type: "hierarchy";
68
- /** Root node of the tree */
69
- root: TreeNode;
70
- }
71
- /**
72
- * Key-value pairs for displaying configuration or metadata.
73
- *
74
- * @example
75
- * ```typescript
76
- * const config: KeyValue = {
77
- * type: "keyvalue",
78
- * entries: {
79
- * name: "my-app",
80
- * version: "1.0.0",
81
- * debug: true,
82
- * },
83
- * };
84
- * ```
85
- */
86
- interface KeyValue {
87
- /** Discriminant for KeyValue type */
88
- type: "keyvalue";
89
- /** Key-value entries to display */
90
- entries: Record<string, unknown>;
91
- }
92
- /**
93
- * A resource with content in a specific format.
94
- *
95
- * @example
96
- * ```typescript
97
- * const jsonResource: Resource = {
98
- * type: "resource",
99
- * data: { name: "test", value: 42 },
100
- * format: "json",
101
- * };
102
- *
103
- * const markdownResource: Resource = {
104
- * type: "resource",
105
- * data: "# Heading\n\nSome **bold** text",
106
- * format: "markdown",
107
- * };
108
- * ```
109
- */
110
- interface Resource {
111
- /** Discriminant for Resource type */
112
- type: "resource";
113
- /** The content to render */
114
- data: unknown;
115
- /** Output format (defaults to "json") */
116
- format?: "json" | "markdown" | "text";
117
- }
118
- /**
119
- * Discriminated union of all output shape types.
120
- *
121
- * Use the type guards {@link isCollection}, {@link isHierarchy},
122
- * {@link isKeyValue}, and {@link isResource} for type narrowing.
123
- *
124
- * @example
125
- * ```typescript
126
- * function processShape(shape: Shape) {
127
- * if (isCollection(shape)) {
128
- * console.log(`Collection with ${shape.items.length} items`);
129
- * } else if (isHierarchy(shape)) {
130
- * console.log(`Tree rooted at ${shape.root.name}`);
131
- * }
132
- * }
133
- * ```
134
- */
135
- type Shape = Collection | Hierarchy | KeyValue | Resource;
136
- /**
137
- * Options for the unified {@link render} function.
138
- *
139
- * @example
140
- * ```typescript
141
- * const options: RenderOptions = {
142
- * width: 80,
143
- * color: true,
144
- * format: "json",
145
- * };
146
- * ```
147
- */
148
- interface RenderOptions {
149
- /** Maximum width for output (used by some renderers) */
150
- width?: number;
151
- /** Whether to use ANSI colors in output */
152
- color?: boolean;
153
- /** Force a specific output format, overriding auto-selection */
154
- format?: "table" | "list" | "tree" | "json" | "text";
155
- }
156
- /**
157
- * Type guard for {@link Collection} shapes.
158
- *
159
- * @param shape - Shape to check
160
- * @returns `true` if the shape is a Collection
161
- *
162
- * @example
163
- * ```typescript
164
- * if (isCollection(shape)) {
165
- * console.log(`Has ${shape.items.length} items`);
166
- * }
167
- * ```
168
- */
169
- declare function isCollection(shape: Shape): shape is Collection;
170
- /**
171
- * Type guard for {@link Hierarchy} shapes.
172
- *
173
- * @param shape - Shape to check
174
- * @returns `true` if the shape is a Hierarchy
175
- *
176
- * @example
177
- * ```typescript
178
- * if (isHierarchy(shape)) {
179
- * console.log(`Root: ${shape.root.name}`);
180
- * }
181
- * ```
182
- */
183
- declare function isHierarchy(shape: Shape): shape is Hierarchy;
184
- /**
185
- * Type guard for {@link KeyValue} shapes.
186
- *
187
- * @param shape - Shape to check
188
- * @returns `true` if the shape is a KeyValue
189
- *
190
- * @example
191
- * ```typescript
192
- * if (isKeyValue(shape)) {
193
- * console.log(`Keys: ${Object.keys(shape.entries).join(", ")}`);
194
- * }
195
- * ```
196
- */
197
- declare function isKeyValue(shape: Shape): shape is KeyValue;
198
- /**
199
- * Type guard for {@link Resource} shapes.
200
- *
201
- * @param shape - Shape to check
202
- * @returns `true` if the shape is a Resource
203
- *
204
- * @example
205
- * ```typescript
206
- * if (isResource(shape)) {
207
- * console.log(`Format: ${shape.format ?? "json"}`);
208
- * }
209
- * ```
210
- */
211
- declare function isResource(shape: Shape): shape is Resource;
212
- /**
213
- * Converts a TreeNode to the Record format expected by renderTree.
214
- */
215
- declare function treeNodeToRecord(node: TreeNode): Record<string, unknown>;
216
- /**
217
- * Checks if an item is a plain object (not null, not array, not primitive).
218
- */
219
- declare function isPlainObject(item: unknown): item is Record<string, unknown>;
220
- /**
221
- * A function that renders a shape to a string.
222
- *
223
- * @typeParam S - The specific shape type this renderer handles
224
- */
225
- type ShapeRenderer<S extends Shape = Shape> = (shape: S, options?: RenderOptions) => string;
226
- /**
227
- * Registers a custom renderer for a shape type.
228
- * Custom renderers take precedence over built-in renderers.
229
- *
230
- * @param shapeType - The shape type to register (e.g., "collection", "hierarchy")
231
- * @param renderer - The renderer function to use for this shape type
232
- *
233
- * @example
234
- * ```typescript
235
- * registerRenderer("collection", (shape, opts) => {
236
- * return shape.items.map(item => `- ${item}`).join("\n");
237
- * });
238
- * ```
239
- */
240
- declare function registerRenderer<S extends Shape>(shapeType: S["type"], renderer: ShapeRenderer<S>): void;
241
- /**
242
- * Removes a custom renderer, reverting to built-in behavior.
243
- *
244
- * @param shapeType - The shape type to unregister
245
- * @returns `true` if a renderer was removed, `false` if none existed
246
- *
247
- * @example
248
- * ```typescript
249
- * unregisterRenderer("collection"); // Reverts to built-in table/list rendering
250
- * ```
251
- */
252
- declare function unregisterRenderer(shapeType: string): boolean;
253
- /**
254
- * Clears all custom renderers, reverting to built-in behavior.
255
- * Useful for testing to ensure clean state between tests.
256
- *
257
- * @example
258
- * ```typescript
259
- * afterEach(() => {
260
- * clearRenderers();
261
- * });
262
- * ```
263
- */
264
- declare function clearRenderers(): void;
265
- /**
266
- * Unified render function that auto-selects the appropriate renderer based on shape type.
267
- *
268
- * Auto-selection logic:
269
- * - **Collection**: Uses {@link renderTable} for object items, {@link renderList} for primitives
270
- * - **Hierarchy**: Uses {@link renderTree}
271
- * - **KeyValue**: Renders as formatted key-value pairs (JSON-like)
272
- * - **Resource**: Uses {@link renderJson}, {@link renderMarkdown}, or {@link renderText} based on format
273
- *
274
- * The `options.format` parameter can override auto-selection.
275
- *
276
- * @param shape - The shape to render
277
- * @param options - Rendering options
278
- * @returns Rendered string output
279
- *
280
- * @example
281
- * ```typescript
282
- * // Collection auto-selects table or list
283
- * render({ type: "collection", items: [{ name: "Alice" }] });
284
- * render({ type: "collection", items: ["item1", "item2"] });
285
- *
286
- * // Hierarchy uses tree rendering
287
- * render({ type: "hierarchy", root: { name: "src", children: [] } });
288
- *
289
- * // KeyValue renders formatted pairs
290
- * render({ type: "keyvalue", entries: { key: "value" } });
291
- *
292
- * // Resource respects format option
293
- * render({ type: "resource", data: obj, format: "json" });
294
- *
295
- * // Override with options.format
296
- * render({ type: "collection", items: [{ a: 1 }] }, { format: "json" });
297
- * ```
298
- */
299
- declare function render(shape: Shape, options?: RenderOptions): string;
300
- export { TreeNode, Collection, Hierarchy, KeyValue, Resource, Shape, RenderOptions, isCollection, isHierarchy, isKeyValue, isResource, treeNodeToRecord, isPlainObject, ShapeRenderer, registerRenderer, unregisterRenderer, clearRenderers, render };
@@ -1,94 +0,0 @@
1
- // @bun
2
- import {
3
- renderTable
4
- } from "./cli-c8fqdaes.js";
5
- import {
6
- BORDER_STYLE_META,
7
- getBorderStyles
8
- } from "./cli-d8ahdd9d.js";
9
- import {
10
- getExample
11
- } from "./cli-xep6v2c0.js";
12
- import {
13
- demoSection
14
- } from "./cli-sam2sq50.js";
15
-
16
- // packages/cli/src/demo/renderers/table.ts
17
- function renderTableDemo(config, theme) {
18
- const showCode = config.showCode ?? true;
19
- const showDescriptions = config.showDescriptions ?? true;
20
- const lines = [];
21
- lines.push(demoSection("Basic Table"));
22
- lines.push("");
23
- if (showCode) {
24
- lines.push('import { renderTable } from "@outfitter/cli/render";');
25
- lines.push("");
26
- lines.push("renderTable([");
27
- lines.push(' { id: 1, name: "Alice", status: "Active" },');
28
- lines.push(' { id: 2, name: "Bob", status: "Pending" },');
29
- lines.push("])");
30
- lines.push("");
31
- }
32
- const basicData = getExample("tableData", config.examples);
33
- lines.push(renderTable(basicData));
34
- lines.push("");
35
- lines.push(demoSection("Custom Headers"));
36
- lines.push("");
37
- if (showCode) {
38
- lines.push("renderTable(data, {");
39
- lines.push(' headers: { id: "Task ID", name: "Assignee" }');
40
- lines.push("})");
41
- lines.push("");
42
- }
43
- lines.push(renderTable(basicData, {
44
- headers: { id: "Task ID", name: "Assignee" }
45
- }));
46
- lines.push("");
47
- lines.push(demoSection("Border Styles"));
48
- lines.push("");
49
- const styles = getBorderStyles().filter((s) => s !== "none");
50
- const smallData = [
51
- { id: 1, name: "Alice" },
52
- { id: 2, name: "Bob" }
53
- ];
54
- for (const style of styles) {
55
- const meta = BORDER_STYLE_META[style];
56
- lines.push(`${meta.label.toUpperCase()} (border: "${style}")`);
57
- if (showDescriptions) {
58
- lines.push(theme.muted(meta.description));
59
- }
60
- lines.push("");
61
- lines.push(renderTable(smallData, { border: style }));
62
- lines.push("");
63
- }
64
- lines.push(demoSection("Compact Mode"));
65
- lines.push("");
66
- if (showCode) {
67
- lines.push("renderTable(data, { compact: true })");
68
- lines.push("");
69
- }
70
- lines.push(renderTable(smallData, { compact: true }));
71
- lines.push("");
72
- lines.push(theme.muted("Compact mode removes borders and uses space separators."));
73
- lines.push("");
74
- lines.push(demoSection("Wide Characters (CJK/Emoji)"));
75
- lines.push("");
76
- if (showCode) {
77
- lines.push("renderTable([");
78
- lines.push(' { id: 1, name: "\u5C71\u7530\u592A\u90CE", status: "\u5B8C\u4E86" },');
79
- lines.push(' { id: 2, name: "Party \uD83C\uDF89", status: "\uD83D\uDE80" },');
80
- lines.push("])");
81
- lines.push("");
82
- }
83
- const wideData = [
84
- { id: 1, name: "\u5C71\u7530\u592A\u90CE", status: "\u5B8C\u4E86" },
85
- { id: 2, name: "Party \uD83C\uDF89", status: "\uD83D\uDE80" }
86
- ];
87
- lines.push(renderTable(wideData));
88
- lines.push("");
89
- lines.push(theme.muted("Uses Bun.stringWidth() for correct column alignment."));
90
- return lines.join(`
91
- `);
92
- }
93
-
94
- export { renderTableDemo };
@@ -1,106 +0,0 @@
1
- /**
2
- * Box-drawing border utilities.
3
- *
4
- * Provides border character sets and line drawing functions for tables, boxes, and panels.
5
- *
6
- * @packageDocumentation
7
- */
8
- /**
9
- * Available border style presets.
10
- *
11
- * - `single`: Standard Unicode single-line borders (┌─┐)
12
- * - `double`: Double-line borders (╔═╗)
13
- * - `rounded`: Rounded corners with single lines (╭─╮)
14
- * - `heavy`: Thick/heavy borders (┏━┓)
15
- * - `ascii`: ASCII-only fallback (+, -, |)
16
- * - `none`: No borders (empty strings)
17
- */
18
- type BorderStyle = "single" | "double" | "rounded" | "heavy" | "ascii" | "none";
19
- /**
20
- * Complete set of box-drawing characters for a border style.
21
- *
22
- * Includes corners, edges, and intersection characters for building
23
- * tables, boxes, and other bordered elements.
24
- */
25
- interface BorderCharacters {
26
- /** Top-left corner (e.g., ┌ ╔ ╭ ┏) */
27
- topLeft: string;
28
- /** Top-right corner (e.g., ┐ ╗ ╮ ┓) */
29
- topRight: string;
30
- /** Bottom-left corner (e.g., └ ╚ ╰ ┗) */
31
- bottomLeft: string;
32
- /** Bottom-right corner (e.g., ┘ ╝ ╯ ┛) */
33
- bottomRight: string;
34
- /** Horizontal line (e.g., ─ ═ ━) */
35
- horizontal: string;
36
- /** Vertical line (e.g., │ ║ ┃) */
37
- vertical: string;
38
- /** Top T-intersection for column separators (e.g., ┬ ╦ ┳) */
39
- topT: string;
40
- /** Bottom T-intersection for column separators (e.g., ┴ ╩ ┻) */
41
- bottomT: string;
42
- /** Left T-intersection for row separators (e.g., ├ ╠ ┣) */
43
- leftT: string;
44
- /** Right T-intersection for row separators (e.g., ┤ ╣ ┫) */
45
- rightT: string;
46
- /** Cross intersection for table cells (e.g., ┼ ╬ ╋) */
47
- cross: string;
48
- }
49
- /**
50
- * Preset border character sets for each style.
51
- *
52
- * @example
53
- * ```typescript
54
- * import { BORDERS } from "@outfitter/cli";
55
- *
56
- * const single = BORDERS.single;
57
- * console.log(`${single.topLeft}${single.horizontal.repeat(10)}${single.topRight}`);
58
- * // Output: ┌──────────┐
59
- * ```
60
- */
61
- declare const BORDERS: Record<BorderStyle, BorderCharacters>;
62
- /**
63
- * Returns the border character set for the given style.
64
- *
65
- * @param style - The border style preset
66
- * @returns The complete set of border characters
67
- *
68
- * @example
69
- * ```typescript
70
- * const chars = getBorderCharacters("rounded");
71
- * console.log(chars.topLeft); // ╭
72
- * console.log(chars.topRight); // ╮
73
- * ```
74
- */
75
- declare function getBorderCharacters(style: BorderStyle): BorderCharacters;
76
- /**
77
- * Position of a horizontal line within a bordered element.
78
- */
79
- type LinePosition = "top" | "middle" | "bottom";
80
- /**
81
- * Draws a horizontal line with the appropriate corner/intersection characters.
82
- *
83
- * Used for building table borders and box edges. Handles column intersections
84
- * when column widths are provided.
85
- *
86
- * @param width - Total width of the line content (excluding corners)
87
- * @param chars - Border character set to use
88
- * @param position - Position of line: "top", "middle", or "bottom"
89
- * @param columnWidths - Optional array of column widths for intersection placement
90
- * @returns The formatted horizontal line string
91
- *
92
- * @example
93
- * ```typescript
94
- * const chars = getBorderCharacters("single");
95
- *
96
- * // Simple line (no columns)
97
- * drawHorizontalLine(10, chars, "top");
98
- * // Returns: ┌──────────┐
99
- *
100
- * // Line with column intersections
101
- * drawHorizontalLine(14, chars, "middle", [5, 7]);
102
- * // Returns: ├─────┼───────┤
103
- * ```
104
- */
105
- declare function drawHorizontalLine(width: number, chars: BorderCharacters, position: LinePosition, columnWidths?: number[]): string;
106
- export { BorderStyle, BorderCharacters, BORDERS, getBorderCharacters, LinePosition, drawHorizontalLine };
@@ -1,122 +0,0 @@
1
- // @bun
2
- import {
3
- TREE_GUIDES,
4
- renderTree
5
- } from "./cli-b5c2k0d7.js";
6
- import {
7
- getExample
8
- } from "./cli-xep6v2c0.js";
9
- import {
10
- demoSection
11
- } from "./cli-sam2sq50.js";
12
-
13
- // packages/cli/src/demo/renderers/tree.ts
14
- function renderTreeDemo(config, _theme) {
15
- const showCode = config.showCode ?? true;
16
- const lines = [];
17
- lines.push(demoSection("Basic Tree"));
18
- lines.push("");
19
- if (showCode) {
20
- lines.push('import { renderTree } from "@outfitter/cli/tree";');
21
- lines.push("");
22
- }
23
- const treeData = getExample("treeData", config.examples);
24
- if (showCode) {
25
- lines.push("renderTree({");
26
- lines.push(" src: {");
27
- lines.push(" components: { Button: null, Input: null },");
28
- lines.push(" utils: null,");
29
- lines.push(" },");
30
- lines.push(" tests: null,");
31
- lines.push("})");
32
- lines.push("");
33
- }
34
- lines.push(renderTree(treeData));
35
- lines.push("");
36
- lines.push(demoSection("Guide Styles"));
37
- lines.push("");
38
- const guideDemo = {
39
- root: {
40
- child1: {
41
- leaf: null
42
- },
43
- child2: null
44
- }
45
- };
46
- const guideStyles = [
47
- "single",
48
- "rounded",
49
- "heavy",
50
- "double"
51
- ];
52
- for (const style of guideStyles) {
53
- const guide = TREE_GUIDES[style];
54
- lines.push(`${style.toUpperCase()} (fork: "${guide.fork.trim()}", end: "${guide.end.trim()}")`);
55
- lines.push("");
56
- lines.push(renderTree(guideDemo, { guide: style }));
57
- lines.push("");
58
- }
59
- lines.push(demoSection("Max Depth"));
60
- lines.push("");
61
- const deepTree = {
62
- level1: {
63
- level2: {
64
- level3: {
65
- level4: null
66
- }
67
- }
68
- }
69
- };
70
- if (showCode) {
71
- lines.push("renderTree(tree, { maxDepth: 2 })");
72
- lines.push("");
73
- }
74
- lines.push("Full tree:");
75
- lines.push(renderTree(deepTree));
76
- lines.push("");
77
- lines.push("With maxDepth: 2:");
78
- lines.push(renderTree(deepTree, { maxDepth: 2 }));
79
- lines.push("");
80
- lines.push(demoSection("Custom Labels"));
81
- lines.push("");
82
- const fileTree = {
83
- src: {
84
- "index.ts": null,
85
- components: {
86
- "Button.tsx": null
87
- }
88
- },
89
- "package.json": null
90
- };
91
- if (showCode) {
92
- lines.push("renderTree(tree, {");
93
- lines.push(" renderLabel: (key, value) => {");
94
- lines.push(" if (value && typeof value === 'object') {");
95
- lines.push(" return `\uD83D\uDCC1 ${key}/`;");
96
- lines.push(" }");
97
- lines.push(" return `\uD83D\uDCC4 ${key}`;");
98
- lines.push(" }");
99
- lines.push("})");
100
- lines.push("");
101
- }
102
- lines.push(renderTree(fileTree, {
103
- renderLabel: (key, value) => {
104
- if (value && typeof value === "object") {
105
- return `\uD83D\uDCC1 ${key}/`;
106
- }
107
- return `\uD83D\uDCC4 ${key}`;
108
- }
109
- }));
110
- lines.push("");
111
- lines.push(demoSection("Usage Notes"));
112
- lines.push("");
113
- lines.push("\u2022 Objects become branches with children");
114
- lines.push("\u2022 null values become leaf nodes (terminal)");
115
- lines.push("\u2022 Use guide option to change visual style");
116
- lines.push("\u2022 Use maxDepth to limit rendering depth");
117
- lines.push("\u2022 Use renderLabel for custom node formatting");
118
- return lines.join(`
119
- `);
120
- }
121
-
122
- export { renderTreeDemo };
@@ -1,66 +0,0 @@
1
- import { WritableStream } from "./cli-cf1xexgn";
2
- /**
3
- * Spinner frame sets.
4
- */
5
- declare const SPINNER_FRAMES: {
6
- readonly dots: readonly ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
7
- readonly line: readonly ["-", "\\", "|", "/"];
8
- readonly simple: readonly ["◐", "◓", "◑", "◒"];
9
- };
10
- /**
11
- * Available spinner styles.
12
- */
13
- type SpinnerStyle = keyof typeof SPINNER_FRAMES;
14
- /**
15
- * Options for creating a spinner.
16
- */
17
- interface SpinnerOptions {
18
- /** Spinner style */
19
- style?: SpinnerStyle;
20
- /** Target stream */
21
- stream?: WritableStream;
22
- /** Frame interval in ms */
23
- interval?: number;
24
- }
25
- /**
26
- * Spinner interface for animated progress indication.
27
- */
28
- interface Spinner {
29
- /** Start the spinner */
30
- start(): void;
31
- /** Update the spinner message */
32
- update(message: string): void;
33
- /** Stop with success state */
34
- succeed(message?: string): void;
35
- /** Stop with failure state */
36
- fail(message?: string): void;
37
- /** Stop the spinner */
38
- stop(): void;
39
- }
40
- /**
41
- * Creates an animated spinner for indicating progress.
42
- *
43
- * In TTY mode, shows an animated spinner. In non-TTY mode,
44
- * falls back to static output.
45
- *
46
- * @param message - Initial spinner message
47
- * @param options - Spinner configuration
48
- * @returns Spinner instance
49
- *
50
- * @example
51
- * ```typescript
52
- * import { createSpinner } from "@outfitter/cli/streaming";
53
- *
54
- * const spinner = createSpinner("Installing dependencies");
55
- * spinner.start();
56
- *
57
- * try {
58
- * await install();
59
- * spinner.succeed("Dependencies installed");
60
- * } catch (error) {
61
- * spinner.fail("Installation failed");
62
- * }
63
- * ```
64
- */
65
- declare function createSpinner(message: string, options?: SpinnerOptions): Spinner;
66
- export { SpinnerStyle, SpinnerOptions, Spinner, createSpinner };