@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,87 +0,0 @@
1
- import { Validator } from "./cli-vstbkzky";
2
- import { Result } from "better-result";
3
- /**
4
- * Error returned when user cancels a prompt.
5
- */
6
- interface CancelledError {
7
- type: "cancelled";
8
- message: string;
9
- }
10
- /**
11
- * Creates a cancelled error.
12
- */
13
- declare function createCancelledError(message?: string): CancelledError;
14
- /**
15
- * Options for text prompts.
16
- */
17
- interface TextPromptOptions {
18
- /** Prompt message to display */
19
- message: string;
20
- /** Placeholder text */
21
- placeholder?: string;
22
- /** Default value */
23
- defaultValue?: string;
24
- /** Validation function */
25
- validate?: Validator;
26
- }
27
- /**
28
- * Options for password prompts.
29
- */
30
- interface PasswordPromptOptions {
31
- /** Prompt message to display */
32
- message: string;
33
- /** Validation function */
34
- validate?: Validator;
35
- /** Mask character (default: •) */
36
- mask?: string;
37
- }
38
- /**
39
- * Options for select prompts.
40
- */
41
- interface SelectPromptOptions<T> {
42
- /** Prompt message to display */
43
- message: string;
44
- /** Available options */
45
- options: Array<{
46
- value: T;
47
- label: string;
48
- hint?: string;
49
- }>;
50
- /** Initial selected index */
51
- initialValue?: T;
52
- /** Maximum number of items to display at once */
53
- pageSize?: number;
54
- }
55
- /**
56
- * Options for multi-select prompts.
57
- */
58
- interface MultiSelectPromptOptions<T> {
59
- /** Prompt message to display */
60
- message: string;
61
- /** Available options */
62
- options: Array<{
63
- value: T;
64
- label: string;
65
- hint?: string;
66
- }>;
67
- /** Initially selected values */
68
- initialValues?: T[];
69
- /** Require at least one selection */
70
- required?: boolean;
71
- /** Maximum number of items to display at once */
72
- pageSize?: number;
73
- }
74
- /**
75
- * Options for confirm prompts.
76
- */
77
- interface ConfirmPromptOptions {
78
- /** Prompt message to display */
79
- message: string;
80
- /** Initial value */
81
- initialValue?: boolean;
82
- }
83
- /**
84
- * Type alias for prompt results.
85
- */
86
- type PromptResult<T> = Promise<Result<T, CancelledError>>;
87
- export { CancelledError, createCancelledError, TextPromptOptions, PasswordPromptOptions, SelectPromptOptions, MultiSelectPromptOptions, ConfirmPromptOptions, PromptResult };
@@ -1,190 +0,0 @@
1
- import { BoxOptions } from "./cli-8xsmsbbd";
2
- import { LayoutContext, WidthMode } from "./cli-2g8bx1aq";
3
- /**
4
- * Gets the current terminal width.
5
- *
6
- * Returns `process.stdout.columns` if available, otherwise falls back to 80
7
- * (standard terminal width).
8
- *
9
- * @returns Terminal width in characters
10
- *
11
- * @example
12
- * ```typescript
13
- * import { getTerminalWidth } from "@outfitter/cli/render";
14
- *
15
- * const width = getTerminalWidth();
16
- * console.log(`Terminal is ${width} columns wide`);
17
- * ```
18
- */
19
- declare function getTerminalWidth(): number;
20
- /**
21
- * Calculates box overhead (borders + padding) for each axis.
22
- *
23
- * Returns the total character/line count consumed by borders and padding,
24
- * separate from content.
25
- *
26
- * @param options - Box options (padding, borders)
27
- * @returns Object with horizontal and vertical overhead
28
- *
29
- * @example
30
- * ```typescript
31
- * import { getBoxOverhead } from "@outfitter/cli/render";
32
- *
33
- * const overhead = getBoxOverhead({ padding: 1, border: "single" });
34
- * // { horizontal: 4, vertical: 2 }
35
- * // horizontal: left border (1) + left padding (1) + right padding (1) + right border (1)
36
- * // vertical: top border (1) + bottom border (1)
37
- * ```
38
- */
39
- declare function getBoxOverhead(options: BoxOptions): {
40
- horizontal: number;
41
- vertical: number;
42
- };
43
- /**
44
- * Calculates available content width inside a box.
45
- *
46
- * Accounts for borders and padding to determine how much space remains
47
- * for content. Use this to size nested components appropriately.
48
- *
49
- * @param options - Box options (width, padding, borders)
50
- * @returns Available width in characters for content
51
- *
52
- * @example
53
- * ```typescript
54
- * import { getContentWidth, createBox, renderProgress } from "@outfitter/cli/render";
55
- *
56
- * const boxOpts = { width: 40, padding: 1, border: "single" };
57
- * const available = getContentWidth(boxOpts); // → 36
58
- *
59
- * const progress = renderProgress(0.5, { width: available });
60
- * const box = createBox(progress, boxOpts);
61
- * ```
62
- */
63
- declare function getContentWidth(options: BoxOptions): number;
64
- /**
65
- * Resolves a width mode to a concrete character width.
66
- *
67
- * Width modes allow flexible sizing relative to terminal or container:
68
- * - `"text"` → 0 (content-sized, no constraint)
69
- * - `"full"` → terminal width
70
- * - `"container"` → container width (requires context)
71
- * - `number` → fixed width
72
- * - `"${number}%"` → percentage of container/terminal
73
- *
74
- * @param mode - Width specification
75
- * @param ctx - Layout context for container-relative modes
76
- * @returns Resolved width in characters
77
- * @throws Error if "container" mode used without context
78
- *
79
- * @example
80
- * ```typescript
81
- * import { resolveWidth, createLayoutContext } from "@outfitter/cli/render";
82
- *
83
- * resolveWidth("full"); // → 120 (terminal width)
84
- * resolveWidth(50); // → 50
85
- * resolveWidth("50%"); // → 60 (half of terminal)
86
- *
87
- * const ctx = createLayoutContext({ width: 80, padding: 1 });
88
- * resolveWidth("50%", ctx); // → 38 (half of context width)
89
- * resolveWidth("container", ctx); // → 76 (context width)
90
- * ```
91
- */
92
- declare function resolveWidth(mode: WidthMode, ctx?: LayoutContext): number;
93
- /**
94
- * Creates a layout context from box options.
95
- *
96
- * Layout contexts propagate width information through nested components,
97
- * enabling relative sizing like `"50%"` or `"container"`.
98
- *
99
- * @param options - Box options defining the container
100
- * @param parent - Parent context for chained calculations
101
- * @returns New layout context with calculated content width
102
- *
103
- * @example
104
- * ```typescript
105
- * import { createLayoutContext, resolveWidth, createBox } from "@outfitter/cli/render";
106
- *
107
- * // Outer container
108
- * const outerOpts = { width: 80, padding: 1 };
109
- * const outerCtx = createLayoutContext(outerOpts);
110
- * // outerCtx.width = 76 (80 - 4 overhead)
111
- *
112
- * // Nested component at 50% width
113
- * const innerWidth = resolveWidth("50%", outerCtx);
114
- * const innerOpts = { width: innerWidth, padding: 1 };
115
- * const innerCtx = createLayoutContext(innerOpts, outerCtx);
116
- * // innerCtx.width = 34 (38 - 4 overhead)
117
- * ```
118
- */
119
- declare function createLayoutContext(options: BoxOptions, parent?: LayoutContext): LayoutContext;
120
- /**
121
- * Vertical alignment for horizontal layout.
122
- */
123
- type Alignment = "top" | "center" | "bottom";
124
- /**
125
- * Options for horizontal layout.
126
- */
127
- interface HorizontalLayoutOptions {
128
- /** Gap (in characters) between blocks */
129
- gap?: number;
130
- /** Vertical alignment of blocks */
131
- align?: Alignment;
132
- }
133
- /**
134
- * Options for vertical layout.
135
- */
136
- interface VerticalLayoutOptions {
137
- /** Gap (in lines) between blocks */
138
- gap?: number;
139
- }
140
- /**
141
- * Joins multiple text blocks horizontally (side by side).
142
- *
143
- * Handles blocks of different heights by aligning them according
144
- * to the `align` option. Blocks are padded to maintain alignment.
145
- *
146
- * @param blocks - Array of text blocks to join
147
- * @param options - Layout options
148
- * @returns Combined string with blocks side by side
149
- *
150
- * @example
151
- * ```typescript
152
- * import { joinHorizontal } from "@outfitter/cli/render";
153
- * import { renderBox } from "@outfitter/cli/render";
154
- *
155
- * const left = renderBox({ content: "Left", borderStyle: "single" });
156
- * const right = renderBox({ content: "Right", borderStyle: "single" });
157
- *
158
- * console.log(joinHorizontal([left, right], { gap: 2 }));
159
- * // ┌──────┐ ┌───────┐
160
- * // │ Left │ │ Right │
161
- * // └──────┘ └───────┘
162
- * ```
163
- */
164
- declare function joinHorizontal(blocks: string[], options?: HorizontalLayoutOptions): string;
165
- /**
166
- * Joins multiple text blocks vertically (stacked).
167
- *
168
- * @param blocks - Array of text blocks to stack
169
- * @param options - Layout options
170
- * @returns Combined string with blocks stacked
171
- *
172
- * @example
173
- * ```typescript
174
- * import { joinVertical, renderHeading, renderSeparator } from "@outfitter/cli/render";
175
- *
176
- * const heading = renderHeading("Section Title");
177
- * const separator = renderSeparator({ width: 20 });
178
- * const content = "Some content here.";
179
- *
180
- * console.log(joinVertical([heading, separator, content], { gap: 1 }));
181
- * // SECTION TITLE
182
- * // =============
183
- * //
184
- * // ────────────────────
185
- * //
186
- * // Some content here.
187
- * ```
188
- */
189
- declare function joinVertical(blocks: string[], options?: VerticalLayoutOptions): string;
190
- export { getTerminalWidth, getBoxOverhead, getContentWidth, resolveWidth, createLayoutContext, Alignment, HorizontalLayoutOptions, VerticalLayoutOptions, joinHorizontal, joinVertical };
@@ -1,64 +0,0 @@
1
- import { Result, ValidationError } from "@outfitter/contracts";
2
- /**
3
- * Represents a date range with start and end dates.
4
- */
5
- interface DateRange {
6
- /** Start of the range (inclusive, at 00:00:00.000) */
7
- start: Date;
8
- /** End of the range (inclusive, at 23:59:59.999) */
9
- end: Date;
10
- }
11
- /**
12
- * Returns a new Date set to the start of the day (00:00:00.000).
13
- *
14
- * @param date - The date to adjust
15
- * @returns A new Date object at 00:00:00.000 on the same day
16
- *
17
- * @example
18
- * ```typescript
19
- * startOfDay(new Date("2024-06-15T14:30:00Z"))
20
- * // Returns 2024-06-15T00:00:00.000 (local time)
21
- * ```
22
- */
23
- declare function startOfDay(date: Date): Date;
24
- /**
25
- * Returns a new Date set to the end of the day (23:59:59.999).
26
- *
27
- * @param date - The date to adjust
28
- * @returns A new Date object at 23:59:59.999 on the same day
29
- *
30
- * @example
31
- * ```typescript
32
- * endOfDay(new Date("2024-06-15T14:30:00Z"))
33
- * // Returns 2024-06-15T23:59:59.999 (local time)
34
- * ```
35
- */
36
- declare function endOfDay(date: Date): Date;
37
- /**
38
- * Parses date range strings into structured DateRange.
39
- *
40
- * Supported formats:
41
- * - `"today"` - Current day (00:00:00 to 23:59:59)
42
- * - `"yesterday"` - Previous day
43
- * - `"last week"` - Last 7 days
44
- * - `"last month"` - Last 30 days
45
- * - `"2024-01-01..2024-12-31"` - Explicit range
46
- * - `"2024-01-01"` - Single day
47
- *
48
- * @param input - The date range string to parse
49
- * @returns Result containing DateRange on success, or ValidationError on failure
50
- *
51
- * @example
52
- * ```typescript
53
- * parseDateRange("today")
54
- * // Ok({ start: today 00:00, end: today 23:59:59 })
55
- *
56
- * parseDateRange("2024-01-01..2024-12-31")
57
- * // Ok({ start: 2024-01-01 00:00, end: 2024-12-31 23:59:59 })
58
- *
59
- * parseDateRange("invalid")
60
- * // Err(ValidationError)
61
- * ```
62
- */
63
- declare function parseDateRange(input: string): Result<DateRange, InstanceType<typeof ValidationError>>;
64
- export { DateRange, startOfDay, endOfDay, parseDateRange };
@@ -1,146 +0,0 @@
1
- // @bun
2
- import {
3
- init_box,
4
- normalizeBorders,
5
- normalizePadding
6
- } from "./cli-jp0k3qd9.js";
7
-
8
- // packages/cli/src/render/layout.ts
9
- init_box();
10
- function getTerminalWidth() {
11
- return process.stdout.columns ?? 80;
12
- }
13
- function getBoxOverhead(options) {
14
- const pad = normalizePadding(options.padding, 1);
15
- const borders = normalizeBorders(options.borders);
16
- return {
17
- horizontal: (borders.left ? 1 : 0) + (borders.right ? 1 : 0) + pad.left + pad.right,
18
- vertical: (borders.top ? 1 : 0) + (borders.bottom ? 1 : 0) + pad.top + pad.bottom
19
- };
20
- }
21
- function getContentWidth(options) {
22
- const { horizontal } = getBoxOverhead(options);
23
- if (options.width) {
24
- const content = options.width - horizontal;
25
- return Math.max(0, content);
26
- }
27
- return Math.max(0, getTerminalWidth() - horizontal);
28
- }
29
- function resolveWidth(mode, ctx) {
30
- if (typeof mode === "number") {
31
- return mode;
32
- }
33
- if (mode === "text") {
34
- return 0;
35
- }
36
- if (mode === "full") {
37
- return getTerminalWidth();
38
- }
39
- if (mode === "container") {
40
- if (!ctx) {
41
- throw new Error("container width mode requires LayoutContext");
42
- }
43
- return ctx.width;
44
- }
45
- const percent = Number.parseInt(mode.slice(0, -1), 10);
46
- const baseWidth = ctx?.width ?? getTerminalWidth();
47
- return Math.floor(baseWidth * (percent / 100));
48
- }
49
- function createLayoutContext(options, parent) {
50
- const effectiveOptions = { ...options };
51
- if (effectiveOptions.width === undefined && parent) {
52
- effectiveOptions.width = parent.width;
53
- }
54
- const width = getContentWidth(effectiveOptions);
55
- return {
56
- width,
57
- ...parent && { parent }
58
- };
59
- }
60
- function getWidth(text) {
61
- return Bun.stringWidth(text);
62
- }
63
- function splitLines(block) {
64
- return block.split(`
65
- `);
66
- }
67
- function padToWidth(text, width) {
68
- const currentWidth = getWidth(text);
69
- if (currentWidth >= width)
70
- return text;
71
- return text + " ".repeat(width - currentWidth);
72
- }
73
- function createFilledArray(length, value) {
74
- const result = [];
75
- for (let i = 0;i < length; i++) {
76
- result.push(value);
77
- }
78
- return result;
79
- }
80
- function joinHorizontal(blocks, options) {
81
- if (blocks.length === 0)
82
- return "";
83
- const first = blocks[0];
84
- if (first === undefined)
85
- return "";
86
- if (blocks.length === 1)
87
- return first;
88
- const gap = options?.gap ?? 0;
89
- const align = options?.align ?? "top";
90
- const gapString = " ".repeat(gap);
91
- const blockLines = blocks.map(splitLines);
92
- const maxHeight = Math.max(...blockLines.map((lines) => lines.length));
93
- const blockWidths = blockLines.map((lines) => Math.max(...lines.map(getWidth)));
94
- const paddedBlocks = blockLines.map((lines, blockIndex) => {
95
- const width = blockWidths[blockIndex] ?? 0;
96
- const height = lines.length;
97
- const padding = maxHeight - height;
98
- let topPadding;
99
- switch (align) {
100
- case "top":
101
- topPadding = 0;
102
- break;
103
- case "center":
104
- topPadding = Math.floor(padding / 2);
105
- break;
106
- case "bottom":
107
- topPadding = padding;
108
- break;
109
- default: {
110
- const _exhaustive = align;
111
- topPadding = _exhaustive;
112
- }
113
- }
114
- const bottomPadding = padding - topPadding;
115
- const emptyLine = " ".repeat(width);
116
- const paddedLines = [
117
- ...createFilledArray(topPadding, emptyLine),
118
- ...lines.map((line) => padToWidth(line, width)),
119
- ...createFilledArray(bottomPadding, emptyLine)
120
- ];
121
- return paddedLines;
122
- });
123
- const resultLines = [];
124
- for (let i = 0;i < maxHeight; i++) {
125
- const lineSegments = paddedBlocks.map((block) => block[i] ?? "");
126
- resultLines.push(lineSegments.join(gapString));
127
- }
128
- return resultLines.join(`
129
- `);
130
- }
131
- function joinVertical(blocks, options) {
132
- if (blocks.length === 0)
133
- return "";
134
- const first = blocks[0];
135
- if (first === undefined)
136
- return "";
137
- if (blocks.length === 1)
138
- return first;
139
- const gap = options?.gap ?? 0;
140
- const gapLines = gap > 0 ? `
141
- `.repeat(gap) : "";
142
- return blocks.join(`
143
- ${gapLines}`);
144
- }
145
-
146
- export { getTerminalWidth, getBoxOverhead, getContentWidth, resolveWidth, createLayoutContext, joinHorizontal, joinVertical };
@@ -1,132 +0,0 @@
1
- /**
2
- * List rendering utilities.
3
- *
4
- * Renders arrays as bullet lists with optional nesting and multiple styles.
5
- *
6
- * @packageDocumentation
7
- */
8
- /**
9
- * Available list styles for {@link renderList}.
10
- *
11
- * - `dash`: Uses - character (default)
12
- * - `bullet`: Uses • character
13
- * - `number`: Uses 1. for top-level, a. for nested, i. for deeply nested
14
- * - `checkbox`: Uses ☐ for unchecked, ☑ for checked
15
- */
16
- type ListStyle = "dash" | "bullet" | "number" | "checkbox";
17
- /**
18
- * Options for customizing list rendering.
19
- *
20
- * @example
21
- * ```typescript
22
- * // Numbered list with custom indent
23
- * renderList(items, { style: "number", indent: 4 });
24
- *
25
- * // Checkbox list with some items checked
26
- * renderList(items, { style: "checkbox", checked: new Set([1, 3]) });
27
- * ```
28
- */
29
- interface ListOptions {
30
- /**
31
- * The list style to use.
32
- * @default "dash"
33
- */
34
- style?: ListStyle;
35
- /**
36
- * Indices of checked top-level items (0-indexed) for checkbox style.
37
- * Only applies to top-level items. For nested items, use the
38
- * `checked` property on {@link NestedListItem} instead.
39
- */
40
- checked?: Set<number>;
41
- /**
42
- * Number of spaces per indentation level.
43
- * @default 2
44
- */
45
- indent?: number;
46
- }
47
- /**
48
- * A list item with optional nested children for {@link renderList}.
49
- *
50
- * @example
51
- * ```typescript
52
- * const item: NestedListItem = {
53
- * text: "Parent item",
54
- * children: ["Child 1", "Child 2"],
55
- * };
56
- *
57
- * // Checkbox item with checked state
58
- * const checkboxItem: NestedListItem = {
59
- * text: "Completed task",
60
- * checked: true,
61
- * };
62
- *
63
- * // Mixed styles: numbered parent with bullet children
64
- * const mixedItem: NestedListItem = {
65
- * text: "Section 1",
66
- * childStyle: "bullet",
67
- * children: ["Unordered item A", "Unordered item B"],
68
- * };
69
- * ```
70
- */
71
- interface NestedListItem {
72
- /** The text content of this list item */
73
- text: string;
74
- /** Optional nested child items (strings or nested items) */
75
- children?: Array<string | NestedListItem>;
76
- /** Whether this item is checked (for checkbox style) */
77
- checked?: boolean;
78
- /** Override style for children (enables mixed numbered/bullet lists) */
79
- childStyle?: ListStyle;
80
- }
81
- /**
82
- * A list item that can be either a simple string or a nested item with children.
83
- *
84
- * @example
85
- * ```typescript
86
- * const items: ListItem[] = [
87
- * "Simple item",
88
- * { text: "Parent", children: ["Child 1", "Child 2"] },
89
- * ];
90
- * ```
91
- */
92
- type ListItem = string | NestedListItem;
93
- /**
94
- * Renders items as a list with optional nesting and multiple styles.
95
- *
96
- * Supports both simple string items and nested items with children.
97
- * The default style uses dash (-) characters.
98
- *
99
- * For numbered lists, child items are indented to align with the parent's
100
- * content (after the marker), creating proper visual hierarchy.
101
- *
102
- * @param items - Array of list items (strings or nested items)
103
- * @param options - Optional configuration for style, checked items, and indent
104
- * @returns Formatted list string
105
- *
106
- * @example
107
- * ```typescript
108
- * // Simple dash list (default)
109
- * console.log(renderList(["First", "Second", "Third"]));
110
- * // - First
111
- * // - Second
112
- * // - Third
113
- *
114
- * // Numbered list with nesting
115
- * console.log(renderList([
116
- * { text: "First section", children: [
117
- * { text: "Subsection A", children: ["Detail i", "Detail ii"] },
118
- * ]},
119
- * ], { style: "number" }));
120
- * // 1. First section
121
- * // a. Subsection A
122
- * // i. Detail i
123
- * // ii. Detail ii
124
- *
125
- * // Checkbox list
126
- * console.log(renderList(["Todo 1", "Todo 2"], { style: "checkbox", checked: new Set([1]) }));
127
- * // ☐ Todo 1
128
- * // ☑ Todo 2
129
- * ```
130
- */
131
- declare function renderList(items: ListItem[], options?: ListOptions): string;
132
- export { ListStyle, ListOptions, NestedListItem, ListItem, renderList };
@@ -1,39 +0,0 @@
1
- // @bun
2
- // packages/cli/src/render/tree.ts
3
- var TREE_GUIDES = {
4
- single: { vertical: "\u2502 ", fork: "\u251C\u2500\u2500 ", end: "\u2514\u2500\u2500 " },
5
- heavy: { vertical: "\u2503 ", fork: "\u2523\u2501\u2501 ", end: "\u2517\u2501\u2501 " },
6
- double: { vertical: "\u2551 ", fork: "\u2560\u2550\u2550 ", end: "\u255A\u2550\u2550 " },
7
- rounded: { vertical: "\u2502 ", fork: "\u251C\u2500\u2500 ", end: "\u2570\u2500\u2500 " }
8
- };
9
- function renderTree(tree, options) {
10
- const guide = TREE_GUIDES[options?.guide ?? "single"];
11
- const maxDepth = options?.maxDepth;
12
- const renderLabel = options?.renderLabel ?? ((key) => key);
13
- const lines = [];
14
- const renderNode = (key, value, prefix, isLast, depth) => {
15
- if (maxDepth !== undefined && depth >= maxDepth) {
16
- return;
17
- }
18
- const connector = isLast ? guide.end : guide.fork;
19
- const label = renderLabel(key, value, depth);
20
- lines.push(prefix + connector + label);
21
- if (value !== null && typeof value === "object") {
22
- const entries2 = Object.entries(value);
23
- const childPrefix = prefix + (isLast ? " " : guide.vertical);
24
- entries2.forEach(([childKey, childValue], index) => {
25
- const childIsLast = index === entries2.length - 1;
26
- renderNode(childKey, childValue, childPrefix, childIsLast, depth + 1);
27
- });
28
- }
29
- };
30
- const entries = Object.entries(tree);
31
- entries.forEach(([key, value], index) => {
32
- const isLast = index === entries.length - 1;
33
- renderNode(key, value, "", isLast, 0);
34
- });
35
- return lines.join(`
36
- `);
37
- }
38
-
39
- export { TREE_GUIDES, renderTree };
@@ -1 +0,0 @@
1
- // @bun
@@ -1,19 +0,0 @@
1
- // @bun
2
- // packages/cli/src/render/progress.ts
3
- function renderProgress(options) {
4
- const { current, total, width = 20, showPercent = false } = options;
5
- if (total <= 0) {
6
- const bar2 = "\u2591".repeat(width);
7
- return showPercent ? `[${bar2}] 0%` : `[${bar2}]`;
8
- }
9
- const percent = Math.min(100, Math.max(0, current / total * 100));
10
- const filled = Math.round(percent / 100 * width);
11
- const empty = width - filled;
12
- const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
13
- if (showPercent) {
14
- return `[${bar}] ${Math.round(percent)}%`;
15
- }
16
- return `[${bar}]`;
17
- }
18
-
19
- export { renderProgress };