convoker 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +1 -1
  2. package/dist/color/index.d.mts +2 -0
  3. package/dist/{color.mjs → color/index.mjs} +1 -2
  4. package/dist/{color-OlJQTTxb.mjs → color-DiZvJ0Fc.mjs} +40 -11
  5. package/dist/color-DiZvJ0Fc.mjs.map +1 -0
  6. package/dist/command/index.d.mts +5 -0
  7. package/dist/command/index.mjs +8 -0
  8. package/dist/{command-D2UiQBNA.mjs → command-8P8qXJ2o.mjs} +98 -195
  9. package/dist/command-8P8qXJ2o.mjs.map +1 -0
  10. package/dist/{index-Dikc5KAP.d.mts → index-BYLskLxk.d.mts} +5 -4
  11. package/dist/{color-BuHvMolk.d.mts → index-BtbthYjp.d.mts} +13 -3
  12. package/dist/{input-B12iaqb8.d.mts → index-ClhbwSD8.d.mts} +20 -5
  13. package/dist/{command-BXmfoT-l.d.mts → index-Cnx4H4D-.d.mts} +10 -25
  14. package/dist/index.d.mts +33 -69
  15. package/dist/index.mjs +91 -9
  16. package/dist/index.mjs.map +1 -0
  17. package/dist/input/index.d.mts +3 -0
  18. package/dist/input/index.mjs +4 -0
  19. package/dist/{input-DRy_sVxZ.mjs → input-XUsy1LCQ.mjs} +5 -3
  20. package/dist/input-XUsy1LCQ.mjs.map +1 -0
  21. package/dist/prompt/index.d.mts +4 -4
  22. package/dist/prompt/index.mjs +4 -6
  23. package/dist/prompt/raw.d.mts +1 -1
  24. package/dist/prompt/raw.mjs +1 -2
  25. package/dist/{prompt-Cvufljin.mjs → prompt-a5Ix_Hyc.mjs} +30 -58
  26. package/dist/prompt-a5Ix_Hyc.mjs.map +1 -0
  27. package/dist/{raw--889icsd.mjs → raw-DEtZFeMv.mjs} +4 -21
  28. package/dist/raw-DEtZFeMv.mjs.map +1 -0
  29. package/dist/{raw-BqvlveTU.d.mts → raw-cqTp2vds.d.mts} +2 -1
  30. package/dist/standard-schema-DTuaYJjO.mjs +32 -0
  31. package/dist/standard-schema-DTuaYJjO.mjs.map +1 -0
  32. package/dist/{standard-schema-DLeKaehR.d.mts → standard-schema-DXS-QnwX.d.mts} +3 -2
  33. package/package.json +14 -17
  34. package/dist/color.d.mts +0 -2
  35. package/dist/command.d.mts +0 -5
  36. package/dist/command.mjs +0 -10
  37. package/dist/error-C1S1gs8L.mjs +0 -115
  38. package/dist/error.d.mts +0 -5
  39. package/dist/error.mjs +0 -3
  40. package/dist/input.d.mts +0 -3
  41. package/dist/input.mjs +0 -5
  42. package/dist/standard-schema-DBXbMy6L.mjs +0 -17
  43. package/dist/utils-ChmY93uA.mjs +0 -45
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 trailfrost
3
+ Copyright (c) 2025 sprucepad
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,2 @@
1
+ import { A as greenBright, B as reset, C as createAnsiColor, D as dim, E as defineTheme, F as magenta, G as whiteBright, H as supportsColor, I as magentaBright, K as yellow, L as overline, N as inverse, O as gray, P as italic, R as red, S as bold, T as cyanBright, U as underline, V as strikethrough, W as white, _ as bgYellow, a as bgBlueBright, b as blue, c as bgGray, d as bgMagenta, f as bgMagentaBright, g as bgWhiteBright, h as bgWhite, i as bgBlue, j as hidden, k as green, l as bgGreen, m as bgRedBright, n as Theme, o as bgCyan, p as bgRed, q as yellowBright, r as bgBlack, s as bgCyanBright, t as DEFAULT_THEME, u as bgGreenBright, v as bgYellowBright, w as cyan, x as blueBright, y as black, z as redBright } from "../index-BtbthYjp.mjs";
2
+ export { DEFAULT_THEME, Theme, bgBlack, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blue, blueBright, bold, createAnsiColor, cyan, cyanBright, defineTheme, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, strikethrough, supportsColor, underline, white, whiteBright, yellow, yellowBright };
@@ -1,4 +1,3 @@
1
- import "./utils-ChmY93uA.mjs";
2
- import { A as greenBright, B as strikethrough, C as createAnsiColor, D as dim, E as defineTheme, F as magentaBright, G as yellow, H as underline, I as overline, K as yellowBright, L as red, M as inverse, N as italic, O as gray, P as magenta, R as redBright, T as cyanBright, U as white, V as supportsColor, W as whiteBright, _ as bgYellowBright, a as bgCyan, b as blueBright, c as bgGreen, d as bgMagentaBright, f as bgRed, g as bgYellow, h as bgWhiteBright, i as bgBlueBright, j as hidden, k as green, l as bgGreenBright, m as bgWhite, n as bgBlack, o as bgCyanBright, p as bgRedBright, r as bgBlue, s as bgGray, t as DEFAULT_THEME, u as bgMagenta, v as black, w as cyan, x as bold, y as blue, z as reset } from "./color-OlJQTTxb.mjs";
1
+ import { A as greenBright, B as strikethrough, C as createAnsiColor, D as dim, E as defineTheme, F as magentaBright, G as yellow, H as underline, I as overline, K as yellowBright, L as red, M as inverse, N as italic, O as gray, P as magenta, R as redBright, T as cyanBright, U as white, V as supportsColor, W as whiteBright, _ as bgYellowBright, a as bgCyan, b as blueBright, c as bgGreen, d as bgMagentaBright, f as bgRed, g as bgYellow, h as bgWhiteBright, i as bgBlueBright, j as hidden, k as green, l as bgGreenBright, m as bgWhite, n as bgBlack, o as bgCyanBright, p as bgRedBright, r as bgBlue, s as bgGray, t as DEFAULT_THEME, u as bgMagenta, v as black, w as cyan, x as bold, y as blue, z as reset } from "../color-DiZvJ0Fc.mjs";
3
2
 
4
3
  export { DEFAULT_THEME, bgBlack, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blue, blueBright, bold, createAnsiColor, cyan, cyanBright, defineTheme, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, strikethrough, supportsColor, underline, white, whiteBright, yellow, yellowBright };
@@ -1,7 +1,38 @@
1
1
  import { t as __export } from "./chunk-z5eko27R.mjs";
2
- import { i as merge } from "./utils-ChmY93uA.mjs";
3
2
 
4
- //#region src/color.ts
3
+ //#region src/utils.ts
4
+ /**
5
+ * Checks if a value is a plain object.
6
+ * @param value The value to check.
7
+ * @returns If the value is a plain object.
8
+ */
9
+ function isPlainObject(value) {
10
+ return value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype;
11
+ }
12
+ /**
13
+ * Merges two objects deeply.
14
+ * @param source The source object.
15
+ * @param target The target object.
16
+ * @returns The merged objects.
17
+ */
18
+ function merge(source, target) {
19
+ if (Array.isArray(source) && Array.isArray(target)) return target;
20
+ if (isPlainObject(source) && isPlainObject(target)) {
21
+ const result = {};
22
+ new Set([...Object.keys(source), ...Object.keys(target)]).forEach((key) => {
23
+ const sourceVal = source[key];
24
+ const targetVal = target[key];
25
+ if (sourceVal !== void 0 && targetVal !== void 0) result[key] = merge(sourceVal, targetVal);
26
+ else if (targetVal !== void 0) result[key] = targetVal;
27
+ else result[key] = sourceVal;
28
+ });
29
+ return result;
30
+ }
31
+ return target;
32
+ }
33
+
34
+ //#endregion
35
+ //#region src/color/index.ts
5
36
  var color_exports = /* @__PURE__ */ __export({
6
37
  DEFAULT_THEME: () => DEFAULT_THEME,
7
38
  bgBlack: () => bgBlack,
@@ -70,14 +101,10 @@ function detectColorSupport() {
70
101
  ].some((k) => k in env) || env.CI_NAME === "codeship") return true;
71
102
  return false;
72
103
  }
73
- if (typeof Deno !== "undefined" && Deno.noColor !== void 0) return !Deno.noColor;
74
- if (typeof process !== "undefined" && process.stdout) {
75
- const term = env.TERM || "";
76
- if ((env.COLORTERM || "").length > 0) return true;
77
- if (term === "dumb") return false;
78
- return /(color|ansi|cygwin|xterm|vt100)/i.test(term);
79
- }
80
- return false;
104
+ const term = env.TERM || "";
105
+ if ((env.COLORTERM || "").length > 0) return true;
106
+ if (term === "dumb") return false;
107
+ return /(color|ansi|cygwin|xterm|vt100)/i.test(term);
81
108
  }
82
109
  /**
83
110
  * If the runtime supports color.
@@ -151,6 +178,7 @@ const DEFAULT_THEME = {
151
178
  symbols: {
152
179
  success: "✔",
153
180
  error: "✖",
181
+ fatal: "✖",
154
182
  warning: "⚠"
155
183
  },
156
184
  styles: {
@@ -169,4 +197,5 @@ function defineTheme(theme) {
169
197
  }
170
198
 
171
199
  //#endregion
172
- export { greenBright as A, strikethrough as B, createAnsiColor as C, dim as D, defineTheme as E, magentaBright as F, yellow as G, underline as H, overline as I, yellowBright as K, red as L, inverse as M, italic as N, gray as O, magenta as P, redBright as R, color_exports as S, cyanBright as T, white as U, supportsColor as V, whiteBright as W, bgYellowBright as _, bgCyan as a, blueBright as b, bgGreen as c, bgMagentaBright as d, bgRed as f, bgYellow as g, bgWhiteBright as h, bgBlueBright as i, hidden as j, green as k, bgGreenBright as l, bgWhite as m, bgBlack as n, bgCyanBright as o, bgRedBright as p, bgBlue as r, bgGray as s, DEFAULT_THEME as t, bgMagenta as u, black as v, cyan as w, bold as x, blue as y, reset as z };
200
+ export { greenBright as A, strikethrough as B, createAnsiColor as C, dim as D, defineTheme as E, magentaBright as F, yellow as G, underline as H, overline as I, yellowBright as K, red as L, inverse as M, italic as N, gray as O, magenta as P, redBright as R, color_exports as S, cyanBright as T, white as U, supportsColor as V, whiteBright as W, bgYellowBright as _, bgCyan as a, blueBright as b, bgGreen as c, bgMagentaBright as d, bgRed as f, bgYellow as g, bgWhiteBright as h, bgBlueBright as i, hidden as j, green as k, bgGreenBright as l, bgWhite as m, bgBlack as n, bgCyanBright as o, bgRedBright as p, merge as q, bgBlue as r, bgGray as s, DEFAULT_THEME as t, bgMagenta as u, black as v, cyan as w, bold as x, blue as y, reset as z };
201
+ //# sourceMappingURL=color-DiZvJ0Fc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-DiZvJ0Fc.mjs","names":["result: any","DEFAULT_THEME: Theme"],"sources":["../src/utils.ts","../src/color/index.ts"],"sourcesContent":["/**\n * Deep `Partial<T>`.\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: DeepPartial<T[P]>;\n};\n\n/**\n * All TypeScript primitive types.\n */\ntype Primitive = string | number | boolean | symbol | null | undefined | bigint;\n\n/**\n * A plain TypeScript object.\n */\ntype PlainObject = Record<string | number | symbol, unknown>;\n\n/**\n * Merges two objects deeply.\n */\nexport type DeepMerge<T, U> = U extends Primitive\n ? T\n : T extends Primitive\n ? T\n : U extends readonly (infer TItem)[]\n ? T extends readonly (infer UItem)[]\n ? Array<DeepMerge<TItem, UItem>>\n : T\n : U extends PlainObject\n ? T extends PlainObject\n ? {\n [K in keyof U | keyof T]: K extends keyof T\n ? K extends keyof U\n ? DeepMerge<U[K], T[K]>\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n }\n : T\n : T;\n\n/**\n * Checks if a value is a plain object.\n * @param value The value to check.\n * @returns If the value is a plain object.\n */\nfunction isPlainObject(value: any): value is Record<string, any> {\n return (\n value !== null &&\n typeof value === \"object\" &&\n Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\n/**\n * Merges two objects deeply.\n * @param source The source object.\n * @param target The target object.\n * @returns The merged objects.\n */\nexport function merge<T, U>(source: T, target: U): DeepMerge<T, U> {\n if (Array.isArray(source) && Array.isArray(target)) {\n // Replace arrays\n return target as any;\n }\n\n if (isPlainObject(source) && isPlainObject(target)) {\n const result: any = {};\n const keys = new Set([...Object.keys(source), ...Object.keys(target)]);\n keys.forEach((key) => {\n const sourceVal = (source as any)[key];\n const targetVal = (target as any)[key];\n\n if (sourceVal !== undefined && targetVal !== undefined) {\n result[key] = merge(sourceVal, targetVal);\n } else if (targetVal !== undefined) {\n result[key] = targetVal;\n } else {\n result[key] = sourceVal;\n }\n });\n return result;\n }\n\n // For class instances or primitives, always use target\n return target as any;\n}\n","import { merge, type DeepPartial } from \"@/utils\";\n\n/**\n * Detects if the runtime supports colored output.\n * @returns If the runtime supports colored output.\n */\nfunction detectColorSupport() {\n // If running in a browser-like environment, return false\n if (typeof window !== \"undefined\" && typeof window.document !== \"undefined\") {\n return false;\n }\n\n const env = typeof process !== \"undefined\" ? (process.env ?? {}) : {};\n\n // Force-disable colors if NO_COLOR is set\n if (\"NO_COLOR\" in env) return false;\n\n // Force-enable if FORCE_COLOR is set\n if (\"FORCE_COLOR\" in env) return true;\n\n // Check for CI systems that support color\n if (\"CI\" in env) {\n if (\n [\n \"TRAVIS\",\n \"CIRCLECI\",\n \"APPVEYOR\",\n \"GITLAB_CI\",\n \"GITHUB_ACTIONS\",\n \"BUILDKITE\",\n \"DRONE\",\n ].some((k) => k in env) ||\n env.CI_NAME === \"codeship\"\n ) {\n return true;\n }\n return false;\n }\n\n const term = env.TERM || \"\";\n const colorterm = env.COLORTERM || \"\";\n\n if (colorterm.length > 0) return true;\n if (term === \"dumb\") return false;\n\n return /(color|ansi|cygwin|xterm|vt100)/i.test(term);\n}\n\n/**\n * If the runtime supports color.\n */\nexport const supportsColor = detectColorSupport();\n\n/**\n * Creates a function that wraps a string in ANSI codes.\n * @param open The opening ANSI code.\n * @param close The closing ANSI code.\n * @returns A function that wraps the string in ANSI codes.\n */\nexport function createAnsiColor(\n open: number,\n close: number,\n): (input: any) => string {\n const openCode = `\\u001b[${open}m`;\n const closeCode = `\\u001b[${close}m`;\n\n if (!supportsColor) return (input) => input + \"\";\n\n return (input) => {\n if (!input) return openCode + closeCode;\n\n const str = input + \"\";\n // replace any existing close codes with reopen\n const replaced = str.replace(\n new RegExp(`\\u001b\\\\[${close}m`, \"g\"),\n closeCode + openCode,\n );\n return openCode + replaced + closeCode;\n };\n}\n\nexport const reset = createAnsiColor(0, 0);\nexport const bold = createAnsiColor(1, 22);\nexport const dim = createAnsiColor(2, 22);\nexport const italic = createAnsiColor(3, 23);\nexport const underline = createAnsiColor(4, 24);\nexport const overline = createAnsiColor(53, 55);\nexport const inverse = createAnsiColor(7, 27);\nexport const hidden = createAnsiColor(8, 28);\nexport const strikethrough = createAnsiColor(9, 29);\n\nexport const black = createAnsiColor(30, 39);\nexport const red = createAnsiColor(31, 39);\nexport const green = createAnsiColor(32, 39);\nexport const yellow = createAnsiColor(33, 39);\nexport const blue = createAnsiColor(34, 39);\nexport const magenta = createAnsiColor(35, 39);\nexport const cyan = createAnsiColor(36, 39);\nexport const white = createAnsiColor(37, 39);\nexport const gray = createAnsiColor(90, 39);\n\nexport const bgBlack = createAnsiColor(40, 49);\nexport const bgRed = createAnsiColor(41, 49);\nexport const bgGreen = createAnsiColor(42, 49);\nexport const bgYellow = createAnsiColor(43, 49);\nexport const bgBlue = createAnsiColor(44, 49);\nexport const bgMagenta = createAnsiColor(45, 49);\nexport const bgCyan = createAnsiColor(46, 49);\nexport const bgWhite = createAnsiColor(47, 49);\nexport const bgGray = createAnsiColor(100, 49);\n\nexport const redBright = createAnsiColor(91, 39);\nexport const greenBright = createAnsiColor(92, 39);\nexport const yellowBright = createAnsiColor(93, 39);\nexport const blueBright = createAnsiColor(94, 39);\nexport const magentaBright = createAnsiColor(95, 39);\nexport const cyanBright = createAnsiColor(96, 39);\nexport const whiteBright = createAnsiColor(97, 39);\n\nexport const bgRedBright = createAnsiColor(101, 49);\nexport const bgGreenBright = createAnsiColor(102, 49);\nexport const bgYellowBright = createAnsiColor(103, 49);\nexport const bgBlueBright = createAnsiColor(104, 49);\nexport const bgMagentaBright = createAnsiColor(105, 49);\nexport const bgCyanBright = createAnsiColor(106, 49);\nexport const bgWhiteBright = createAnsiColor(107, 49);\n\n/**\n * A theme.\n */\nexport interface Theme {\n /**\n * Wraps a string in a background ANSI code.\n * @param a The string to wrap.\n */\n background?(a: string): string;\n /**\n * Wraps a string in a foreground ANSI code.\n * @param a The string to wrap.\n */\n foreground?(a: string): string;\n /**\n * Wraps a string in a primary ANSI code.\n * @param a The string to wrap.\n */\n primary(a: string): string;\n /**\n * Wraps a string in a secondary ANSI code.\n * @param a The string to wrap.\n */\n secondary(a: string): string;\n /**\n * Wraps a string in a accent ANSI code.\n * @param a The string to wrap.\n */\n accent?(a: string): string;\n\n /**\n * Wraps a string in a success ANSI code.\n * @param a The string to wrap.\n */\n success(a: string): string;\n /**\n * Wraps a string in a warning ANSI code.\n * @param a The string to wrap.\n */\n warning(a: string): string;\n /**\n * Wraps a string in a error ANSI code.\n * @param a The string to wrap.\n */\n error(a: string): string;\n /**\n * Wraps a string in a info ANSI code.\n * @param a The string to wrap.\n */\n info?(a: string): string;\n\n /**\n * Set of symbols for logging.\n */\n symbols?: {\n /**\n * Success message symbol.\n */\n success: string;\n /**\n * Error message symbol.\n */\n error: string;\n /**\n * Fatal error message symbol.\n */\n fatal: string;\n /**\n * Warning message symbol.\n */\n warning: string;\n /**\n * Information message symbol.\n */\n info?: string;\n };\n\n /**\n * Optional styles.\n */\n styles?: {\n /**\n * Wraps a string in a bold ANSI code.\n * @param a The string to wrap.\n */\n bold?(a: string): string;\n /**\n * Wraps a string in an italic ANSI code.\n * @param a The string to wrap.\n */\n italic?(a: string): string;\n /**\n * Wraps a string in an underline ANSI code.\n * @param a The string to wrap.\n */\n underline?(a: string): string;\n };\n}\n\n/**\n * The default theme.\n */\nexport const DEFAULT_THEME: Theme = {\n primary: cyan,\n secondary: gray,\n\n success: green,\n warning: yellow,\n error: red,\n\n symbols: {\n success: \"✔\",\n error: \"✖\",\n fatal: \"✖\",\n warning: \"⚠\",\n },\n\n styles: {\n bold: bold,\n italic: italic,\n underline: underline,\n },\n};\n\n/**\n * Defines a theme.\n * @param theme The (partial) theme.\n * @returns The theme, merged with the default theme.\n */\nexport function defineTheme(theme: DeepPartial<Theme>): Theme {\n return merge(DEFAULT_THEME, theme);\n}\n"],"mappings":";;;;;;;;AA+CA,SAAS,cAAc,OAA0C;AAC/D,QACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,eAAe,MAAM,KAAK,OAAO;;;;;;;;AAU5C,SAAgB,M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E9C,MAAa,YAAY,gBAAgB,IAAI,GAAG;AAChD,MAAa,cAAc,gBAAgB,IAAI,GAAG;AAClD,MAAa,eAAe,gBAAgB,IAAI,GAAG;AACnD,MAAa,aAAa,gBAAgB,IAAI,GAAG;AACjD,MAAa,gBAAgB,gBAAgB,IAAI,GAAG;AACpD,MAAa,aAAa,gBAAgB,IAAI,GAAG;AACjD,MAAa,cAAc,gBAAgB,IAAI,GAAG;AAElD,MAAa,cAAc,gBAAgB,KAAK,GAAG;AACnD,MAAa,gBAAgB,gBAAgB,KAAK,GAAG;AACrD,MAAa,iBAAiB,gBAAgB,KAAK,GAAG;AACtD,MAAa,eAAe,gBAAgB,KAAK,GAAG;AACpD,MAAa,kBAAkB,gBAAgB,KAAK,GAAG;AACvD,MAAa,eAAe,gBAAgB,KAAK,GAAG;AACpD,MAAa,gBAAgB,gBAAgB,KAAK,GAAG;;;;AAwGrD,MAAaC,gBAAuB;CAClC,SAAS;CACT,WAAW;CAEX,SAAS;CACT,SAAS;CACT,OAAO;CAEP,SAAS;EACP,SAAS;EACT,OAAO;EACP,OAAO;EACP,SAAS;EACV;CAED,QAAQ;EACA;EACE;EACG;EACZ;CACF;;;;;;AAOD,SAAgB,YAAY,OAAkC;AAC5D,QAAO,MAAM,eAAe,MAAM"}
@@ -0,0 +1,5 @@
1
+ import "../index-BtbthYjp.mjs";
2
+ import "../standard-schema-DXS-QnwX.mjs";
3
+ import "../index-ClhbwSD8.mjs";
4
+ import { a as ErrorFn, c as ConvokerError, d as MissingRequiredOptionError, f as TooManyArgumentsError, i as CommandAlias, l as HelpAskedError, n as Builder, o as MiddlewareFn, p as UnknownOptionError, r as Command, s as ParseResult, t as ActionFn, u as MissingRequiredArgumentError } from "../index-Cnx4H4D-.mjs";
5
+ export { ActionFn, Builder, Command, CommandAlias, ConvokerError, ErrorFn, HelpAskedError, MiddlewareFn, MissingRequiredArgumentError, MissingRequiredOptionError, ParseResult, TooManyArgumentsError, UnknownOptionError };
@@ -0,0 +1,8 @@
1
+ import "../color-DiZvJ0Fc.mjs";
2
+ import "../standard-schema-DTuaYJjO.mjs";
3
+ import "../raw-DEtZFeMv.mjs";
4
+ import "../prompt-a5Ix_Hyc.mjs";
5
+ import { a as MissingRequiredOptionError, i as MissingRequiredArgumentError, n as ConvokerError, o as TooManyArgumentsError, r as HelpAskedError, s as UnknownOptionError, t as Command } from "../command-8P8qXJ2o.mjs";
6
+ import "../input-XUsy1LCQ.mjs";
7
+
8
+ export { Command, ConvokerError, HelpAskedError, MissingRequiredArgumentError, MissingRequiredOptionError, TooManyArgumentsError, UnknownOptionError };
@@ -1,195 +1,99 @@
1
- import { t as __export } from "./chunk-z5eko27R.mjs";
2
- import { i as merge, n as isDeno, r as isNode, t as isBun } from "./utils-ChmY93uA.mjs";
3
- import { O as gray, t as DEFAULT_THEME, w as cyan, x as bold } from "./color-OlJQTTxb.mjs";
4
- import { a as MissingRequiredOptionError, i as MissingRequiredArgumentError, n as HelpAskedError, o as TooManyArgumentsError, s as UnknownOptionError, t as ConvokerError } from "./error-C1S1gs8L.mjs";
5
- import { c as setTheme } from "./prompt-Cvufljin.mjs";
6
- import { i as convert, n as Positional, t as Option } from "./input-DRy_sVxZ.mjs";
1
+ import { O as gray, w as cyan, x as bold } from "./color-DiZvJ0Fc.mjs";
2
+ import { c as setTheme } from "./prompt-a5Ix_Hyc.mjs";
3
+ import { i as convert, n as Positional, t as Option } from "./input-XUsy1LCQ.mjs";
4
+ import process from "node:process";
7
5
 
8
- //#region src/log.ts
9
- var log_exports = /* @__PURE__ */ __export({
10
- error: () => error,
11
- fatal: () => fatal,
12
- info: () => info,
13
- setConfig: () => setConfig,
14
- setTheme: () => setTheme$1,
15
- setup: () => setup,
16
- trace: () => trace,
17
- warn: () => warn
18
- });
6
+ //#region src/command/error.ts
19
7
  /**
20
- * Gets the default stdout, in a cross-runtime way.
21
- * @returns The default stdout.
8
+ * A Convoker-related error. These are usually handled by default.
22
9
  */
23
- async function getDefaultStdout() {
24
- if (isNode && process.stdout?.writable) {
25
- const { Writable } = await import("node:stream");
26
- return Writable.toWeb(process.stdout);
10
+ var ConvokerError = class extends Error {
11
+ /**
12
+ * Creates a new Convoker error.
13
+ * @param message The message.
14
+ * @param command The command.
15
+ */
16
+ constructor(message, command) {
17
+ super(message);
18
+ this.command = command;
27
19
  }
28
- if (isDeno && Deno.stdout?.writable) return Deno.stdout.writable;
29
- if (isBun && Bun.stdout) return Bun.stdout;
30
- return new WritableStream({ write(chunk) {
31
- console.log(String(chunk));
32
- } });
33
- }
34
- /**
35
- * Gets the default stderr, in a cross-runtime way.
36
- * @returns The default stderr.
37
- */
38
- async function getDefaultStderr() {
39
- if (isNode && process.stderr?.writable) {
40
- const { Writable } = await import("node:stream");
41
- return Writable.toWeb(process.stderr);
20
+ /**
21
+ * Prints the error's message.
22
+ */
23
+ print() {
24
+ console.error(this.message);
42
25
  }
43
- if (isDeno && Deno.stderr?.writable) return Deno.stderr.writable;
44
- if (isBun && Bun.stderr) return Bun.stderr;
45
- return new WritableStream({ write(chunk) {
46
- console.error(String(chunk));
47
- } });
48
- }
26
+ };
49
27
  /**
50
- * Gets the default stdin, in a cross-runtime way.
51
- * @returns The default stdin.
28
+ * When the user asks for help.
52
29
  */
53
- async function getDefaultStdin() {
54
- if (isNode && process.stdin?.readable) {
55
- const { Readable } = await import("node:stream");
56
- return Readable.toWeb(process.stdin);
30
+ var HelpAskedError = class extends ConvokerError {
31
+ /**
32
+ * Creates a new help asked error.
33
+ * @param command The command.
34
+ */
35
+ constructor(command) {
36
+ super("user asked for help!", command);
57
37
  }
58
- if (isDeno && Deno.stdin?.readable) return Deno.stdin.readable;
59
- if (isBun) return Bun.stdin.stream();
60
- return new ReadableStream({ start(controller) {
61
- controller.close();
62
- } });
63
- }
64
- let theme = DEFAULT_THEME;
65
- let config = void 0;
66
- /**
67
- * Sets a new theme.
68
- * @param t The theme.
69
- */
70
- function setTheme$1(t) {
71
- theme = t;
72
- }
73
- /**
74
- * Sets new configuration.
75
- * @param c The config.
76
- */
77
- async function setConfig(c) {
78
- config = merge({
79
- format: "text",
80
- stdout: await getDefaultStdout(),
81
- stderr: await getDefaultStderr(),
82
- stdin: await getDefaultStdin()
83
- }, c);
84
- }
85
- /**
86
- * Sets default configuration.
87
- */
88
- async function setup() {
89
- await setConfig({});
90
- }
38
+ };
91
39
  /**
92
- * Formats a message to the correct format.
93
- * @param level The level of mesage.
94
- * @param msgs The messages to format.
95
- * @returns The formatted message.
40
+ * When you pass too many arguments.
96
41
  */
97
- function formatMessages(level, ...msgs) {
98
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
99
- const msg = msgs.map((m) => typeof m === "string" ? m : JSON.stringify(m, null, 2)).join(" ");
100
- switch (config.format) {
101
- case "json": return JSON.stringify({
102
- timestamp,
103
- level,
104
- message: msg
105
- }) + "\n";
106
- case "xml": return `<log>
107
- <timestamp>${timestamp}</timestamp>
108
- <level>${level}</level>
109
- <message>${msg}</message>
110
- </log>\n`;
111
- case "yaml": return `- timestamp: ${timestamp}
112
- level: ${level}
113
- message: "${msg.replace(/"/g, "\\\"")}"\n`;
114
- case "csv": return `"${timestamp}","${level}","${msg.replace(/"/g, "\"\"")}"\n`;
115
- case "text":
116
- default: return `[${timestamp}] [${level.toUpperCase()}] ${msg}\n`;
42
+ var TooManyArgumentsError = class extends ConvokerError {
43
+ /**
44
+ * Creates a new too many arguments error.
45
+ * @param command The command.
46
+ */
47
+ constructor(command) {
48
+ super("too many arguments!", command);
117
49
  }
118
- }
50
+ };
119
51
  /**
120
- * Colorizes text.
121
- * @param level The log level.
122
- * @param text The text to colorize.
123
- * @returns The colorized text.
52
+ * When you pass an unknown option, when unknown options aren't allowed.
124
53
  */
125
- function colorize(level, text) {
126
- switch (level) {
127
- case "trace": return theme.secondary ? theme.secondary(text) : text;
128
- case "info": return theme.info ? theme.info(text) : text;
129
- case "warn": return theme.warning ? theme.warning(text) : text;
130
- case "error": return theme.error ? theme.error(text) : text;
131
- case "fatal": return theme.error ? theme.error(theme.styles?.bold?.(text) ?? text) : text;
132
- default: return text;
54
+ var UnknownOptionError = class extends ConvokerError {
55
+ /**
56
+ * Creates a new unknown option error.
57
+ * @param command The command.
58
+ * @param key The key.
59
+ */
60
+ constructor(command, key) {
61
+ super(`unknown option: ${key}!`, command);
62
+ this.key = key;
133
63
  }
134
- }
64
+ };
135
65
  /**
136
- * Writes to a stream.
137
- * @param stream The stream to write to.
138
- * @param msg The message to write.
66
+ * When a required option is missing.
139
67
  */
140
- async function writeToStream(stream, msg) {
141
- const writer = stream.getWriter();
142
- try {
143
- await writer.write(msg);
144
- } finally {
145
- writer.releaseLock();
68
+ var MissingRequiredOptionError = class extends ConvokerError {
69
+ /**
70
+ * Creates a new missing required option error.
71
+ * @param command The command.
72
+ * @param key The key.
73
+ * @param entry The entry.
74
+ */
75
+ constructor(command, key, entry) {
76
+ super(`missing required option: ${key}!`, command);
77
+ this.key = key;
78
+ this.entry = entry;
146
79
  }
147
- }
148
- /**
149
- * Prints debug information.
150
- * @param msgs The messages to write.
151
- */
152
- async function trace(...msgs) {
153
- const colored = colorize("trace", formatMessages("trace", ...msgs));
154
- await writeToStream(config.stdout, colored);
155
- }
156
- /**
157
- * Prints information.
158
- * @param msgs The messages to write.
159
- */
160
- async function info(...msgs) {
161
- const colored = colorize("info", formatMessages("info", ...msgs));
162
- await writeToStream(config.stdout, colored);
163
- }
164
- /**
165
- * Prints warnings.
166
- * @param msgs The messages to write.
167
- */
168
- async function warn(...msgs) {
169
- const colored = colorize("warn", formatMessages("warn", ...msgs));
170
- await writeToStream(config.stdout, colored);
171
- }
172
- /**
173
- * Prints errors.
174
- * @param msgs The messages to write.
175
- */
176
- async function error(...msgs) {
177
- const colored = colorize("error", formatMessages("error", ...msgs));
178
- await writeToStream(config.stderr, colored);
179
- }
180
- /**
181
- * Prints errors and exits.
182
- * @param msgs The messages to write.
183
- */
184
- async function fatal(...msgs) {
185
- const colored = colorize("fatal", formatMessages("fatal", ...msgs));
186
- await writeToStream(config.stderr, colored);
187
- if (isDeno) Deno.exit(-1);
188
- else if (isNode || isBun) process.exit(-1);
189
- }
80
+ };
81
+ var MissingRequiredArgumentError = class extends ConvokerError {
82
+ /**
83
+ * Creates a new missing required argument error.
84
+ * @param command The command.
85
+ * @param key The key.
86
+ * @param entry The entry.
87
+ */
88
+ constructor(command, key, entry) {
89
+ super(`missing required positional argument: ${key}!`, command);
90
+ this.key = key;
91
+ this.entry = entry;
92
+ }
93
+ };
190
94
 
191
95
  //#endregion
192
- //#region src/command.ts
96
+ //#region src/command/index.ts
193
97
  /**
194
98
  * A command.
195
99
  */
@@ -218,7 +122,7 @@ var Command = class Command {
218
122
  * @returns this
219
123
  */
220
124
  alias(...aliases) {
221
- this.$names.concat(aliases);
125
+ this.$names.push(...aliases);
222
126
  this.$parent?.add(this);
223
127
  return this;
224
128
  }
@@ -277,19 +181,21 @@ var Command = class Command {
277
181
  return this;
278
182
  }
279
183
  /**
280
- * Adds an existing command to this.
281
- * @param command The command.
184
+ * Adds existing commands to this.
185
+ * @param commands The commands.
282
186
  * @returns this
283
187
  */
284
- add(command) {
285
- command.$parent = this;
286
- const alias = {
287
- command,
288
- alias: command.$names[0]
289
- };
290
- for (let i = 0; i < command.$names.length; i++) {
291
- if (i === 0) this.$children.set(command.$names[i], { command });
292
- this.$children.set(command.$names[i], alias);
188
+ add(...commands) {
189
+ for (const command of commands) {
190
+ command.$parent = this;
191
+ const alias = {
192
+ command,
193
+ alias: command.$names[0]
194
+ };
195
+ for (let i = 0; i < command.$names.length; i++) {
196
+ if (i === 0) this.$children.set(command.$names[i], { command });
197
+ this.$children.set(command.$names[i], alias);
198
+ }
293
199
  }
294
200
  return this;
295
201
  }
@@ -375,10 +281,7 @@ var Command = class Command {
375
281
  }
376
282
  } else if (command.$children.has(arg) && !found) {
377
283
  command = command.$children.get(arg).command;
378
- if (command.$theme) {
379
- setTheme(command.$theme);
380
- setTheme$1(command.$theme);
381
- }
284
+ if (command.$theme) setTheme(command.$theme);
382
285
  } else {
383
286
  found = true;
384
287
  args.push(arg);
@@ -461,10 +364,10 @@ var Command = class Command {
461
364
  defaultErrorScreen(errors) {
462
365
  let printHelpScreen = false;
463
366
  const nonCliErrors = [];
464
- for (const error$1 of errors) if (error$1 instanceof ConvokerError) {
465
- if (!(error$1 instanceof HelpAskedError)) error$1.print();
367
+ for (const error of errors) if (error instanceof ConvokerError) {
368
+ if (!(error instanceof HelpAskedError)) error.print();
466
369
  printHelpScreen = true;
467
- } else nonCliErrors.push(error$1);
370
+ } else nonCliErrors.push(error);
468
371
  if (nonCliErrors.length) throw nonCliErrors[0];
469
372
  if (!printHelpScreen) return;
470
373
  const pad = (s, len) => s.padEnd(len, " ");
@@ -526,8 +429,7 @@ var Command = class Command {
526
429
  * @returns this
527
430
  */
528
431
  async run(argv) {
529
- if (!argv) argv = typeof Bun !== "undefined" ? Bun.argv.slice(2) : typeof Deno !== "undefined" ? Deno.args : process.argv.slice(2);
530
- const result = await this.parse(argv);
432
+ const result = await this.parse(argv ?? process.argv.slice(2));
531
433
  if (result.isHelp) {
532
434
  result.command.handleErrors([new HelpAskedError(result.command)]);
533
435
  return this;
@@ -580,4 +482,5 @@ function compose(mws) {
580
482
  }
581
483
 
582
484
  //#endregion
583
- export { log_exports as n, Command as t };
485
+ export { MissingRequiredOptionError as a, MissingRequiredArgumentError as i, ConvokerError as n, TooManyArgumentsError as o, HelpAskedError as r, UnknownOptionError as s, Command as t };
486
+ //# sourceMappingURL=command-8P8qXJ2o.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-8P8qXJ2o.mjs","names":["command","command: Command<any>","input: Record<string, unknown>","args: string[]","opts: Record<string, string>","errors: ConvokerError[]","usedValue: string | undefined","rawValue: string | string[] | undefined","names: string[]","cmd: Command<any> | undefined","nonCliErrors: Error[]","middlewares: MiddlewareFn<any>[]","current: Command<any> | undefined"],"sources":["../src/command/error.ts","../src/command/index.ts"],"sourcesContent":["import { Positional, Option } from \"@/input\";\nimport { Command } from \".\";\n\n/**\n * A Convoker-related error. These are usually handled by default.\n */\nexport class ConvokerError extends Error {\n /**\n * The command this error happened on.\n */\n command: Command<any>;\n\n /**\n * Creates a new Convoker error.\n * @param message The message.\n * @param command The command.\n */\n constructor(message: string, command: Command<any>) {\n super(message);\n this.command = command;\n }\n\n /**\n * Prints the error's message.\n */\n print() {\n console.error(this.message);\n }\n}\n\n/**\n * When the user asks for help.\n */\nexport class HelpAskedError extends ConvokerError {\n /**\n * Creates a new help asked error.\n * @param command The command.\n */\n constructor(command: Command<any>) {\n super(\"user asked for help!\", command);\n }\n}\n\n/**\n * When you pass too many arguments.\n */\nexport class TooManyArgumentsError extends ConvokerError {\n /**\n * Creates a new too many arguments error.\n * @param command The command.\n */\n constructor(command: Command<any>) {\n super(\"too many arguments!\", command);\n }\n}\n\n/**\n * When you pass an unknown option, when unknown options aren't allowed.\n */\nexport class UnknownOptionError extends ConvokerError {\n /**\n * The option key.\n */\n key: string;\n\n /**\n * Creates a new unknown option error.\n * @param command The command.\n * @param key The key.\n */\n constructor(command: Command<any>, key: string) {\n super(`unknown option: ${key}!`, command);\n this.key = key;\n }\n}\n\n/**\n * When a required option is missing.\n */\nexport class MissingRequiredOptionError extends ConvokerError {\n /**\n * The option key.\n */\n key: string;\n /**\n * The option entry.\n */\n entry: Option<any, any, any>;\n\n /**\n * Creates a new missing required option error.\n * @param command The command.\n * @param key The key.\n * @param entry The entry.\n */\n constructor(\n command: Command<any>,\n key: string,\n entry: Option<any, any, any>,\n ) {\n super(`missing required option: ${key}!`, command);\n this.key = key;\n this.entry = entry;\n }\n}\n\nexport class MissingRequiredArgumentError extends ConvokerError {\n /**\n * The argument key.\n */\n key: string;\n /**\n * The argument entry.\n */\n entry: Positional<any, any, any>;\n\n /**\n * Creates a new missing required argument error.\n * @param command The command.\n * @param key The key.\n * @param entry The entry.\n */\n constructor(\n command: Command<any>,\n key: string,\n entry: Positional<any, any, any>,\n ) {\n super(`missing required positional argument: ${key}!`, command);\n this.key = key;\n this.entry = entry;\n }\n}\n","import process from \"node:process\";\n\nimport { gray, cyan, bold, type Theme } from \"@/color\";\nimport { setTheme as setPromptTheme } from \"@/prompt\";\nimport {\n ConvokerError,\n HelpAskedError,\n MissingRequiredArgumentError,\n MissingRequiredOptionError,\n TooManyArgumentsError,\n UnknownOptionError,\n} from \"./error\";\nimport {\n convert,\n Option,\n Positional,\n type InferInput,\n type Input,\n} from \"@/input\";\n\n/**\n * What the command is an alias for.\n */\nexport interface CommandAlias<T extends Input = Input> {\n /**\n * A pointer to the command.\n */\n command: Command<T>;\n /**\n * The name of the command this is an alias for.\n */\n alias?: string;\n}\n\n/**\n * The result of the `Command.parse` function.\n */\nexport interface ParseResult<T extends Input> {\n /**\n * A pointer to the command to run.\n */\n command: Command<T>;\n /**\n * The input to pass into the command.\n */\n input: InferInput<T>;\n /**\n * Errors collected during parsing.\n */\n errors: ConvokerError[];\n /**\n * If this should result in displaying the version of the command.\n */\n isVersion: boolean;\n /**\n * If this should result in displaying a help screen.\n */\n isHelp: boolean;\n}\n\n/**\n * Command action function.\n */\nexport type ActionFn<T extends Input> = (\n input: InferInput<T>,\n) => any | Promise<any>;\n\n/**\n * Command middleware function.\n */\nexport type MiddlewareFn<T extends Input = Input> = (\n input: InferInput<T>,\n next: () => Promise<any>,\n) => any | Promise<any>;\n\n/**\n * Command error handler.\n */\nexport type ErrorFn<T extends Input> = (\n command: Command<T>,\n errors: Error[],\n input: Partial<InferInput<T>>,\n) => void | Promise<void>;\n\n/**\n * Builder for commands.\n */\nexport type Builder = (c: Command<any>) => Command<any> | void;\n\n/**\n * An input map entry.\n */\ninterface MapEntry {\n /**\n * The key of the map entry.\n */\n key: string;\n /**\n * The value of the map entry.\n */\n value: Option<any, any, any> | Positional<any, any, any>;\n}\n\n/**\n * A command.\n */\nexport class Command<T extends Input = Input> {\n /**\n * The names (aliases) of this command.\n */\n $names: string[];\n /**\n * The description of this command.\n */\n $description: string | undefined;\n /**\n * The theme of this command\n */\n $theme: Theme | undefined;\n /**\n * The version of this command.\n */\n $version: string | undefined;\n /**\n * The children of this command.\n */\n $children: Map<string, CommandAlias> = new Map();\n /**\n * The parent of this command.\n */\n $parent: Command<any> | undefined;\n /**\n * If this command allows unknown options.\n */\n $allowUnknownOptions: boolean = false;\n /**\n * If you should be able to surpass the amount of positional arguments defined in the input.\n */\n $allowSurpassArgLimit: boolean = false;\n /**\n * The input this command takes.\n */\n $input: T = {} as T;\n /**\n * The action function of this command.\n */\n $fn: ActionFn<T> | undefined = undefined;\n /**\n * The middlewares associated with this command.\n */\n $middlewares: MiddlewareFn<T>[] = [];\n /**\n * The error handler of this command.\n */\n $errorFn: ErrorFn<T> | undefined = undefined;\n\n /**\n * Creates a new command.\n * @param names The names (aliases).\n * @param desc The description.\n * @param version The version.\n */\n constructor(names: string | string[], desc?: string, version?: string) {\n this.$names = Array.isArray(names) ? names : [names];\n this.$description = desc;\n this.$version = version;\n }\n\n /**\n * Adds a set of aliases to this command.\n * @param aliases The aliases to add.\n * @returns this\n */\n alias(...aliases: string[]): this {\n this.$names.push(...aliases);\n this.$parent?.add(this);\n return this;\n }\n\n /**\n * Adds a description to this command.\n * @param desc The description.\n * @returns this\n */\n description(desc: string): this {\n this.$description = desc;\n return this;\n }\n\n /**\n * Adds a version to this command.\n * @param version The version.\n * @returns this\n */\n version(version: string): this {\n this.$version = version;\n return this;\n }\n\n /**\n * Sets the input for this command.\n * @param version The input.\n * @returns this\n */\n input<TInput extends Input>(input: TInput): Command<TInput> {\n this.$input = input as any;\n return this as any;\n }\n\n /**\n * Adds a chain of middlewares.\n * @param fns The middlewares to use.\n * @returns this\n */\n use(...fns: MiddlewareFn<T>[]): this {\n this.$middlewares.push(...fns);\n return this;\n }\n\n /**\n * Sets the action function for this command.\n * @param fn The action.\n * @returns this\n */\n action(fn: ActionFn<T>): this {\n this.$fn = fn;\n return this;\n }\n\n /**\n * Sets the error function for this command.\n * @param fn The error handler.\n * @returns this\n */\n error(fn: ErrorFn<T>): this {\n this.$errorFn = fn;\n return this;\n }\n\n /**\n * Adds existing commands to this.\n * @param commands The commands.\n * @returns this\n */\n add(...commands: Command<any>[]): this {\n for (const command of commands) {\n command.$parent = this;\n const alias = { command, alias: command.$names[0] };\n for (let i = 0; i < command.$names.length; i++) {\n if (i === 0) this.$children.set(command.$names[i], { command });\n this.$children.set(command.$names[i], alias);\n }\n }\n return this;\n }\n\n /**\n * Creates a new subcommand and adds it.\n * @param names The aliases of the subcommand.\n * @param builder A builder to create the command.\n */\n subCommand(names: string | string[], builder: Builder): this;\n /**\n * Creates a new subcommand and adds it.\n * @param names The aliases of the subcommand.\n * @param desc The description of the subcommand.\n * @param version The version of the subcommand.\n */\n subCommand(\n names: string | string[],\n desc?: string,\n version?: string,\n ): Command<any>;\n\n subCommand(\n names: string | string[],\n descOrBuilder?: Builder | string,\n version?: string,\n ): Command<any> {\n if (typeof descOrBuilder === \"function\") {\n const command = new Command(names);\n descOrBuilder(command);\n this.add(command);\n return this;\n }\n\n const command = new Command(names, descOrBuilder, version);\n this.add(command);\n return command;\n }\n\n /**\n * Allows unknown options.\n * @returns this\n */\n allowUnknownOptions(): this {\n this.$allowUnknownOptions = true;\n return this;\n }\n\n /**\n * Parses a set of command-line arguments.\n * @param argv The arguments to parse.\n * @returns A parse result.\n */\n async parse(argv: string[]): Promise<ParseResult<T>> {\n // eslint-disable-next-line -- alias to this is necessary to go through the tree\n let command: Command<any> = this;\n let found = false;\n const input: Record<string, unknown> = {};\n\n const args: string[] = [];\n const opts: Record<string, string> = {};\n\n const errors: ConvokerError[] = [];\n const map = command.buildInputMap();\n\n function getOption(key: string, isSpecial?: boolean) {\n const entry = map.get(key);\n if (!entry) {\n if (!command.$allowUnknownOptions && !isSpecial)\n errors.push(new UnknownOptionError(command, key));\n return null;\n }\n return entry.value as Option<any, any, any>;\n }\n\n function setOption(\n key: string,\n option: Option<any, any, any>,\n value?: string,\n ) {\n if (option.$kind === \"boolean\") {\n opts[key] = \"true\";\n } else if (value !== undefined) {\n opts[key] = value;\n }\n }\n\n let isVersion = false;\n let isHelp = false;\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg.startsWith(\"--\")) {\n // --long[=value] or --long [value]\n const [key, value] = arg.slice(2).split(\"=\");\n\n let isSpecial = false;\n if (key === \"help\") {\n isHelp = true;\n isSpecial = true;\n } else if (key === \"version\") {\n isVersion = true;\n isSpecial = true;\n }\n\n const option = getOption(key, isSpecial);\n if (option) {\n if (value === undefined)\n setOption(\n key,\n option,\n option.$kind === \"boolean\" ? undefined : argv[++i],\n );\n else setOption(key, option, value);\n }\n } else if (arg.startsWith(\"-\")) {\n // -abc or -k[=value] or -k [value]\n const [shortKeys, value] = arg.slice(1).split(\"=\");\n const chars = shortKeys.split(\"\");\n let usedValue: string | undefined = value;\n\n for (const char of chars) {\n let isSpecial = false;\n if (char === \"h\") {\n isHelp = true;\n isSpecial = true;\n } else if (char === \"V\") {\n isVersion = true;\n isSpecial = true;\n }\n\n const option = getOption(char, isSpecial);\n if (!option) continue;\n\n if (option.$kind !== \"boolean\" && usedValue === undefined) {\n usedValue = argv[++i];\n }\n setOption(char, option, usedValue);\n usedValue = undefined; // only first consumes\n }\n } else {\n // positional\n if (command.$children.has(arg) && !found) {\n command = command.$children.get(arg)!.command;\n if (command.$theme) {\n setPromptTheme(command.$theme);\n }\n } else {\n found = true;\n args.push(arg);\n }\n }\n }\n\n // Apply user values, defaults, or enforce required\n let index = 0;\n for (const key in command.$input) {\n const entry = command.$input[key];\n let rawValue: string | string[] | undefined;\n\n if (entry instanceof Positional) {\n if (entry.$list) {\n rawValue = args.slice(index);\n index = args.length;\n if (\n !command.$allowSurpassArgLimit &&\n rawValue.length === 0 &&\n entry.$required\n ) {\n errors.push(new MissingRequiredArgumentError(command, key, entry));\n }\n } else {\n rawValue = args[index++];\n if (rawValue === undefined && entry.$required) {\n errors.push(new MissingRequiredArgumentError(command, key, entry));\n }\n }\n } else {\n for (const name of entry.$names) {\n if (opts[name] !== undefined) {\n rawValue = entry.$list\n ? opts[name].split(entry.$separator ?? \",\")\n : opts[name];\n break;\n }\n }\n }\n\n if (rawValue !== undefined) {\n input[key] = await convert(entry.$kind, rawValue);\n } else if (entry.$default !== undefined) {\n input[key] = entry.$default;\n } else if (entry.$required) {\n if (entry instanceof Option) {\n errors.push(new MissingRequiredOptionError(command, key, entry));\n } else {\n errors.push(new MissingRequiredArgumentError(command, key, entry));\n }\n }\n }\n\n // Check for too many arguments\n const remainingArgs = args.slice(index);\n if (!command.$allowSurpassArgLimit && remainingArgs.length > 0) {\n errors.push(new TooManyArgumentsError(command));\n }\n\n return {\n input: input as InferInput<T>,\n command,\n errors,\n isVersion,\n isHelp,\n };\n }\n\n private buildInputMap(\n ignoreParentMap?: boolean,\n ): Map<string | number, MapEntry> {\n const map = new Map<string | number, MapEntry>();\n\n let i = 0;\n for (const key in this.$input) {\n const value = this.$input[key];\n if (value instanceof Positional) {\n map.set(i++, { value, key });\n } else {\n for (const name of value.$names) {\n map.set(name, { value, key });\n }\n }\n }\n\n if (!ignoreParentMap) {\n for (const [key, entry] of this.$parent?.buildInputMap() ?? []) {\n map.set(key, entry);\n }\n }\n\n for (const [, { command }] of this.$children) {\n for (const [key, entry] of command.buildInputMap(true)) {\n map.set(key, entry);\n }\n }\n\n return map;\n }\n\n /**\n * Allows surpassing the amount of arguments specified.\n * @returns this\n */\n allowSurpassArgLimit(): this {\n this.$allowSurpassArgLimit = true;\n return this;\n }\n\n /**\n * Gets the full command path (name including parents).\n * @returns The full command path.\n */\n fullCommandPath(): string {\n const names: string[] = [];\n // eslint-disable-next-line -- necessary for traversing up the tree\n let cmd: Command<any> | undefined = this;\n while (cmd) {\n names.unshift(cmd.$names[0]);\n cmd = cmd.$parent;\n }\n return names.join(\" \");\n }\n\n /**\n * The default error screen.\n * @param errors The errors.\n */\n defaultErrorScreen(errors: Error[]) {\n let printHelpScreen = false;\n const nonCliErrors: Error[] = [];\n\n for (const error of errors) {\n if (error instanceof ConvokerError) {\n if (!(error instanceof HelpAskedError)) error.print();\n printHelpScreen = true;\n } else {\n nonCliErrors.push(error);\n }\n }\n\n if (nonCliErrors.length) throw nonCliErrors[0];\n\n if (!printHelpScreen) return;\n const pad = (s: string, len: number) => s.padEnd(len, \" \");\n\n console.log(\n `${bold(\"usage:\")} ${cyan(this.fullCommandPath())} ${gray(\"[options] [arguments]\")}`,\n );\n if (this.$description) {\n console.log(`${this.$description}`);\n }\n\n if (this.$version) {\n console.log(`${bold(\"version\")} ${this.$version}`);\n }\n\n // OPTIONS\n const opts = Object.entries(this.$input)\n .filter(([, entry]) => entry instanceof Option)\n .map(([key, entry]) => ({ key, entry: entry as Option<any, any, any> }));\n\n if (opts.length > 0) {\n console.log(bold(\"options:\"));\n const longest = Math.max(\n ...opts.map(({ entry }) => entry.$names.join(\", \").length),\n );\n for (const { entry } of opts) {\n const names = entry.$names\n .map((n) => (n.length === 1 ? `-${n}` : `--${n}`))\n .join(\", \");\n const line = ` ${cyan(pad(names, longest + 4))}${gray(entry.$description ?? \"\")}`;\n console.log(line);\n }\n }\n\n // POSITIONALS\n const positionals = Object.entries(this.$input)\n .filter(([, entry]) => entry instanceof Positional)\n .map(([key, entry]) => ({\n key,\n entry: entry as Positional<any, any, any>,\n }));\n\n if (positionals.length > 0) {\n console.log(bold(\"arguments:\"));\n const longest = Math.max(...positionals.map(({ key }) => key.length));\n for (const { key, entry } of positionals) {\n const name = entry.$required ? `<${key}>` : `[${key}]`;\n const line = ` ${cyan(pad(name, longest + 4))}${gray(entry.$description ?? \"\")}`;\n console.log(line);\n }\n }\n\n // SUBCOMMANDS\n if (this.$children.size > 0) {\n console.log(bold(\"sub commands:\"));\n const deduped = Array.from(\n new Map(\n [...this.$children.values()].map((a) => [\n a.command.$names[0],\n a.command,\n ]),\n ).values(),\n );\n\n const longest = Math.max(...deduped.map((c) => c.$names[0].length));\n for (const cmd of deduped) {\n const line = ` ${cyan(pad(cmd.$names[0], longest + 4))}${gray(cmd.$description) ?? \"\"}`;\n console.log(line);\n }\n console.log();\n console.log(\n `run '${cyan(`${this.fullCommandPath()} <command> --help`)}' for more info on a command.`,\n );\n }\n }\n\n /**\n * Handles a set of errors.\n * @param errors The errors to handle.\n * @param input The parsed input, if possible.\n * @returns this\n */\n async handleErrors(\n errors: Error[],\n input?: Partial<InferInput<T>>,\n ): Promise<this> {\n // eslint-disable-next-line -- necessary for traversing up the tree\n let command: Command<any> = this;\n while (!command.$errorFn && command.$parent) {\n command = command.$parent;\n }\n\n if (command.$errorFn) {\n await command.$errorFn(command, errors, input ?? {});\n } else {\n this.defaultErrorScreen(errors);\n }\n return this;\n }\n\n /**\n * Runs a command.\n * @param argv The arguments to run the command with. Defaults to your runtime's `argv` equivalent.\n * @returns this\n */\n async run(argv?: string[]): Promise<this> {\n const result = await this.parse(argv ?? process.argv.slice(2));\n if (result.isHelp) {\n result.command.handleErrors([new HelpAskedError(result.command)]);\n return this;\n } else if (result.isVersion) {\n console.log(\n `${result.command.fullCommandPath()} version ${result.command.$version}`,\n );\n return this;\n }\n\n try {\n if (result.errors.length > 0) {\n await result.command.handleErrors(result.errors, result.input);\n } else if (!result.command.$fn) {\n await result.command.handleErrors(\n [new HelpAskedError(result.command), ...result.errors],\n result.input,\n );\n } else {\n const middlewares = collectMiddlewares(result.command);\n if (middlewares.length > 0) {\n const runner = compose(middlewares);\n // finalNext calls the command action with the same input\n await runner(result.input, async () => {\n await result.command.$fn?.(result.input);\n });\n } else {\n await result.command.$fn(result.input);\n }\n }\n } catch (e) {\n if (!(e instanceof Error)) {\n console.warn(\n \"[convoker] an error that is not instance of `Error` was thrown. this may cause undefined behavior.\",\n );\n }\n await result.command.handleErrors([e as Error]);\n }\n return this;\n }\n}\n\nfunction collectMiddlewares(cmd: Command<any>) {\n const middlewares: MiddlewareFn<any>[] = [];\n let current: Command<any> | undefined = cmd;\n while (current) {\n if (current.$middlewares.length) {\n middlewares.unshift(...current.$middlewares);\n }\n current = current.$parent;\n }\n return middlewares;\n}\n\nfunction compose(mws: MiddlewareFn<any>[]) {\n return (input: InferInput<any>, finalNext?: () => Promise<any>) => {\n let index = -1;\n const dispatch = (i: number): Promise<any> => {\n if (i <= index)\n return Promise.reject(new Error(\"next() called multiple times\"));\n index = i;\n const fn = mws[i];\n if (!fn) {\n // when middlewares exhausted call finalNext if provided\n return finalNext ? finalNext() : Promise.resolve();\n }\n try {\n return Promise.resolve(fn(input, () => dispatch(i + 1)));\n } catch (err) {\n return Promise.reject(err);\n }\n };\n return dispatch(0);\n };\n}\n\nexport * from \"./error\";\n"],"mappings":";;;;;;;;;AAMA,IAAa,gBAAb,cAAmC,MAAM;;;;;;CAWvC,YAAY,SAAiB,SAAuB;AAClD,QAAM,QAAQ;AACd,OAAK,UAAU;;;;;CAMjB,QAAQ;AACN,UAAQ,MAAM,KAAK,QAAQ;;;;;;AAO/B,IAAa,iBAAb,cAAoC,cAAc;;;;;CAKhD,YAAY,SAAuB;AACjC,QAAM,wBAAwB,QAAQ;;;;;;AAO1C,IAAa,wBAAb,cAA2C,cAAc;;;;;CAKvD,YAAY,SAAuB;AACjC,QAAM,uBAAuB,QAAQ;;;;;;AAOzC,IAAa,qBAAb,cAAwC,cAAc;;;;;;CAWpD,YAAY,SAAuB,KAAa;AAC9C,QAAM,mBAAmB,IAAI,IAAI,QAAQ;AACzC,OAAK,MAAM;;;;;;AAOf,IAAa,6BAAb,cAAgD,cAAc;;;;;;;CAgB5D,YACE,SACA,KACA,OACA;AACA,QAAM,4BAA4B,IAAI,IAAI,QAAQ;AAClD,OAAK,MAAM;AACX,OAAK,QAAQ;;;AAIjB,IAAa,+BAAb,cAAkD,cAAc;;;;;;;CAgB9D,YACE,SACA,KACA,OACA;AACA,QAAM,yCAAyC,IAAI,IAAI,QAAQ;AAC/D,OAAK,MAAM;AACX,OAAK,QAAQ;;;;;;;;;ACvBjB,IAAa,UAAb,MAAa,QAAiC;;;;;;;CAwD5C,YAAY,OAA0B,MAAe,SAAkB;mCApChC,IAAI,KAAK;8BAQhB;+BAIC;g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Q,OAAO,IAAI;;;AAG9B,SAAO,SAAS,EAAE"}
@@ -1,6 +1,6 @@
1
- import { n as Theme } from "./color-BuHvMolk.mjs";
2
- import { t as StandardSchemaV1 } from "./standard-schema-DLeKaehR.mjs";
3
- import { i as raw_d_exports } from "./raw-BqvlveTU.mjs";
1
+ import { n as Theme } from "./index-BtbthYjp.mjs";
2
+ import { t as StandardSchemaV1 } from "./standard-schema-DXS-QnwX.mjs";
3
+ import { i as raw_d_exports } from "./raw-cqTp2vds.mjs";
4
4
 
5
5
  //#region src/prompt/index.d.ts
6
6
  declare namespace index_d_exports {
@@ -196,4 +196,5 @@ interface EditorOpts extends BaseOpts<string> {
196
196
  */
197
197
  declare function editor(opts: EditorOpts): Promise<string>;
198
198
  //#endregion
199
- export { text as _, SearchOpts as a, TextOpts as c, index_d_exports as d, multiselect as f, setTheme as g, select as h, PasswordOpts as i, confirm as l, search as m, ConfirmOpts as n, SelectOption as o, password as p, EditorOpts as r, SelectOpts as s, BaseOpts as t, editor as u };
199
+ export { text as _, SearchOpts as a, TextOpts as c, index_d_exports as d, multiselect as f, setTheme as g, select as h, PasswordOpts as i, confirm as l, search as m, ConfirmOpts as n, SelectOption as o, password as p, EditorOpts as r, SelectOpts as s, BaseOpts as t, editor as u };
200
+ //# sourceMappingURL=index-BYLskLxk.d.mts.map
@@ -1,4 +1,9 @@
1
- declare namespace color_d_exports {
1
+ //#region src/utils.d.ts
2
+ /**
3
+ * Deep `Partial<T>`.
4
+ */
5
+ type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]> };
6
+ declare namespace index_d_exports {
2
7
  export { DEFAULT_THEME, Theme, bgBlack, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blue, blueBright, bold, createAnsiColor, cyan, cyanBright, defineTheme, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, strikethrough, supportsColor, underline, white, whiteBright, yellow, yellowBright };
3
8
  }
4
9
  /**
@@ -114,6 +119,10 @@ interface Theme {
114
119
  * Error message symbol.
115
120
  */
116
121
  error: string;
122
+ /**
123
+ * Fatal error message symbol.
124
+ */
125
+ fatal: string;
117
126
  /**
118
127
  * Warning message symbol.
119
128
  */
@@ -153,6 +162,7 @@ declare const DEFAULT_THEME: Theme;
153
162
  * @param theme The (partial) theme.
154
163
  * @returns The theme, merged with the default theme.
155
164
  */
156
- declare function defineTheme(theme: Partial<Theme>): Theme;
165
+ declare function defineTheme(theme: DeepPartial<Theme>): Theme;
157
166
  //#endregion
158
- export { green as A, reset as B, color_d_exports as C, defineTheme as D, cyanBright as E, magenta as F, whiteBright as G, supportsColor as H, magentaBright as I, yellow as K, overline as L, hidden as M, inverse as N, dim as O, italic as P, red as R, bold as S, cyan as T, underline as U, strikethrough as V, white as W, bgYellow as _, bgBlueBright as a, blue as b, bgGray as c, bgMagenta as d, bgMagentaBright as f, bgWhiteBright as g, bgWhite as h, bgBlue as i, greenBright as j, gray as k, bgGreen as l, bgRedBright as m, Theme as n, bgCyan as o, bgRed as p, yellowBright as q, bgBlack as r, bgCyanBright as s, DEFAULT_THEME as t, bgGreenBright as u, bgYellowBright as v, createAnsiColor as w, blueBright as x, black as y, redBright as z };
167
+ export { greenBright as A, reset as B, createAnsiColor as C, dim as D, defineTheme as E, magenta as F, whiteBright as G, supportsColor as H, magentaBright as I, DeepPartial as J, yellow as K, overline as L, index_d_exports as M, inverse as N, gray as O, italic as P, red as R, bold as S, cyanBright as T, underline as U, strikethrough as V, white as W, bgYellow as _, bgBlueBright as a, blue as b, bgGray as c, bgMagenta as d, bgMagentaBright as f, bgWhiteBright as g, bgWhite as h, bgBlue as i, hidden as j, green as k, bgGreen as l, bgRedBright as m, Theme as n, bgCyan as o, bgRed as p, yellowBright as q, bgBlack as r, bgCyanBright as s, DEFAULT_THEME as t, bgGreenBright as u, bgYellowBright as v, cyan as w, blueBright as x, black as y, redBright as z };
168
+ //# sourceMappingURL=index-BtbthYjp.d.mts.map