convoker 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/color/index.d.mts +2 -2
- package/dist/color/index.mjs +2 -2
- package/dist/{color-DiZvJ0Fc.mjs → color-s-N9yh90.mjs} +2 -65
- package/dist/color-s-N9yh90.mjs.map +1 -0
- package/dist/command/index.d.mts +4 -4
- package/dist/command/index.mjs +7 -6
- package/dist/{command-8P8qXJ2o.mjs → command-C9QIG--8.mjs} +145 -9
- package/dist/command-C9QIG--8.mjs.map +1 -0
- package/dist/{index-BYLskLxk.d.mts → index-C0cH9MIP.d.mts} +4 -4
- package/dist/{index-ClhbwSD8.d.mts → index-C6iJZTo3.d.mts} +2 -2
- package/dist/index-CCQ6jz54.d.mts +58 -0
- package/dist/{index-Cnx4H4D-.d.mts → index-OUlP1L9o.d.mts} +3 -3
- package/dist/index.d.mts +62 -7
- package/dist/index.mjs +8 -91
- package/dist/input/index.d.mts +2 -2
- package/dist/input/index.mjs +2 -2
- package/dist/{input-XUsy1LCQ.mjs → input-li13L1uf.mjs} +2 -2
- package/dist/{input-XUsy1LCQ.mjs.map → input-li13L1uf.mjs.map} +1 -1
- package/dist/prompt/index.d.mts +4 -4
- package/dist/prompt/index.mjs +5 -4
- package/dist/prompt/raw.d.mts +1 -1
- package/dist/prompt/raw.mjs +1 -1
- package/dist/{prompt-a5Ix_Hyc.mjs → prompt-OXGrAkDf.mjs} +4 -4
- package/dist/{prompt-a5Ix_Hyc.mjs.map → prompt-OXGrAkDf.mjs.map} +1 -1
- package/dist/{raw-cqTp2vds.d.mts → raw-BqvlveTU.d.mts} +1 -1
- package/dist/{raw-DEtZFeMv.mjs → raw-DVT5lw11.mjs} +1 -1
- package/dist/{raw-DEtZFeMv.mjs.map → raw-DVT5lw11.mjs.map} +1 -1
- package/dist/{standard-schema-DXS-QnwX.d.mts → standard-schema-D1sStgzy.d.mts} +1 -1
- package/dist/{standard-schema-DTuaYJjO.mjs → standard-schema-WhGEzW0C.mjs} +1 -1
- package/dist/{standard-schema-DTuaYJjO.mjs.map → standard-schema-WhGEzW0C.mjs.map} +1 -1
- package/dist/theme-Chg3mOhZ.mjs +68 -0
- package/dist/theme-Chg3mOhZ.mjs.map +1 -0
- package/dist/theme-EERPMtQU.d.mts +115 -0
- package/dist/theme.d.mts +2 -0
- package/dist/theme.mjs +4 -0
- package/package.json +5 -1
- package/dist/color-DiZvJ0Fc.mjs.map +0 -1
- package/dist/command-8P8qXJ2o.mjs.map +0 -1
- package/dist/index-BtbthYjp.d.mts +0 -168
- package/dist/index.mjs.map +0 -1
package/dist/color/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export {
|
|
1
|
+
import { A as inverse, B as underline, C as cyanBright, D as greenBright, E as green, F as red, H as whiteBright, I as redBright, L as reset, M as magenta, N as magentaBright, O as hidden, P as overline, R as strikethrough, S as cyan, T as gray, U as yellow, V as white, W as yellowBright, _ as black, a as bgCyanBright, b as bold, c as bgGreenBright, d as bgRed, f as bgRedBright, g as bgYellowBright, h as bgYellow, i as bgCyan, j as italic, l as bgMagenta, m as bgWhiteBright, n as bgBlue, o as bgGray, p as bgWhite, r as bgBlueBright, s as bgGreen, t as bgBlack, u as bgMagentaBright, v as blue, w as dim, x as createAnsiColor, y as blueBright, z as supportsColor } from "../index-CCQ6jz54.mjs";
|
|
2
|
+
export { bgBlack, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blue, blueBright, bold, createAnsiColor, cyan, cyanBright, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, strikethrough, supportsColor, underline, white, whiteBright, yellow, yellowBright };
|
package/dist/color/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as inverse, B as underline, C as cyan, D as green, E as gray, F as red, H as whiteBright, I as redBright, L as reset, M as magenta, N as magentaBright, O as greenBright, P as overline, R as strikethrough, S as createAnsiColor, T as dim, U as yellow, V as white, W as yellowBright, _ as black, a as bgCyanBright, b as bold, c as bgGreenBright, d as bgRed, f as bgRedBright, g as bgYellowBright, h as bgYellow, i as bgCyan, j as italic, k as hidden, l as bgMagenta, m as bgWhiteBright, n as bgBlue, o as bgGray, p as bgWhite, r as bgBlueBright, s as bgGreen, t as bgBlack, u as bgMagentaBright, v as blue, w as cyanBright, y as blueBright, z as supportsColor } from "../color-s-N9yh90.mjs";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { bgBlack, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blue, blueBright, bold, createAnsiColor, cyan, cyanBright, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, strikethrough, supportsColor, underline, white, whiteBright, yellow, yellowBright };
|
|
@@ -1,40 +1,7 @@
|
|
|
1
1
|
import { t as __export } from "./chunk-z5eko27R.mjs";
|
|
2
2
|
|
|
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
3
|
//#region src/color/index.ts
|
|
36
4
|
var color_exports = /* @__PURE__ */ __export({
|
|
37
|
-
DEFAULT_THEME: () => DEFAULT_THEME,
|
|
38
5
|
bgBlack: () => bgBlack,
|
|
39
6
|
bgBlue: () => bgBlue,
|
|
40
7
|
bgBlueBright: () => bgBlueBright,
|
|
@@ -58,7 +25,6 @@ var color_exports = /* @__PURE__ */ __export({
|
|
|
58
25
|
createAnsiColor: () => createAnsiColor,
|
|
59
26
|
cyan: () => cyan,
|
|
60
27
|
cyanBright: () => cyanBright,
|
|
61
|
-
defineTheme: () => defineTheme,
|
|
62
28
|
dim: () => dim,
|
|
63
29
|
gray: () => gray,
|
|
64
30
|
green: () => green,
|
|
@@ -166,36 +132,7 @@ const bgBlueBright = createAnsiColor(104, 49);
|
|
|
166
132
|
const bgMagentaBright = createAnsiColor(105, 49);
|
|
167
133
|
const bgCyanBright = createAnsiColor(106, 49);
|
|
168
134
|
const bgWhiteBright = createAnsiColor(107, 49);
|
|
169
|
-
/**
|
|
170
|
-
* The default theme.
|
|
171
|
-
*/
|
|
172
|
-
const DEFAULT_THEME = {
|
|
173
|
-
primary: cyan,
|
|
174
|
-
secondary: gray,
|
|
175
|
-
success: green,
|
|
176
|
-
warning: yellow,
|
|
177
|
-
error: red,
|
|
178
|
-
symbols: {
|
|
179
|
-
success: "✔",
|
|
180
|
-
error: "✖",
|
|
181
|
-
fatal: "✖",
|
|
182
|
-
warning: "⚠"
|
|
183
|
-
},
|
|
184
|
-
styles: {
|
|
185
|
-
bold,
|
|
186
|
-
italic,
|
|
187
|
-
underline
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Defines a theme.
|
|
192
|
-
* @param theme The (partial) theme.
|
|
193
|
-
* @returns The theme, merged with the default theme.
|
|
194
|
-
*/
|
|
195
|
-
function defineTheme(theme) {
|
|
196
|
-
return merge(DEFAULT_THEME, theme);
|
|
197
|
-
}
|
|
198
135
|
|
|
199
136
|
//#endregion
|
|
200
|
-
export {
|
|
201
|
-
//# sourceMappingURL=color-
|
|
137
|
+
export { inverse as A, underline as B, cyan as C, green as D, gray as E, red as F, whiteBright as H, redBright as I, reset as L, magenta as M, magentaBright as N, greenBright as O, overline as P, strikethrough as R, createAnsiColor as S, dim as T, yellow as U, white as V, yellowBright as W, black as _, bgCyanBright as a, bold as b, bgGreenBright as c, bgRed as d, bgRedBright as f, bgYellowBright as g, bgYellow as h, bgCyan as i, italic as j, hidden as k, bgMagenta as l, bgWhiteBright as m, bgBlue as n, bgGray as o, bgWhite as p, bgBlueBright as r, bgGreen as s, bgBlack as t, bgMagentaBright as u, blue as v, cyanBright as w, color_exports as x, blueBright as y, supportsColor as z };
|
|
138
|
+
//# sourceMappingURL=color-s-N9yh90.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-s-N9yh90.mjs","names":[],"sources":["../src/color/index.ts"],"sourcesContent":["/**\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,qBAAqB;AAE5B,KAAI,OAAO,WAAW,eAAe,OAAO,OAAO,aAAa,YAC9D,QAAO;CAGT,MAAM,MAAM,OAAO,YAAY,cAAe,QAAQ,OAAO,EAAE,GAAI,EAAE;AAGrE,KAAI,cAAc,IAAK,QAAO;AAG9B,KAAI,iBAAiB,IAAK,QAAO;AAGjC,KAAI,QAAQ,KAAK;AACf,MACE;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,MAAM,MAAM,KAAK,IAAI,IACvB,IAAI,YAAY,WAEhB,QAAO;AAET,SAAO;;CAGT,MAAM,OAAO,IAAI,QAAQ;AAGzB,MAFkB,IAAI,aAAa,IA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AAa,UAAU,gBAAgB,IAAI,GAAG;AAC9C,MAAa,WAAW,gBAAgB,IAAI,GAAG;AAC/C,MAAa,SAAS,gBAAgB,IAAI,GAAG;AAC7C,MAAa,YAAY,gBAAgB,IAAI,GAAG;AAChD,MAAa,SAAS,gBAAgB,IAAI,GAAG;AAC7C,MAAa,UAAU,gBAAgB,IAAI,GAAG;AAC9C,MAAa,SAAS,gBAAgB,KAAK,GAAG;AAE9C,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"}
|
package/dist/command/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../standard-schema-
|
|
3
|
-
import "../index-
|
|
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-
|
|
1
|
+
import "../theme-EERPMtQU.mjs";
|
|
2
|
+
import "../standard-schema-D1sStgzy.mjs";
|
|
3
|
+
import "../index-C6iJZTo3.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-OUlP1L9o.mjs";
|
|
5
5
|
export { ActionFn, Builder, Command, CommandAlias, ConvokerError, ErrorFn, HelpAskedError, MiddlewareFn, MissingRequiredArgumentError, MissingRequiredOptionError, ParseResult, TooManyArgumentsError, UnknownOptionError };
|
package/dist/command/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import "../color-
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import
|
|
6
|
-
import "../
|
|
1
|
+
import "../color-s-N9yh90.mjs";
|
|
2
|
+
import "../theme-Chg3mOhZ.mjs";
|
|
3
|
+
import "../standard-schema-WhGEzW0C.mjs";
|
|
4
|
+
import "../raw-DVT5lw11.mjs";
|
|
5
|
+
import "../prompt-OXGrAkDf.mjs";
|
|
6
|
+
import { a as MissingRequiredOptionError, i as MissingRequiredArgumentError, n as ConvokerError, o as TooManyArgumentsError, r as HelpAskedError, s as UnknownOptionError, t as Command } from "../command-C9QIG--8.mjs";
|
|
7
|
+
import "../input-li13L1uf.mjs";
|
|
7
8
|
|
|
8
9
|
export { Command, ConvokerError, HelpAskedError, MissingRequiredArgumentError, MissingRequiredOptionError, TooManyArgumentsError, UnknownOptionError };
|
|
@@ -1,8 +1,141 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as __export } from "./chunk-z5eko27R.mjs";
|
|
2
|
+
import { C as cyan, E as gray, b as bold } from "./color-s-N9yh90.mjs";
|
|
3
|
+
import { r as merge, t as DEFAULT_THEME } from "./theme-Chg3mOhZ.mjs";
|
|
4
|
+
import { c as setTheme } from "./prompt-OXGrAkDf.mjs";
|
|
5
|
+
import { i as convert, n as Positional, t as Option } from "./input-li13L1uf.mjs";
|
|
4
6
|
import process from "node:process";
|
|
5
7
|
|
|
8
|
+
//#region src/log/error.ts
|
|
9
|
+
/**
|
|
10
|
+
* Error for when logs fail to write to stdout/stderr.
|
|
11
|
+
*/
|
|
12
|
+
var WriteError = class extends Error {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new error for stream writes.
|
|
15
|
+
* @param streamName The name of the stream.
|
|
16
|
+
*/
|
|
17
|
+
constructor(streamName) {
|
|
18
|
+
super(`Could not write to \`${streamName}\`.`);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/log/index.ts
|
|
24
|
+
var log_exports = /* @__PURE__ */ __export({
|
|
25
|
+
DEFAULT_CONFIG: () => DEFAULT_CONFIG,
|
|
26
|
+
WriteError: () => WriteError,
|
|
27
|
+
error: () => error,
|
|
28
|
+
fatal: () => fatal,
|
|
29
|
+
info: () => info,
|
|
30
|
+
setConfig: () => setConfig,
|
|
31
|
+
setTheme: () => setTheme$1,
|
|
32
|
+
trace: () => trace,
|
|
33
|
+
warn: () => warn
|
|
34
|
+
});
|
|
35
|
+
let th = DEFAULT_THEME;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the theme for logs.
|
|
38
|
+
* @param theme The theme to set.
|
|
39
|
+
*/
|
|
40
|
+
function setTheme$1(theme) {
|
|
41
|
+
th = theme;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Default log configuration.
|
|
45
|
+
*/
|
|
46
|
+
const DEFAULT_CONFIG = {
|
|
47
|
+
format: "text",
|
|
48
|
+
stderr: process.stderr,
|
|
49
|
+
stdout: process.stdout,
|
|
50
|
+
jsonSpace: 2
|
|
51
|
+
};
|
|
52
|
+
let config = DEFAULT_CONFIG;
|
|
53
|
+
/**
|
|
54
|
+
* Sets log configuration.
|
|
55
|
+
* @param cfg The configuration, optionally including a theme.
|
|
56
|
+
*/
|
|
57
|
+
function setConfig({ theme,...cfg }) {
|
|
58
|
+
config = merge(DEFAULT_CONFIG, cfg);
|
|
59
|
+
th = theme ?? th;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Prints messages.
|
|
63
|
+
* @param msgs The messages to print.
|
|
64
|
+
*/
|
|
65
|
+
function trace(...msgs) {
|
|
66
|
+
const str = format(msgs, "TRACE");
|
|
67
|
+
if (!config.stdout.write(str)) throw new WriteError("stdout");
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Prints messages.
|
|
71
|
+
* @param msgs The messages to print.
|
|
72
|
+
*/
|
|
73
|
+
function info(...msgs) {
|
|
74
|
+
const str = format(msgs, "INFO");
|
|
75
|
+
if (!config.stdout.write(str)) throw new WriteError("stdout");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Prints warning messages.
|
|
79
|
+
* @param msgs The messages to print.
|
|
80
|
+
*/
|
|
81
|
+
function warn(...msgs) {
|
|
82
|
+
const str = format(msgs, "WARN");
|
|
83
|
+
if (!config.stderr.write(th.warning(str))) throw new WriteError("stderr");
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Prints error messages.
|
|
87
|
+
* @param msgs The messages to print.
|
|
88
|
+
*/
|
|
89
|
+
function error(...msgs) {
|
|
90
|
+
const str = format(msgs, "ERROR");
|
|
91
|
+
if (!config.stderr.write(str)) throw new WriteError("stderr");
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Prints messages and exits with code -1.
|
|
95
|
+
* @param msgs The messages to print.
|
|
96
|
+
*/
|
|
97
|
+
function fatal(...msgs) {
|
|
98
|
+
const str = format(msgs, "FATAL");
|
|
99
|
+
if (!config.stderr.write(str)) throw new WriteError("stderr");
|
|
100
|
+
process.exit(-1);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Formats a list of messages into a single string.
|
|
104
|
+
* @param msgs The messages to format.
|
|
105
|
+
* @param level The log level.
|
|
106
|
+
* @returns A formatted message.
|
|
107
|
+
*/
|
|
108
|
+
function format(msgs, level) {
|
|
109
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
110
|
+
const msg = msgs.map((m) => typeof m === "string" ? m : JSON.stringify(m, null, config.jsonSpace)).join(" ");
|
|
111
|
+
switch (config.format) {
|
|
112
|
+
case "json": return colorize(JSON.stringify({
|
|
113
|
+
timestamp,
|
|
114
|
+
level,
|
|
115
|
+
message: msg
|
|
116
|
+
}) + "\n", level);
|
|
117
|
+
case "text":
|
|
118
|
+
default: return colorize(`[${timestamp}] [${th.symbols[level] ?? level}] ${msg}\n`, level);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Wraps a string in ANSI codes, based on a log level.
|
|
123
|
+
* @param str The string to color.
|
|
124
|
+
* @param level The log level.
|
|
125
|
+
* @returns An ANSI-wrapped string.
|
|
126
|
+
*/
|
|
127
|
+
function colorize(str, level) {
|
|
128
|
+
switch (level) {
|
|
129
|
+
case "TRACE": return th.secondary(str);
|
|
130
|
+
case "WARN": return th.warning(str);
|
|
131
|
+
case "ERROR": return th.error(str);
|
|
132
|
+
case "FATAL": return th.styles?.bold ? th.styles.bold(th.error(str)) : th.error(str);
|
|
133
|
+
case "INFO":
|
|
134
|
+
default: return th.info?.(str) ?? str;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
6
139
|
//#region src/command/error.ts
|
|
7
140
|
/**
|
|
8
141
|
* A Convoker-related error. These are usually handled by default.
|
|
@@ -281,7 +414,10 @@ var Command = class Command {
|
|
|
281
414
|
}
|
|
282
415
|
} else if (command.$children.has(arg) && !found) {
|
|
283
416
|
command = command.$children.get(arg).command;
|
|
284
|
-
if (command.$theme)
|
|
417
|
+
if (command.$theme) {
|
|
418
|
+
setTheme(command.$theme);
|
|
419
|
+
setTheme$1(command.$theme);
|
|
420
|
+
}
|
|
285
421
|
} else {
|
|
286
422
|
found = true;
|
|
287
423
|
args.push(arg);
|
|
@@ -364,10 +500,10 @@ var Command = class Command {
|
|
|
364
500
|
defaultErrorScreen(errors) {
|
|
365
501
|
let printHelpScreen = false;
|
|
366
502
|
const nonCliErrors = [];
|
|
367
|
-
for (const error of errors) if (error instanceof ConvokerError) {
|
|
368
|
-
if (!(error instanceof HelpAskedError)) error.print();
|
|
503
|
+
for (const error$1 of errors) if (error$1 instanceof ConvokerError) {
|
|
504
|
+
if (!(error$1 instanceof HelpAskedError)) error$1.print();
|
|
369
505
|
printHelpScreen = true;
|
|
370
|
-
} else nonCliErrors.push(error);
|
|
506
|
+
} else nonCliErrors.push(error$1);
|
|
371
507
|
if (nonCliErrors.length) throw nonCliErrors[0];
|
|
372
508
|
if (!printHelpScreen) return;
|
|
373
509
|
const pad = (s, len) => s.padEnd(len, " ");
|
|
@@ -482,5 +618,5 @@ function compose(mws) {
|
|
|
482
618
|
}
|
|
483
619
|
|
|
484
620
|
//#endregion
|
|
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-
|
|
621
|
+
export { MissingRequiredOptionError as a, log_exports as c, MissingRequiredArgumentError as i, ConvokerError as n, TooManyArgumentsError as o, HelpAskedError as r, UnknownOptionError as s, Command as t };
|
|
622
|
+
//# sourceMappingURL=command-C9QIG--8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-C9QIG--8.mjs","names":["th: Theme","setTheme","DEFAULT_CONFIG: Config","config: Config","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[]","error","middlewares: MiddlewareFn<any>[]","current: Command<any> | undefined"],"sources":["../src/log/error.ts","../src/log/index.ts","../src/command/error.ts","../src/command/index.ts"],"sourcesContent":["/**\n * Error for when logs fail to write to stdout/stderr.\n */\nexport class WriteError extends Error {\n /**\n * Creates a new error for stream writes.\n * @param streamName The name of the stream.\n */\n constructor(streamName: string) {\n super(`Could not write to \\`${streamName}\\`.`);\n }\n}\n","import Stream from \"node:stream\";\nimport process from \"node:process\";\nimport { DEFAULT_THEME, type Theme } from \"@/theme\";\nimport { DeepPartial, merge } from \"@/utils\";\nimport { WriteError } from \"./error\";\n\nlet th: Theme = DEFAULT_THEME;\n\n/**\n * Sets the theme for logs.\n * @param theme The theme to set.\n */\nexport function setTheme(theme: Theme) {\n th = theme;\n}\n\n/**\n * Log configuration.\n */\nexport interface Config {\n /**\n * The configuration format.\n */\n format: \"text\" | \"json\";\n /**\n * Standard output.\n */\n stdout: Stream.Writable;\n /**\n * Standard error output.\n */\n stderr: Stream.Writable;\n /**\n * How much space in the JSON output of objects.\n * This does not change spacing in JSON logs, only for objects passed into log functions.\n */\n jsonSpace: number;\n}\n\n/**\n * Default log configuration.\n */\nexport const DEFAULT_CONFIG: Config = {\n format: \"text\",\n stderr: process.stderr,\n stdout: process.stdout,\n jsonSpace: 2,\n};\n\nlet config: Config = DEFAULT_CONFIG;\n\n/**\n * Sets log configuration.\n * @param cfg The configuration, optionally including a theme.\n */\nexport function setConfig({\n theme,\n ...cfg\n}: DeepPartial<Config> & { theme?: Theme }) {\n config = merge(DEFAULT_CONFIG, cfg);\n th = theme ?? th;\n}\n\n/**\n * Prints messages.\n * @param msgs The messages to print.\n */\nexport function trace(...msgs: any[]) {\n const str = format(msgs, \"TRACE\");\n if (!config.stdout.write(str)) {\n throw new WriteError(\"stdout\");\n }\n}\n\n/**\n * Prints messages.\n * @param msgs The messages to print.\n */\nexport function info(...msgs: any[]) {\n const str = format(msgs, \"INFO\");\n if (!config.stdout.write(str)) {\n throw new WriteError(\"stdout\");\n }\n}\n\n/**\n * Prints warning messages.\n * @param msgs The messages to print.\n */\nexport function warn(...msgs: any[]) {\n const str = format(msgs, \"WARN\");\n if (!config.stderr.write(th.warning(str))) {\n throw new WriteError(\"stderr\");\n }\n}\n\n/**\n * Prints error messages.\n * @param msgs The messages to print.\n */\nexport function error(...msgs: any[]) {\n const str = format(msgs, \"ERROR\");\n if (!config.stderr.write(str)) {\n throw new WriteError(\"stderr\");\n }\n}\n\n/**\n * Prints messages and exits with code -1.\n * @param msgs The messages to print.\n */\nexport function fatal(...msgs: any[]) {\n const str = format(msgs, \"FATAL\");\n if (!config.stderr.write(str)) {\n throw new WriteError(\"stderr\");\n }\n\n process.exit(-1);\n}\n\nexport * from \"./error\";\n\n/**\n * Formats a list of messages into a single string.\n * @param msgs The messages to format.\n * @param level The log level.\n * @returns A formatted message.\n */\nfunction format(msgs: any[], level: string): string {\n const timestamp = new Date().toISOString();\n const msg = msgs\n .map((m) =>\n typeof m === \"string\" ? m : JSON.stringify(m, null, config.jsonSpace),\n )\n .join(\" \");\n switch (config.format) {\n case \"json\":\n return colorize(\n JSON.stringify({ timestamp, level, message: msg }) + \"\\n\",\n level,\n );\n case \"text\":\n default:\n return colorize(\n `[${timestamp}] [${(th.symbols as any)[level] ?? level}] ${msg}\\n`,\n level,\n );\n }\n}\n\n/**\n * Wraps a string in ANSI codes, based on a log level.\n * @param str The string to color.\n * @param level The log level.\n * @returns An ANSI-wrapped string.\n */\nfunction colorize(str: string, level: string) {\n switch (level) {\n case \"TRACE\":\n return th.secondary(str);\n case \"WARN\":\n return th.warning(str);\n case \"ERROR\":\n return th.error(str);\n case \"FATAL\":\n return th.styles?.bold ? th.styles.bold(th.error(str)) : th.error(str);\n case \"INFO\":\n default:\n return th.info?.(str) ?? str;\n }\n}\n","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 } from \"@/color\";\nimport type { Theme } from \"@/theme\";\nimport { setTheme as setPromptTheme } from \"@/prompt\";\nimport { setTheme as setLogTheme } from \"@/log\";\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 setLogTheme(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":";;;;;;;;;;;AAGA,IAAa,aAAb,cAAgC,MAAM;;;;;CAKpC,YAAY,YAAoB;AAC9B,QAAM,wBAAwB,WAAW,KAAK;;;;;;;;;;;;;;;;;ACHlD,IAAIA,KAAY;;;;;AAMhB,SAAgBC,WAAS,OAAc;AACrC,MAAK;;;;;AA6BP,MAAaC,iBAAyB;CACpC,QAAQ;CACR,QAAQ,QAAQ;CAChB,QAAQ,QAAQ;CAChB,WAAW;CACZ;AAED,IAAIC,SAAiB;;;;;AAMrB,SAAgB,UAAU,EACxB,MACA,GAAG,OACuC;AAC1C,UAAS,MAAM,gBAAgB,IAAI;AACnC,MAAK,SAAS;;;;;;AAOhB,SAAgB,MAAM,GAAG,MAAa;CACpC,MAAM,MAAM,OAAO,MAAM,QAAQ;AACjC,KAAI,CAAC,OAAO,OAAO,MAAM,IAAI,CAC3B,OAAM,IAAI,WAAW,SAAS;;;;;;AAQlC,SAAgB,KAAK,GAAG,MAAa;CACnC,MAAM,MAAM,OAAO,MAAM,OAAO;AAChC,KAAI,CAAC,OAAO,OAAO,MAAM,IAAI,CAC3B,OAAM,IAAI,WAAW,SAAS;;;;;;AAQlC,SAAgB,KAAK,GAAG,MAAa;CACnC,MAAM,MAAM,OAAO,MAAM,OAAO;AAChC,KAAI,CAAC,OAAO,OAAO,MAAM,GAAG,QAAQ,IAAI,CAAC,CACvC,OAAM,IAAI,WAAW,SAAS;;;;;;AAQlC,SAAgB,MAAM,GAAG,MAAa;CACpC,MAAM,MAAM,OAAO,MAAM,QAAQ;AACjC,KAAI,CAAC,OAAO,OAAO,MAAM,IAAI,CAC3B,OAAM,IAAI,WAAW,SAAS;;;;;;AAQlC,SAAgB,MA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AAO,QAAQ,aAAa,CAAC,EAAW,CAAC;;AAEjD,SAAO;;;AAIX,SAAS,mBAAmB,KAAmB;CAC7C,MAAMW,cAAmC,EAAE;CAC3C,IAAIC,UAAoC;AACxC,QAAO,SAAS;AACd,MAAI,QAAQ,aAAa,OACvB,aAAY,QAAQ,GAAG,QAAQ,aAAa;AAE9C,YAAU,QAAQ;;AAEpB,QAAO;;AAGT,SAAS,QAAQ,KAA0B;AACzC,SAAQ,OAAwB,cAAmC;EACjE,IAAI,QAAQ;EACZ,MAAM,YAAY,MAA4B;AAC5C,OAAI,KAAK,MACP,QAAO,QAAQ,uBAAO,IAAI,MAAM,+BAA+B,CAAC;AAClE,WAAQ;GACR,MAAM,KAAK,IAAI;AACf,OAAI,CAAC,GAEH,QAAO,YAAY,WAAW,GAAG,QAAQ,SAAS;AAEpD,OAAI;AACF,WAAO,QAAQ,QAAQ,GAAG,aAAa,SAAS,IAAI,EAAE,CAAC,CAAC;YACjD,KAAK;AACZ,WAAO,QAAQ,OAAO,IAAI;;;AAG9B,SAAO,SAAS,EAAE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as Theme } from "./
|
|
2
|
-
import { t as StandardSchemaV1 } from "./standard-schema-
|
|
3
|
-
import { i as raw_d_exports } from "./raw-
|
|
1
|
+
import { n as Theme } from "./theme-EERPMtQU.mjs";
|
|
2
|
+
import { t as StandardSchemaV1 } from "./standard-schema-D1sStgzy.mjs";
|
|
3
|
+
import { i as raw_d_exports } from "./raw-BqvlveTU.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/prompt/index.d.ts
|
|
6
6
|
declare namespace index_d_exports {
|
|
@@ -197,4 +197,4 @@ interface EditorOpts extends BaseOpts<string> {
|
|
|
197
197
|
declare function editor(opts: EditorOpts): Promise<string>;
|
|
198
198
|
//#endregion
|
|
199
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-
|
|
200
|
+
//# sourceMappingURL=index-C0cH9MIP.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as StandardSchemaV1 } from "./standard-schema-
|
|
1
|
+
import { t as StandardSchemaV1 } from "./standard-schema-D1sStgzy.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/input/error.d.ts
|
|
4
4
|
/**
|
|
@@ -199,4 +199,4 @@ declare function positional<T extends Kind>(kind: T): Positional<T>;
|
|
|
199
199
|
declare function argument<T extends Kind>(kind: T): Positional<T>;
|
|
200
200
|
//#endregion
|
|
201
201
|
export { Kind as a, TypeOf as c, index_d_exports as d, option as f, Input as i, argument as l, InputValidationError as m, InferEntry as n, Option as o, positional as p, InferInput as r, Positional as s, BasicKind as t, convert as u };
|
|
202
|
-
//# sourceMappingURL=index-
|
|
202
|
+
//# sourceMappingURL=index-C6iJZTo3.d.mts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
declare namespace index_d_exports {
|
|
2
|
+
export { bgBlack, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blue, blueBright, bold, createAnsiColor, cyan, cyanBright, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, strikethrough, supportsColor, underline, white, whiteBright, yellow, yellowBright };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* If the runtime supports color.
|
|
6
|
+
*/
|
|
7
|
+
declare const supportsColor: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a function that wraps a string in ANSI codes.
|
|
10
|
+
* @param open The opening ANSI code.
|
|
11
|
+
* @param close The closing ANSI code.
|
|
12
|
+
* @returns A function that wraps the string in ANSI codes.
|
|
13
|
+
*/
|
|
14
|
+
declare function createAnsiColor(open: number, close: number): (input: any) => string;
|
|
15
|
+
declare const reset: (input: any) => string;
|
|
16
|
+
declare const bold: (input: any) => string;
|
|
17
|
+
declare const dim: (input: any) => string;
|
|
18
|
+
declare const italic: (input: any) => string;
|
|
19
|
+
declare const underline: (input: any) => string;
|
|
20
|
+
declare const overline: (input: any) => string;
|
|
21
|
+
declare const inverse: (input: any) => string;
|
|
22
|
+
declare const hidden: (input: any) => string;
|
|
23
|
+
declare const strikethrough: (input: any) => string;
|
|
24
|
+
declare const black: (input: any) => string;
|
|
25
|
+
declare const red: (input: any) => string;
|
|
26
|
+
declare const green: (input: any) => string;
|
|
27
|
+
declare const yellow: (input: any) => string;
|
|
28
|
+
declare const blue: (input: any) => string;
|
|
29
|
+
declare const magenta: (input: any) => string;
|
|
30
|
+
declare const cyan: (input: any) => string;
|
|
31
|
+
declare const white: (input: any) => string;
|
|
32
|
+
declare const gray: (input: any) => string;
|
|
33
|
+
declare const bgBlack: (input: any) => string;
|
|
34
|
+
declare const bgRed: (input: any) => string;
|
|
35
|
+
declare const bgGreen: (input: any) => string;
|
|
36
|
+
declare const bgYellow: (input: any) => string;
|
|
37
|
+
declare const bgBlue: (input: any) => string;
|
|
38
|
+
declare const bgMagenta: (input: any) => string;
|
|
39
|
+
declare const bgCyan: (input: any) => string;
|
|
40
|
+
declare const bgWhite: (input: any) => string;
|
|
41
|
+
declare const bgGray: (input: any) => string;
|
|
42
|
+
declare const redBright: (input: any) => string;
|
|
43
|
+
declare const greenBright: (input: any) => string;
|
|
44
|
+
declare const yellowBright: (input: any) => string;
|
|
45
|
+
declare const blueBright: (input: any) => string;
|
|
46
|
+
declare const magentaBright: (input: any) => string;
|
|
47
|
+
declare const cyanBright: (input: any) => string;
|
|
48
|
+
declare const whiteBright: (input: any) => string;
|
|
49
|
+
declare const bgRedBright: (input: any) => string;
|
|
50
|
+
declare const bgGreenBright: (input: any) => string;
|
|
51
|
+
declare const bgYellowBright: (input: any) => string;
|
|
52
|
+
declare const bgBlueBright: (input: any) => string;
|
|
53
|
+
declare const bgMagentaBright: (input: any) => string;
|
|
54
|
+
declare const bgCyanBright: (input: any) => string;
|
|
55
|
+
declare const bgWhiteBright: (input: any) => string;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { inverse as A, underline as B, cyanBright as C, greenBright as D, green as E, red as F, whiteBright as H, redBright as I, reset as L, magenta as M, magentaBright as N, hidden as O, overline as P, strikethrough as R, cyan as S, gray as T, yellow as U, white as V, yellowBright as W, black as _, bgCyanBright as a, bold as b, bgGreenBright as c, bgRed as d, bgRedBright as f, bgYellowBright as g, bgYellow as h, bgCyan as i, italic as j, index_d_exports as k, bgMagenta as l, bgWhiteBright as m, bgBlue as n, bgGray as o, bgWhite as p, bgBlueBright as r, bgGreen as s, bgBlack as t, bgMagentaBright as u, blue as v, dim as w, createAnsiColor as x, blueBright as y, supportsColor as z };
|
|
58
|
+
//# sourceMappingURL=index-CCQ6jz54.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as Theme } from "./
|
|
2
|
-
import { i as Input, o as Option, r as InferInput, s as Positional } from "./index-
|
|
1
|
+
import { n as Theme } from "./theme-EERPMtQU.mjs";
|
|
2
|
+
import { i as Input, o as Option, r as InferInput, s as Positional } from "./index-C6iJZTo3.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/command/error.d.ts
|
|
5
5
|
|
|
@@ -313,4 +313,4 @@ declare class Command<T extends Input = Input> {
|
|
|
313
313
|
}
|
|
314
314
|
//#endregion
|
|
315
315
|
export { ErrorFn as a, ConvokerError as c, MissingRequiredOptionError as d, TooManyArgumentsError as f, CommandAlias as i, HelpAskedError as l, Builder as n, MiddlewareFn as o, UnknownOptionError as p, Command as r, ParseResult as s, ActionFn as t, MissingRequiredArgumentError as u };
|
|
316
|
-
//# sourceMappingURL=index-
|
|
316
|
+
//# sourceMappingURL=index-OUlP1L9o.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,37 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import "./
|
|
6
|
-
import
|
|
1
|
+
import { k as index_d_exports } from "./index-CCQ6jz54.mjs";
|
|
2
|
+
import { i as DeepPartial, n as Theme, r as defineTheme, t as DEFAULT_THEME } from "./theme-EERPMtQU.mjs";
|
|
3
|
+
import "./standard-schema-D1sStgzy.mjs";
|
|
4
|
+
import { d as index_d_exports$1 } from "./index-C6iJZTo3.mjs";
|
|
5
|
+
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-OUlP1L9o.mjs";
|
|
6
|
+
import "./raw-BqvlveTU.mjs";
|
|
7
|
+
import { d as index_d_exports$3 } from "./index-C0cH9MIP.mjs";
|
|
7
8
|
import Stream from "node:stream";
|
|
8
9
|
|
|
9
10
|
//#region src/log/error.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Error for when logs fail to write to stdout/stderr.
|
|
13
|
+
*/
|
|
10
14
|
declare class WriteError extends Error {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new error for stream writes.
|
|
17
|
+
* @param streamName The name of the stream.
|
|
18
|
+
*/
|
|
11
19
|
constructor(streamName: string);
|
|
12
20
|
}
|
|
13
21
|
declare namespace index_d_exports$2 {
|
|
14
22
|
export { Config, DEFAULT_CONFIG, WriteError, error, fatal, info, setConfig, setTheme, trace, warn };
|
|
15
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Sets the theme for logs.
|
|
26
|
+
* @param theme The theme to set.
|
|
27
|
+
*/
|
|
16
28
|
declare function setTheme(theme: Theme): void;
|
|
29
|
+
/**
|
|
30
|
+
* Log configuration.
|
|
31
|
+
*/
|
|
17
32
|
interface Config {
|
|
33
|
+
/**
|
|
34
|
+
* The configuration format.
|
|
35
|
+
*/
|
|
18
36
|
format: "text" | "json";
|
|
37
|
+
/**
|
|
38
|
+
* Standard output.
|
|
39
|
+
*/
|
|
19
40
|
stdout: Stream.Writable;
|
|
41
|
+
/**
|
|
42
|
+
* Standard error output.
|
|
43
|
+
*/
|
|
20
44
|
stderr: Stream.Writable;
|
|
45
|
+
/**
|
|
46
|
+
* How much space in the JSON output of objects.
|
|
47
|
+
* This does not change spacing in JSON logs, only for objects passed into log functions.
|
|
48
|
+
*/
|
|
21
49
|
jsonSpace: number;
|
|
22
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Default log configuration.
|
|
53
|
+
*/
|
|
23
54
|
declare const DEFAULT_CONFIG: Config;
|
|
55
|
+
/**
|
|
56
|
+
* Sets log configuration.
|
|
57
|
+
* @param cfg The configuration, optionally including a theme.
|
|
58
|
+
*/
|
|
24
59
|
declare function setConfig({
|
|
25
60
|
theme,
|
|
26
61
|
...cfg
|
|
27
62
|
}: DeepPartial<Config> & {
|
|
28
63
|
theme?: Theme;
|
|
29
64
|
}): void;
|
|
65
|
+
/**
|
|
66
|
+
* Prints messages.
|
|
67
|
+
* @param msgs The messages to print.
|
|
68
|
+
*/
|
|
30
69
|
declare function trace(...msgs: any[]): void;
|
|
70
|
+
/**
|
|
71
|
+
* Prints messages.
|
|
72
|
+
* @param msgs The messages to print.
|
|
73
|
+
*/
|
|
31
74
|
declare function info(...msgs: any[]): void;
|
|
75
|
+
/**
|
|
76
|
+
* Prints warning messages.
|
|
77
|
+
* @param msgs The messages to print.
|
|
78
|
+
*/
|
|
32
79
|
declare function warn(...msgs: any[]): void;
|
|
80
|
+
/**
|
|
81
|
+
* Prints error messages.
|
|
82
|
+
* @param msgs The messages to print.
|
|
83
|
+
*/
|
|
33
84
|
declare function error(...msgs: any[]): void;
|
|
85
|
+
/**
|
|
86
|
+
* Prints messages and exits with code -1.
|
|
87
|
+
* @param msgs The messages to print.
|
|
88
|
+
*/
|
|
34
89
|
declare function fatal(...msgs: any[]): void;
|
|
35
90
|
//#endregion
|
|
36
|
-
export { ActionFn, Builder, Command, CommandAlias, ConvokerError, ErrorFn, HelpAskedError, MiddlewareFn, MissingRequiredArgumentError, MissingRequiredOptionError, ParseResult, TooManyArgumentsError, UnknownOptionError, index_d_exports as color, index_d_exports$1 as i, index_d_exports$2 as log, index_d_exports$3 as prompt };
|
|
91
|
+
export { ActionFn, Builder, Command, CommandAlias, ConvokerError, DEFAULT_THEME, ErrorFn, HelpAskedError, MiddlewareFn, MissingRequiredArgumentError, MissingRequiredOptionError, ParseResult, Theme, TooManyArgumentsError, UnknownOptionError, index_d_exports as color, defineTheme, index_d_exports$1 as i, index_d_exports$2 as log, index_d_exports$3 as prompt };
|
|
37
92
|
//# sourceMappingURL=index.d.mts.map
|