bob-core 2.0.0-beta.13 → 2.0.0-beta.15

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/esm/index.js CHANGED
@@ -1,515 +1,244 @@
1
- import b from "prompts";
2
- import X from "minimist";
3
- import * as Z from "node:fs";
4
- import I from "path";
5
- import * as ee from "string-similarity";
6
- class z {
1
+ import y from "prompts";
2
+ import a from "chalk";
3
+ import q from "minimist";
4
+ import * as I from "node:fs";
5
+ import R from "path";
6
+ class S {
7
7
  logger;
8
- constructor(e) {
9
- this.logger = e;
8
+ constructor(t) {
9
+ this.logger = t.logger;
10
10
  }
11
11
  /**
12
12
  * Logger methods
13
13
  */
14
- log(...e) {
15
- this.logger.log(...e);
14
+ log(...t) {
15
+ this.logger.log(...t);
16
16
  }
17
- info(...e) {
18
- this.logger.info(...e);
17
+ info(...t) {
18
+ this.logger.info(...t);
19
19
  }
20
- warn(...e) {
21
- this.logger.warn(...e);
20
+ warn(...t) {
21
+ this.logger.warn(...t);
22
22
  }
23
- error(...e) {
24
- this.logger.error(...e);
23
+ error(...t) {
24
+ this.logger.error(...t);
25
25
  }
26
- debug(...e) {
27
- this.logger.debug(...e);
26
+ debug(...t) {
27
+ this.logger.debug(...t);
28
28
  }
29
29
  /**
30
30
  * Prompt utils
31
31
  */
32
- async askForConfirmation(e = "Do you want to continue?", t) {
33
- return (await b({
32
+ async askForConfirmation(t = "Do you want to continue?", e) {
33
+ return (await y({
34
34
  type: "confirm",
35
35
  name: "value",
36
- message: e,
37
- initial: t ?? !1
36
+ message: t,
37
+ initial: e ?? !1
38
38
  })).value;
39
39
  }
40
- async askForInput(e, t, r) {
41
- return (await b({
40
+ async askForInput(t, e, i) {
41
+ return (await y({
42
42
  type: "text",
43
43
  name: "value",
44
- message: e,
45
- initial: t,
46
- ...r
44
+ message: t,
45
+ initial: e,
46
+ ...i
47
47
  }))?.value ?? null;
48
48
  }
49
- async askForDate(e, t, r) {
50
- return (await b({
49
+ async askForDate(t, e, i) {
50
+ return (await y({
51
51
  type: "date",
52
52
  name: "value",
53
- message: e,
54
- initial: t,
55
- ...r
53
+ message: t,
54
+ initial: e,
55
+ ...i
56
56
  }))?.value ?? null;
57
57
  }
58
- async askForList(e, t, r) {
59
- return (await b({
58
+ async askForList(t, e, i) {
59
+ return (await y({
60
60
  type: "list",
61
61
  name: "value",
62
- message: e,
63
- initial: t,
64
- ...r
62
+ message: t,
63
+ initial: e,
64
+ ...i
65
65
  }))?.value ?? null;
66
66
  }
67
- async askForToggle(e, t, r) {
68
- return (await b({
67
+ async askForToggle(t, e, i) {
68
+ return (await y({
69
69
  type: "toggle",
70
70
  name: "value",
71
- message: e,
72
- initial: t,
73
- ...r
71
+ message: t,
72
+ initial: e,
73
+ ...i
74
74
  }))?.value ?? null;
75
75
  }
76
- async askForSelect(e, t, r) {
77
- if (t.length === 0)
76
+ async askForSelect(t, e, i) {
77
+ if (e.length === 0)
78
78
  throw new Error("No options provided");
79
- const s = [];
80
- for (const o of t)
81
- typeof o == "string" ? s.push({ title: o, value: o }) : s.push(o);
82
- return (await b({
79
+ const n = [];
80
+ for (const o of e)
81
+ typeof o == "string" ? n.push({ title: o, value: o }) : n.push(o);
82
+ return (await y({
83
83
  type: "select",
84
84
  name: "value",
85
- message: e,
86
- choices: s,
87
- ...r
85
+ message: t,
86
+ choices: n,
87
+ ...i
88
88
  }))?.value ?? null;
89
89
  }
90
- newLoader(e = "", t = ["⠙", "⠘", "⠰", "⠴", "⠤", "⠦", "⠆", "⠃", "⠋", "⠉"], r = 100) {
91
- let s = e, i = null, o = 0;
92
- const u = setInterval(function() {
93
- i && (process.stdout.write(new TextEncoder().encode("\r" + " ".repeat(i.length + 5) + "\r")), i = null), process.stdout.write(new TextEncoder().encode("\r" + t[o++] + " " + s)), o = o % t.length;
94
- }, r), m = () => {
95
- clearInterval(u), process.stdout.write(new TextEncoder().encode("\r" + " ".repeat(s.length + 5) + "\r"));
90
+ newLoader(t = "", e = ["⠙", "⠘", "⠰", "⠴", "⠤", "⠦", "⠆", "⠃", "⠋", "⠉"], i = 100) {
91
+ let n = t, s = null, o = 0;
92
+ const m = setInterval(function() {
93
+ s && (process.stdout.write(new TextEncoder().encode("\r" + " ".repeat(s.length + 5) + "\r")), s = null), process.stdout.write(new TextEncoder().encode("\r" + e[o++] + " " + n)), o = o % e.length;
94
+ }, i), u = () => {
95
+ clearInterval(m), process.stdout.write(new TextEncoder().encode("\r" + " ".repeat(n.length + 5) + "\r"));
96
96
  };
97
97
  return {
98
- [Symbol.dispose]: m,
99
- [Symbol.asyncDispose]: m,
98
+ [Symbol.dispose]: u,
99
+ [Symbol.asyncDispose]: u,
100
100
  updateText: (h) => {
101
- i = s, s = h;
101
+ s = n, n = h;
102
102
  },
103
- stop: m
103
+ stop: u
104
104
  };
105
105
  }
106
106
  }
107
- const F = 10, L = (n = 0) => (e) => `\x1B[${e + n}m`, M = (n = 0) => (e) => `\x1B[${38 + n};5;${e}m`, V = (n = 0) => (e, t, r) => `\x1B[${38 + n};2;${e};${t};${r}m`, c = {
108
- modifier: {
109
- reset: [0, 0],
110
- // 21 isn't widely supported and 22 does the same thing
111
- bold: [1, 22],
112
- dim: [2, 22],
113
- italic: [3, 23],
114
- underline: [4, 24],
115
- overline: [53, 55],
116
- inverse: [7, 27],
117
- hidden: [8, 28],
118
- strikethrough: [9, 29]
119
- },
120
- color: {
121
- black: [30, 39],
122
- red: [31, 39],
123
- green: [32, 39],
124
- yellow: [33, 39],
125
- blue: [34, 39],
126
- magenta: [35, 39],
127
- cyan: [36, 39],
128
- white: [37, 39],
129
- // Bright color
130
- blackBright: [90, 39],
131
- gray: [90, 39],
132
- // Alias of `blackBright`
133
- grey: [90, 39],
134
- // Alias of `blackBright`
135
- redBright: [91, 39],
136
- greenBright: [92, 39],
137
- yellowBright: [93, 39],
138
- blueBright: [94, 39],
139
- magentaBright: [95, 39],
140
- cyanBright: [96, 39],
141
- whiteBright: [97, 39]
142
- },
143
- bgColor: {
144
- bgBlack: [40, 49],
145
- bgRed: [41, 49],
146
- bgGreen: [42, 49],
147
- bgYellow: [43, 49],
148
- bgBlue: [44, 49],
149
- bgMagenta: [45, 49],
150
- bgCyan: [46, 49],
151
- bgWhite: [47, 49],
152
- // Bright color
153
- bgBlackBright: [100, 49],
154
- bgGray: [100, 49],
155
- // Alias of `bgBlackBright`
156
- bgGrey: [100, 49],
157
- // Alias of `bgBlackBright`
158
- bgRedBright: [101, 49],
159
- bgGreenBright: [102, 49],
160
- bgYellowBright: [103, 49],
161
- bgBlueBright: [104, 49],
162
- bgMagentaBright: [105, 49],
163
- bgCyanBright: [106, 49],
164
- bgWhiteBright: [107, 49]
165
- }
166
- };
167
- Object.keys(c.modifier);
168
- const te = Object.keys(c.color), re = Object.keys(c.bgColor);
169
- [...te, ...re];
170
- function ne() {
171
- const n = /* @__PURE__ */ new Map();
172
- for (const [e, t] of Object.entries(c)) {
173
- for (const [r, s] of Object.entries(t))
174
- c[r] = {
175
- open: `\x1B[${s[0]}m`,
176
- close: `\x1B[${s[1]}m`
177
- }, t[r] = c[r], n.set(s[0], s[1]);
178
- Object.defineProperty(c, e, {
179
- value: t,
180
- enumerable: !1
181
- });
182
- }
183
- return Object.defineProperty(c, "codes", {
184
- value: n,
185
- enumerable: !1
186
- }), c.color.close = "\x1B[39m", c.bgColor.close = "\x1B[49m", c.color.ansi = L(), c.color.ansi256 = M(), c.color.ansi16m = V(), c.bgColor.ansi = L(F), c.bgColor.ansi256 = M(F), c.bgColor.ansi16m = V(F), Object.defineProperties(c, {
187
- rgbToAnsi256: {
188
- value(e, t, r) {
189
- return e === t && t === r ? e < 8 ? 16 : e > 248 ? 231 : Math.round((e - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(e / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(r / 255 * 5);
190
- },
191
- enumerable: !1
192
- },
193
- hexToRgb: {
194
- value(e) {
195
- const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));
196
- if (!t)
197
- return [0, 0, 0];
198
- let [r] = t;
199
- r.length === 3 && (r = [...r].map((i) => i + i).join(""));
200
- const s = Number.parseInt(r, 16);
201
- return [
202
- /* eslint-disable no-bitwise */
203
- s >> 16 & 255,
204
- s >> 8 & 255,
205
- s & 255
206
- /* eslint-enable no-bitwise */
207
- ];
208
- },
209
- enumerable: !1
210
- },
211
- hexToAnsi256: {
212
- value: (e) => c.rgbToAnsi256(...c.hexToRgb(e)),
213
- enumerable: !1
214
- },
215
- ansi256ToAnsi: {
216
- value(e) {
217
- if (e < 8)
218
- return 30 + e;
219
- if (e < 16)
220
- return 90 + (e - 8);
221
- let t, r, s;
222
- if (e >= 232)
223
- t = ((e - 232) * 10 + 8) / 255, r = t, s = t;
224
- else {
225
- e -= 16;
226
- const u = e % 36;
227
- t = Math.floor(e / 36) / 5, r = Math.floor(u / 6) / 5, s = u % 6 / 5;
228
- }
229
- const i = Math.max(t, r, s) * 2;
230
- if (i === 0)
231
- return 30;
232
- let o = 30 + (Math.round(s) << 2 | Math.round(r) << 1 | Math.round(t));
233
- return i === 2 && (o += 60), o;
234
- },
235
- enumerable: !1
236
- },
237
- rgbToAnsi: {
238
- value: (e, t, r) => c.ansi256ToAnsi(c.rgbToAnsi256(e, t, r)),
239
- enumerable: !1
240
- },
241
- hexToAnsi: {
242
- value: (e) => c.ansi256ToAnsi(c.hexToAnsi256(e)),
243
- enumerable: !1
244
- }
245
- }), c;
246
- }
247
- const f = ne(), q = (() => {
248
- if (!("navigator" in globalThis))
249
- return 0;
250
- if (globalThis.navigator.userAgentData) {
251
- const n = navigator.userAgentData.brands.find(({ brand: e }) => e === "Chromium");
252
- if (n && n.version > 93)
253
- return 3;
254
- }
255
- return /\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent) ? 1 : 0;
256
- })(), D = q !== 0 && {
257
- level: q
258
- }, se = {
259
- stdout: D,
260
- stderr: D
261
- };
262
- function ie(n, e, t) {
263
- let r = n.indexOf(e);
264
- if (r === -1)
265
- return n;
266
- const s = e.length;
267
- let i = 0, o = "";
268
- do
269
- o += n.slice(i, r) + e + t, i = r + s, r = n.indexOf(e, i);
270
- while (r !== -1);
271
- return o += n.slice(i), o;
107
+ class f extends Error {
272
108
  }
273
- function oe(n, e, t, r) {
274
- let s = 0, i = "";
275
- do {
276
- const o = n[r - 1] === "\r";
277
- i += n.slice(s, o ? r - 1 : r) + e + (o ? `\r
278
- ` : `
279
- `) + t, s = r + 1, r = n.indexOf(`
280
- `, s);
281
- } while (r !== -1);
282
- return i += n.slice(s), i;
109
+ function x(r) {
110
+ if (r === "string" || r === "number") return null;
111
+ if (r === "boolean") return !1;
112
+ if (Array.isArray(r) && r.length === 1) {
113
+ if (r[0] === "string") return [];
114
+ if (r[0] === "number") return [];
115
+ }
116
+ throw new Error("Invalid option type: " + r);
283
117
  }
284
- const { stdout: H, stderr: W } = se, S = Symbol("GENERATOR"), v = Symbol("STYLER"), C = Symbol("IS_EMPTY"), G = [
285
- "ansi",
286
- "ansi",
287
- "ansi256",
288
- "ansi16m"
289
- ], A = /* @__PURE__ */ Object.create(null), ae = (n, e = {}) => {
290
- if (e.level && !(Number.isInteger(e.level) && e.level >= 0 && e.level <= 3))
291
- throw new Error("The `level` option should be an integer from 0 to 3");
292
- const t = H ? H.level : 0;
293
- n.level = e.level === void 0 ? t : e.level;
294
- }, le = (n) => {
295
- const e = (...t) => t.join(" ");
296
- return ae(e, n), Object.setPrototypeOf(e, O.prototype), e;
297
- };
298
- function O(n) {
299
- return le(n);
118
+ function E(r) {
119
+ return typeof r == "string" || Array.isArray(r) ? x(r) : r.default !== void 0 ? r.default : x(r.type);
300
120
  }
301
- Object.setPrototypeOf(O.prototype, Function.prototype);
302
- for (const [n, e] of Object.entries(f))
303
- A[n] = {
304
- get() {
305
- const t = R(this, N(e.open, e.close, this[v]), this[C]);
306
- return Object.defineProperty(this, n, { value: t }), t;
307
- }
308
- };
309
- A.visible = {
310
- get() {
311
- const n = R(this, this[v], !0);
312
- return Object.defineProperty(this, "visible", { value: n }), n;
313
- }
314
- };
315
- const T = (n, e, t, ...r) => n === "rgb" ? e === "ansi16m" ? f[t].ansi16m(...r) : e === "ansi256" ? f[t].ansi256(f.rgbToAnsi256(...r)) : f[t].ansi(f.rgbToAnsi(...r)) : n === "hex" ? T("rgb", e, t, ...f.hexToRgb(...r)) : f[t][n](...r), ue = ["rgb", "hex", "ansi256"];
316
- for (const n of ue) {
317
- A[n] = {
318
- get() {
319
- const { level: t } = this;
320
- return function(...r) {
321
- const s = N(T(n, G[t], "color", ...r), f.color.close, this[v]);
322
- return R(this, s, this[C]);
323
- };
324
- }
325
- };
326
- const e = "bg" + n[0].toUpperCase() + n.slice(1);
327
- A[e] = {
328
- get() {
329
- const { level: t } = this;
330
- return function(...r) {
331
- const s = N(T(n, G[t], "bgColor", ...r), f.bgColor.close, this[v]);
332
- return R(this, s, this[C]);
333
- };
334
- }
335
- };
336
- }
337
- const me = Object.defineProperties(() => {
338
- }, {
339
- ...A,
340
- level: {
341
- enumerable: !0,
342
- get() {
343
- return this[S].level;
344
- },
345
- set(n) {
346
- this[S].level = n;
347
- }
348
- }
349
- }), N = (n, e, t) => {
350
- let r, s;
351
- return t === void 0 ? (r = n, s = e) : (r = t.openAll + n, s = e + t.closeAll), {
352
- open: n,
353
- close: e,
354
- openAll: r,
355
- closeAll: s,
356
- parent: t
357
- };
358
- }, R = (n, e, t) => {
359
- const r = (...s) => de(r, s.length === 1 ? "" + s[0] : s.join(" "));
360
- return Object.setPrototypeOf(r, me), r[S] = n, r[v] = e, r[C] = t, r;
361
- }, de = (n, e) => {
362
- if (n.level <= 0 || !e)
363
- return n[C] ? "" : e;
364
- let t = n[v];
365
- if (t === void 0)
366
- return e;
367
- const { openAll: r, closeAll: s } = t;
368
- if (e.includes("\x1B"))
369
- for (; t !== void 0; )
370
- e = ie(e, t.close, t.open), t = t.parent;
371
- const i = e.indexOf(`
372
- `);
373
- return i !== -1 && (e = oe(e, s, r, i)), r + e + s;
374
- };
375
- Object.defineProperties(O.prototype, A);
376
- const a = O();
377
- O({ level: W ? W.level : 0 });
378
- class w extends Error {
379
- }
380
- function _(n) {
381
- if (n === "string" || n === "number") return null;
382
- if (n === "boolean") return !1;
383
- if (Array.isArray(n) && n.length === 1) {
384
- if (n[0] === "string") return [];
385
- if (n[0] === "number") return [];
386
- }
387
- throw new Error("Invalid option type: " + n);
388
- }
389
- function U(n) {
390
- return typeof n == "string" || Array.isArray(n) ? _(n) : n.default !== void 0 ? n.default : _(n.type);
391
- }
392
- function y(n) {
393
- return typeof n == "string" || Array.isArray(n) ? {
121
+ function g(r) {
122
+ return typeof r == "string" || Array.isArray(r) ? {
394
123
  alias: [],
395
- default: U(n),
124
+ default: E(r),
396
125
  description: "",
397
126
  required: !1,
398
127
  secret: !1,
399
- type: n,
128
+ type: r,
400
129
  variadic: !1
401
130
  } : {
402
- alias: n.alias ? Array.isArray(n.alias) ? n.alias : [n.alias] : [],
403
- default: n.default ?? U(n.type),
404
- description: n.description ?? "",
405
- required: n.required ?? !1,
406
- secret: n.secret ?? !1,
407
- type: n.type,
408
- variadic: n.variadic ?? !1
131
+ alias: r.alias ? Array.isArray(r.alias) ? r.alias : [r.alias] : [],
132
+ default: r.default ?? E(r.type),
133
+ description: r.description ?? "",
134
+ required: r.required ?? !1,
135
+ secret: r.secret ?? !1,
136
+ type: r.type,
137
+ variadic: r.variadic ?? !1
409
138
  };
410
139
  }
411
- class k extends w {
412
- constructor(e, t = {}) {
413
- super(`Invalid option ${e} in not recognized`), this.option = e, this.optionsSchema = t;
414
- }
415
- pretty(e) {
416
- const t = Object.entries(this.optionsSchema);
417
- if (t.length > 0) {
418
- e.log(`
140
+ class b extends f {
141
+ constructor(t, e = {}) {
142
+ super(`Invalid option ${t} in not recognized`), this.option = t, this.optionsSchema = e;
143
+ }
144
+ pretty(t) {
145
+ const e = Object.entries(this.optionsSchema);
146
+ if (e.length > 0) {
147
+ t.log(`
419
148
  ${a.yellow("Available options")}:`);
420
- for (const [r, s] of t) {
421
- const i = y(s), o = typeof i.alias == "string" ? [i.alias] : i.alias, u = Array.isArray(i.type) ? `[${i.type[0]}]` : i.type, m = `--${r}${o.length > 0 ? o.map((l) => `, -${l}`).join("") : ""}`, h = " ".repeat(30 - m.length);
422
- e.log(` ${a.green(m)} ${h} ${i.description || "\b"} ${a.white(`(${u})`)}`);
149
+ for (const [i, n] of e) {
150
+ const s = g(n), o = typeof s.alias == "string" ? [s.alias] : s.alias, m = Array.isArray(s.type) ? `[${s.type[0]}]` : s.type, u = `--${i}${o.length > 0 ? o.map((l) => `, -${l}`).join("") : ""}`, h = " ".repeat(30 - u.length);
151
+ t.log(` ${a.green(u)} ${h} ${s.description || "\b"} ${a.white(`(${m})`)}`);
423
152
  }
424
- e.log("");
153
+ t.log("");
425
154
  }
426
- e.log(`${a.white.bgRed(" ERROR ")} Option ${a.bold.yellow(this.option)} is not recognized.`);
155
+ t.log(`${a.white.bgRed(" ERROR ")} Option ${a.bold.yellow(this.option)} is not recognized.`);
427
156
  }
428
157
  }
429
- class Y extends w {
430
- constructor(e) {
431
- super(`Argument "${e}" is required.`), this.argument = e;
158
+ class F extends f {
159
+ constructor(t) {
160
+ super(`Argument "${t}" is required.`), this.argument = t;
432
161
  }
433
- pretty(e) {
434
- e.log(`${a.white.bgRed(" ERROR ")} Argument ${a.bold.yellow(this.argument)} is required.`);
162
+ pretty(t) {
163
+ t.log(`${a.white.bgRed(" ERROR ")} Argument ${a.bold.yellow(this.argument)} is required.`);
435
164
  }
436
165
  }
437
- class ce extends w {
438
- constructor(e) {
439
- super(`Argument "${e}" is required.`), this.option = e;
166
+ class V extends f {
167
+ constructor(t) {
168
+ super(`Argument "${t}" is required.`), this.option = t;
440
169
  }
441
- pretty(e) {
442
- e.log(`${a.white.bgRed(" ERROR ")} Option ${a.bold.yellow(this.option)} is required.`);
170
+ pretty(t) {
171
+ t.log(`${a.white.bgRed(" ERROR ")} Option ${a.bold.yellow(this.option)} is required.`);
443
172
  }
444
173
  }
445
- class Ae extends w {
446
- constructor(e) {
447
- let t = `Argument "${e.param}" value is invalid.`;
448
- e.reason ? t += ` Reason: ${e.reason}` : t += ` Value: "${e.value}"`, super(t), this.param = e;
174
+ class U extends f {
175
+ constructor(t) {
176
+ let e = `Argument "${t.param}" value is invalid.`;
177
+ t.reason ? e += ` Reason: ${t.reason}` : e += ` Value: "${t.value}"`, super(e), this.param = t;
449
178
  }
450
- pretty(e) {
451
- e.log(` ${a.white.bgRed(" ERROR ")} Argument ${a.bold.yellow(this.param.param)} value is invalid. `), (this.param.value || this.param.reason) && e.log(""), this.param.value && e.log(` ${a.blue("Value")}: ${this.param.value}`), this.param.reason && e.log(` ${a.yellow("Reason")}: ${this.param.reason}`);
179
+ pretty(t) {
180
+ t.log(` ${a.white.bgRed(" ERROR ")} Argument ${a.bold.yellow(this.param.param)} value is invalid. `), (this.param.value || this.param.reason) && t.log(""), this.param.value && t.log(` ${a.blue("Value")}: ${this.param.value}`), this.param.reason && t.log(` ${a.yellow("Reason")}: ${this.param.reason}`);
452
181
  }
453
182
  }
454
- class B extends w {
455
- constructor(e) {
456
- let t = `Option "${e.option}" value is invalid.`;
457
- e.reason ? t += ` Reason: ${e.reason}` : t += ` Value: "${e.value}"`, super(t), this.param = e;
183
+ class C extends f {
184
+ constructor(t) {
185
+ let e = `Option "${t.option}" value is invalid.`;
186
+ t.reason ? e += ` Reason: ${t.reason}` : e += ` Value: "${t.value}"`, super(e), this.param = t;
458
187
  }
459
- pretty(e) {
460
- e.log(` ${a.white.bgRed(" ERROR ")} Option ${a.bold.yellow(this.param.option)} value is invalid. `), (this.param.value || this.param.reason) && e.log(""), this.param.value && e.log(` ${a.blue("Value")}: ${this.param.value}`), this.param.reason && e.log(` ${a.yellow("Reason")}: ${this.param.reason}`);
188
+ pretty(t) {
189
+ t.log(` ${a.white.bgRed(" ERROR ")} Option ${a.bold.yellow(this.param.option)} value is invalid. `), (this.param.value || this.param.reason) && t.log(""), this.param.value && t.log(` ${a.blue("Value")}: ${this.param.value}`), this.param.reason && t.log(` ${a.yellow("Reason")}: ${this.param.reason}`);
461
190
  }
462
191
  }
463
- class he extends w {
464
- constructor(e) {
465
- super(`Command "${e}" not found.`), this.command = e;
192
+ class P extends f {
193
+ constructor(t) {
194
+ super(`Command "${t}" not found.`), this.command = t;
466
195
  }
467
- pretty(e) {
468
- e.log(`${a.bgRed(" ERROR ")} Command ${a.yellow(this.command)} not found.`);
196
+ pretty(t) {
197
+ t.log(`${a.bgRed(" ERROR ")} Command ${a.yellow(this.command)} not found.`);
469
198
  }
470
199
  }
471
- function $(n, e, t, r) {
472
- if (n == null)
473
- return r ?? null;
474
- if (e === "string")
475
- return String(n);
476
- if (e === "number") {
477
- const s = Number(n);
478
- if (isNaN(s))
479
- throw new B({
480
- option: t,
481
- reason: `Expected a number, got "${n}"`
200
+ function w(r, t, e, i) {
201
+ if (r == null)
202
+ return i ?? null;
203
+ if (t === "string")
204
+ return String(r);
205
+ if (t === "number") {
206
+ const n = Number(r);
207
+ if (isNaN(n))
208
+ throw new C({
209
+ option: e,
210
+ reason: `Expected a number, got "${r}"`
482
211
  });
483
- return s;
484
- }
485
- if (e === "boolean")
486
- return typeof n == "boolean" ? n : n === "true" || n === "1" ? !0 : n === "false" || n === "0" ? !1 : !!n;
487
- if (Array.isArray(e)) {
488
- const s = e[0], i = Array.isArray(n) ? n : [n];
489
- if (s === "string")
490
- return i.map((o) => String(o));
491
- if (s === "number")
492
- return i.map((o) => {
493
- const u = Number(o);
494
- if (isNaN(u))
495
- throw new B({
496
- option: t,
212
+ return n;
213
+ }
214
+ if (t === "boolean")
215
+ return typeof r == "boolean" ? r : r === "true" || r === "1" ? !0 : r === "false" || r === "0" ? !1 : !!r;
216
+ if (Array.isArray(t)) {
217
+ const n = t[0], s = Array.isArray(r) ? r : [r];
218
+ if (n === "string")
219
+ return s.map((o) => String(o));
220
+ if (n === "number")
221
+ return s.map((o) => {
222
+ const m = Number(o);
223
+ if (isNaN(m))
224
+ throw new C({
225
+ option: e,
497
226
  reason: `Expected array of numbers, got "${o}" in array`
498
227
  });
499
- return u;
228
+ return m;
500
229
  });
501
230
  }
502
- return n;
231
+ return r;
503
232
  }
504
- class J {
233
+ class k {
505
234
  options;
506
235
  parsedOptions = null;
507
236
  arguments;
508
237
  parsedArguments = null;
509
238
  io;
510
239
  shouldPromptForMissingOptions = !0;
511
- constructor(e) {
512
- this.options = e.options, this.arguments = e.arguments, this.io = e.io;
240
+ constructor(t) {
241
+ this.options = t.options, this.arguments = t.arguments, this.io = t.io;
513
242
  }
514
243
  // === PUBLIC METHODS ===
515
244
  /**
@@ -519,9 +248,9 @@ class J {
519
248
  * @throws {InvalidOption} If an naan option is provided
520
249
  * @throws {BadCommandOption} If a value cannot be converted to the expected type
521
250
  */
522
- init(e) {
523
- const { _: t, ...r } = X(e);
524
- return this.validateUnknownOptions(r), this.parsedOptions = this.handleOptions(r), this.parsedArguments = this.handleArguments(t), {
251
+ init(t) {
252
+ const { _: e, ...i } = q(t);
253
+ return this.validateUnknownOptions(i), this.parsedOptions = this.handleOptions(i), this.parsedArguments = this.handleArguments(e), {
525
254
  options: this.parsedOptions,
526
255
  arguments: this.parsedArguments
527
256
  };
@@ -531,30 +260,30 @@ class J {
531
260
  * @throws {Error} If validation fails
532
261
  */
533
262
  async validate() {
534
- for (const e in this.options)
535
- if (y(this.options[e]).required && (this.parsedOptions?.[e] === void 0 || this.parsedOptions?.[e] === null))
536
- throw new ce(e);
537
- for (const e in this.arguments) {
538
- const t = y(this.arguments[e]), r = this.parsedArguments?.[e];
539
- if (t.required && r == null) {
263
+ for (const t in this.options)
264
+ if (g(this.options[t]).required && (this.parsedOptions?.[t] === void 0 || this.parsedOptions?.[t] === null))
265
+ throw new V(t);
266
+ for (const t in this.arguments) {
267
+ const e = g(this.arguments[t]), i = this.parsedArguments?.[t];
268
+ if (e.required && i == null) {
540
269
  if (this.shouldPromptForMissingOptions) {
541
- const s = await this.promptForArgument(e, t);
542
- if (s && this.parsedArguments) {
543
- this.parsedArguments[e] = $(s, t.type, e);
270
+ const n = await this.promptForArgument(t, e);
271
+ if (n && this.parsedArguments) {
272
+ this.parsedArguments[t] = w(n, e.type, t);
544
273
  continue;
545
274
  }
546
275
  }
547
- throw new Y(e);
276
+ throw new F(t);
548
277
  }
549
- if (t.required && t.variadic && Array.isArray(r) && r.length === 0) {
278
+ if (e.required && e.variadic && Array.isArray(i) && i.length === 0) {
550
279
  if (this.shouldPromptForMissingOptions) {
551
- const s = await this.promptForArgument(e, t);
552
- if (s && this.parsedArguments) {
553
- this.parsedArguments[e] = $(s, t.type, e);
280
+ const n = await this.promptForArgument(t, e);
281
+ if (n && this.parsedArguments) {
282
+ this.parsedArguments[t] = w(n, e.type, t);
554
283
  continue;
555
284
  }
556
285
  }
557
- throw new Y(e);
286
+ throw new F(t);
558
287
  }
559
288
  }
560
289
  }
@@ -565,17 +294,17 @@ class J {
565
294
  * @returns The typed option value
566
295
  * @throws {Error} If init() has not been called yet
567
296
  */
568
- option(e, t) {
297
+ option(t, e) {
569
298
  if (!this.parsedOptions)
570
299
  throw new Error("Options have not been parsed yet. Call init() first.");
571
- return this.isEmptyValue(this.parsedOptions[e]) && t !== void 0 ? t : this.parsedOptions[e];
300
+ return this.isEmptyValue(this.parsedOptions[t]) && e !== void 0 ? e : this.parsedOptions[t];
572
301
  }
573
- setOption(e, t) {
302
+ setOption(t, e) {
574
303
  if (!this.parsedOptions)
575
304
  throw new Error("Options have not been parsed yet. Call init() first.");
576
- if (!(e in this.options))
577
- throw new k(e, this.options);
578
- this.parsedOptions[e] = t;
305
+ if (!(t in this.options))
306
+ throw new b(t, this.options);
307
+ this.parsedOptions[t] = e;
579
308
  }
580
309
  /**
581
310
  * Retrieves a parsed argument value by name
@@ -584,17 +313,17 @@ class J {
584
313
  * @returns The typed argument value
585
314
  * @throws {Error} If init() has not been called yet
586
315
  */
587
- argument(e, t) {
316
+ argument(t, e) {
588
317
  if (!this.parsedArguments)
589
318
  throw new Error("Arguments have not been parsed yet. Call init() first.");
590
- return this.isEmptyValue(this.parsedArguments[e]) && t !== void 0 ? t : this.parsedArguments[e];
319
+ return this.isEmptyValue(this.parsedArguments[t]) && e !== void 0 ? e : this.parsedArguments[t];
591
320
  }
592
- setArgument(e, t) {
321
+ setArgument(t, e) {
593
322
  if (!this.parsedArguments)
594
323
  throw new Error("Arguments have not been parsed yet. Call init() first.");
595
- if (!(e in this.arguments))
596
- throw new k(e, this.arguments);
597
- this.parsedArguments[e] = t;
324
+ if (!(t in this.arguments))
325
+ throw new b(t, this.arguments);
326
+ this.parsedArguments[t] = e;
598
327
  }
599
328
  // === PRIVATE HELPERS ===
600
329
  /**
@@ -602,97 +331,97 @@ class J {
602
331
  * @param value - The value to check
603
332
  * @returns true if the value is null, undefined, or an empty array
604
333
  */
605
- isEmptyValue(e) {
606
- return e == null || Array.isArray(e) && e.length === 0;
334
+ isEmptyValue(t) {
335
+ return t == null || Array.isArray(t) && t.length === 0;
607
336
  }
608
337
  /**
609
338
  * Validates that all provided options are recognized
610
339
  * @throws {InvalidOption} If an unknown option is found
611
340
  */
612
- validateUnknownOptions(e) {
613
- const t = /* @__PURE__ */ new Set();
614
- for (const r in this.options) {
615
- t.add(r);
616
- const s = y(this.options[r]);
617
- for (const i of s.alias)
618
- t.add(i);
341
+ validateUnknownOptions(t) {
342
+ const e = /* @__PURE__ */ new Set();
343
+ for (const i in this.options) {
344
+ e.add(i);
345
+ const n = g(this.options[i]);
346
+ for (const s of n.alias)
347
+ e.add(s);
619
348
  }
620
- for (const r in e)
621
- if (!t.has(r))
622
- throw new k(r, this.options);
349
+ for (const i in t)
350
+ if (!e.has(i))
351
+ throw new b(i, this.options);
623
352
  }
624
353
  /**
625
354
  * Processes named options from minimist output
626
355
  */
627
- handleOptions(e) {
628
- const t = {};
629
- for (const r in this.options) {
630
- const s = y(this.options[r]);
631
- t[r] = this.resolveOptionValue(r, s, e);
356
+ handleOptions(t) {
357
+ const e = {};
358
+ for (const i in this.options) {
359
+ const n = g(this.options[i]);
360
+ e[i] = this.resolveOptionValue(i, n, t);
632
361
  }
633
- return t;
362
+ return e;
634
363
  }
635
364
  /**
636
365
  * Processes positional arguments from minimist output
637
366
  */
638
- handleArguments(e) {
639
- const t = {}, r = [...e];
640
- for (const s in this.arguments) {
641
- const i = y(this.arguments[s]);
642
- if (i.variadic) {
643
- t[s] = this.handleVariadicArgument(s, i, r);
367
+ handleArguments(t) {
368
+ const e = {}, i = [...t];
369
+ for (const n in this.arguments) {
370
+ const s = g(this.arguments[n]);
371
+ if (s.variadic) {
372
+ e[n] = this.handleVariadicArgument(n, s, i);
644
373
  continue;
645
374
  }
646
- t[s] = this.resolveArgumentValue(s, i, r.shift());
375
+ e[n] = this.resolveArgumentValue(n, s, i.shift());
647
376
  }
648
- return t;
377
+ return e;
649
378
  }
650
379
  /**
651
380
  * Handles variadic arguments that consume all remaining positional values
652
381
  */
653
- handleVariadicArgument(e, t, r) {
654
- return r.length ? $(r, t.type, e, t.default) : t.default;
382
+ handleVariadicArgument(t, e, i) {
383
+ return i.length ? w(i, e.type, t, e.default) : e.default;
655
384
  }
656
385
  /**
657
386
  * Resolves a single positional argument value with defaults and type conversion
658
387
  * Note: Does not validate required arguments - validation happens in subclass validate() methods
659
388
  */
660
- resolveArgumentValue(e, t, r) {
661
- return r === void 0 ? t.default : $(r, t.type, e, t.default);
389
+ resolveArgumentValue(t, e, i) {
390
+ return i === void 0 ? e.default : w(i, e.type, t, e.default);
662
391
  }
663
392
  /**
664
393
  * Resolves an option value from the parsed option values object
665
394
  * Handles alias resolution, defaults, and type conversion
666
395
  */
667
- resolveOptionValue(e, t, r) {
668
- let s;
669
- const i = [e, ...t.alias];
670
- for (const o of i)
671
- if (o in r) {
672
- s = r[o];
396
+ resolveOptionValue(t, e, i) {
397
+ let n;
398
+ const s = [t, ...e.alias];
399
+ for (const o of s)
400
+ if (o in i) {
401
+ n = i[o];
673
402
  break;
674
403
  }
675
- if (s === void 0) {
676
- if (t.required)
677
- throw new B({
678
- option: e,
404
+ if (n === void 0) {
405
+ if (e.required)
406
+ throw new C({
407
+ option: t,
679
408
  reason: "Required option is missing"
680
409
  });
681
- return t.default;
410
+ return e.default;
682
411
  }
683
- return $(s, t.type, e, t.default);
412
+ return w(n, e.type, t, e.default);
684
413
  }
685
414
  optionDefinitions() {
686
- const e = {};
687
- for (const t in this.options)
688
- e[t] = y(this.options[t]);
689
- return e;
415
+ const t = {};
416
+ for (const e in this.options)
417
+ t[e] = g(this.options[e]);
418
+ return t;
690
419
  }
691
420
  argumentDefinitions() {
692
- const e = {};
693
- for (const t in this.arguments)
694
- e[t] = y(this.arguments[t]);
695
- return e;
421
+ const t = {};
422
+ for (const e in this.arguments)
423
+ t[e] = g(this.arguments[e]);
424
+ return t;
696
425
  }
697
426
  availableOptions() {
698
427
  return Object.keys(this.options);
@@ -714,89 +443,89 @@ class J {
714
443
  * @param argDef - The argument's definition for type and description
715
444
  * @returns The user-provided value, or null if none given
716
445
  */
717
- async promptForArgument(e, t) {
718
- if (!Array.isArray(t.type) && !["string", "number", "secret"].includes(t.type))
446
+ async promptForArgument(t, e) {
447
+ if (!Array.isArray(e.type) && !["string", "number", "secret"].includes(e.type))
719
448
  return null;
720
- let r = `${a.yellow.bold(e)} is required`;
721
- return t.description && (r += `: ${a.gray(`(${t.description})`)}`), r += ` ${a.green(`(${t.type}${t.variadic == !0 ? "[]" : ""})`)}
722
- `, Array.isArray(t.type) ? (r += `Please provide one or more values, separated by commas:
723
- `, await this.io.askForList(r, void 0, {
449
+ let i = `${a.yellow.bold(t)} is required`;
450
+ return e.description && (i += `: ${a.gray(`(${e.description})`)}`), i += ` ${a.green(`(${e.type}${e.variadic == !0 ? "[]" : ""})`)}
451
+ `, Array.isArray(e.type) ? (i += `Please provide one or more values, separated by commas:
452
+ `, await this.io.askForList(i, void 0, {
724
453
  separator: ",",
725
- validate: (s) => {
726
- if (!s.length)
454
+ validate: (n) => {
455
+ if (!n.length)
727
456
  return "Please enter at least one value";
728
- if (t.type[0] === "number") {
729
- for (const i of s.split(","))
730
- if (isNaN(Number(i)))
457
+ if (e.type[0] === "number") {
458
+ for (const s of n.split(","))
459
+ if (isNaN(Number(s)))
731
460
  return "Please enter only valid numbers";
732
461
  }
733
462
  return !0;
734
463
  }
735
- })) : await this.io.askForInput(r, void 0, {
736
- type: t.type === "number" ? "number" : t.secret ? "password" : "text",
737
- validate: (s) => {
738
- if (s == null || typeof s == "string" && !s.length)
464
+ })) : await this.io.askForInput(i, void 0, {
465
+ type: e.type === "number" ? "number" : e.secret ? "password" : "text",
466
+ validate: (n) => {
467
+ if (n == null || typeof n == "string" && !n.length)
739
468
  return "This value is required";
740
- if (t.type === "number") {
741
- const i = Number(s);
742
- if (isNaN(i))
469
+ if (e.type === "number") {
470
+ const s = Number(n);
471
+ if (isNaN(s))
743
472
  return "Please enter a valid number";
744
- } else if (t.type === "string" && (typeof s != "string" || !s.length))
473
+ } else if (e.type === "string" && (typeof n != "string" || !n.length))
745
474
  return "Please enter a valid text";
746
475
  return !0;
747
476
  }
748
477
  });
749
478
  }
750
479
  }
751
- function j(n) {
752
- return new Array(n + 5).join(" ");
480
+ function A(r) {
481
+ return new Array(r + 5).join(" ");
753
482
  }
754
- class pe {
483
+ class D {
755
484
  type = "boolean";
756
485
  option = "help";
757
486
  alias = ["h"];
758
487
  default = !1;
759
488
  description = `Display help for the given command. When no command is given display help for the ${a.green("list")} command`;
760
489
  async handler() {
761
- const e = this.parser.argumentDefinitions(), t = this.parser.optionDefinitions(), r = Object.entries(e), s = Object.entries(t), i = s.map(([l, d]) => {
762
- const p = Array.isArray(d.alias) ? d.alias : d.alias ? [d.alias] : [];
490
+ const t = this.parser.argumentDefinitions(), e = this.parser.optionDefinitions(), i = Object.entries(t), n = Object.entries(e), s = n.map(([l, d]) => {
491
+ const c = Array.isArray(d.alias) ? d.alias : d.alias ? [d.alias] : [];
763
492
  return {
764
493
  name: l,
765
494
  ...d,
766
- optionWithAlias: `--${l}${p.map((g) => `, -${g}`).join("")}`
495
+ optionWithAlias: `--${l}${c.map((p) => `, -${p}`).join("")}`
767
496
  };
768
- }), o = r.filter(([, l]) => l.required);
497
+ }), o = i.filter(([, l]) => l.required);
769
498
  this.io.log(a.yellow("Description:")), this.io.log(` ${this.description}
770
499
  `), this.io.log(a.yellow("Usage:")), this.io.log(` ${this.command} ${o.length > 0 ? o.map(([l]) => `<${l}>`).join(" ") : "\b"} [options]`);
771
- const u = Math.max(...i.map((l) => l.optionWithAlias.length), 0), m = Math.max(...r.map(([l]) => l.length), 0), h = m > u ? m : u;
772
- if (r.length > 0) {
500
+ const m = Math.max(...s.map((l) => l.optionWithAlias.length), 0), u = Math.max(...i.map(([l]) => l.length), 0), h = u > m ? u : m;
501
+ if (i.length > 0) {
773
502
  this.io.log(`
774
503
  ${a.yellow("Arguments")}:`);
775
- for (const [l, d] of r) {
776
- const p = j(h - l.length);
777
- let g = ` ${a.green(l)} ${p} ${d.description ?? "\b"}`;
504
+ for (const [l, d] of i) {
505
+ const c = A(h - l.length);
506
+ let p = ` ${a.green(l)} ${c} ${d.description ?? "\b"}`;
778
507
  if (d.default !== void 0 && !d.required) {
779
- const Q = (Array.isArray(d.type) ? `[${d.type[0]}]` : d.type) === "array" || Array.isArray(d.type) ? JSON.stringify(d.default) : d.default;
780
- g += ` ${a.yellow(`[default: ${Q}]`)}`;
508
+ const L = (Array.isArray(d.type) ? `[${d.type[0]}]` : d.type) === "array" || Array.isArray(d.type) ? JSON.stringify(d.default) : d.default;
509
+ p += ` ${a.yellow(`[default: ${L}]`)}`;
781
510
  }
782
- d.variadic && (g += ` ${a.white("(variadic)")}`), this.io.log(g);
511
+ d.variadic && (p += ` ${a.white("(variadic)")}`), this.io.log(p);
783
512
  }
784
513
  }
785
- if (s.length > 0) {
514
+ if (n.length > 0) {
786
515
  this.io.log(`
787
516
  ${a.yellow("Options")}:`);
788
- for (const l of i) {
789
- const d = j(h - l.optionWithAlias.length);
790
- let p = `${a.green(l.optionWithAlias)} ${d} ${l.description ?? "\b"}`;
517
+ for (const l of s) {
518
+ const d = A(h - l.optionWithAlias.length);
519
+ let c = `${a.green(l.optionWithAlias)} ${d} ${l.description ?? "\b"}`;
791
520
  if (l.type) {
792
- const g = Array.isArray(l.type) ? `[${l.type[0]}]` : l.type;
793
- p += ` ${a.white(`(${g})`)}`;
521
+ const p = Array.isArray(l.type) ? `[${l.type[0]}]` : l.type;
522
+ c += ` ${a.white(`(${p})`)}`;
794
523
  }
795
524
  if (l.default !== void 0 && !l.required) {
796
- const P = (Array.isArray(l.type) ? `[${l.type[0]}]` : l.type) === "array" || Array.isArray(l.type) ? JSON.stringify(l.default) : l.default;
797
- p += ` ${a.yellow(`[default: ${P}]`)}`;
525
+ const O = (Array.isArray(l.type) ? `[${l.type[0]}]` : l.type) === "array" || Array.isArray(l.type) ? JSON.stringify(l.default) : l.default;
526
+ c += ` ${a.yellow(`[default: ${O}]`)}`;
798
527
  }
799
- this.io.log(p);
528
+ this.io.log(c);
800
529
  }
801
530
  }
802
531
  if (this.commandsExamples.length > 0) {
@@ -804,14 +533,14 @@ ${a.yellow("Options")}:`);
804
533
  ${a.yellow("Examples")}:`);
805
534
  let l = process.argv[0].split("/").pop();
806
535
  l === "node" && (l += " " + process.argv[1].split("/").pop());
807
- for (const [d, p] of this.commandsExamples.entries())
808
- d > 0 && this.io.log(""), this.io.log(` ${p.description}
809
- `), this.io.log(` ${a.green(`${l} ${p.command}`)}`);
536
+ for (const [d, c] of this.commandsExamples.entries())
537
+ d > 0 && this.io.log(""), this.io.log(` ${c.description}
538
+ `), this.io.log(` ${a.green(`${l} ${c.command}`)}`);
810
539
  }
811
540
  return -1;
812
541
  }
813
542
  }
814
- class x {
543
+ class v {
815
544
  _command;
816
545
  description;
817
546
  group;
@@ -828,125 +557,125 @@ class x {
828
557
  _handler;
829
558
  tmp;
830
559
  defaultOptions() {
831
- return [new pe()];
560
+ return [new D()];
832
561
  }
833
- newCommandParser(e) {
834
- return new J({
835
- io: e.io,
836
- options: e.options,
837
- arguments: e.arguments
562
+ newCommandParser(t) {
563
+ return new k({
564
+ io: t.io,
565
+ options: t.options,
566
+ arguments: t.arguments
838
567
  });
839
568
  }
840
- newCommandIO(e) {
841
- return new z(e.logger);
569
+ newCommandIO(t) {
570
+ return new S(t);
842
571
  }
843
- constructor(e, t) {
844
- this._command = e, this.description = t?.description ?? "", this.group = t?.group, this.tmp = {
845
- options: t?.options ?? {},
846
- arguments: t?.arguments ?? {}
572
+ constructor(t, e) {
573
+ this._command = t, this.description = e?.description ?? "", this.group = e?.group, this.tmp = {
574
+ options: e?.options ?? {},
575
+ arguments: e?.arguments ?? {}
847
576
  };
848
- const r = this.defaultOptions();
849
- if (r.length > 0)
850
- for (const s of r)
851
- this.tmp.options[s.option] = s;
577
+ const i = this.defaultOptions();
578
+ if (i.length > 0)
579
+ for (const n of i)
580
+ this.tmp.options[n.option] = n;
852
581
  }
853
582
  disablePrompting() {
854
583
  return this.disablePromptingFlag = !0, this;
855
584
  }
856
- preHandler(e) {
857
- return this._preHandler = e, this;
585
+ preHandler(t) {
586
+ return this._preHandler = t, this;
858
587
  }
859
- handler(e) {
860
- return this._handler = e, this;
588
+ handler(t) {
589
+ return this._handler = t, this;
861
590
  }
862
- options(e) {
591
+ options(t) {
863
592
  return this.tmp = {
864
593
  options: {
865
594
  ...this.tmp?.options ?? {},
866
- ...e
595
+ ...t
867
596
  },
868
597
  arguments: this.tmp?.arguments ?? {}
869
598
  }, this;
870
599
  }
871
- arguments(e) {
600
+ arguments(t) {
872
601
  return this.tmp = {
873
602
  options: this.tmp?.options ?? {},
874
603
  arguments: {
875
604
  ...this.tmp?.arguments ?? {},
876
- ...e
605
+ ...t
877
606
  }
878
607
  }, this;
879
608
  }
880
- async run(e) {
609
+ async run(t) {
881
610
  if (!this._handler && !this.handle)
882
611
  throw new Error(`No handler defined for command ${this.command || "(unknown)"}`);
883
- let t;
884
- if (this.ctx = e.ctx, this.logger = e.logger, this.io = this.newCommandIO({
885
- logger: e.logger
886
- }), e && "args" in e) {
887
- const i = this.tmp?.options ?? {};
612
+ let e;
613
+ if (this.ctx = t.ctx, this.logger = t.logger, this.io = this.newCommandIO({
614
+ logger: t.logger
615
+ }), t && "args" in t) {
616
+ const s = this.tmp?.options ?? {};
888
617
  for (const o of this.defaultOptions())
889
- o.option in i || (i[o.option] = o);
618
+ o.option in s || (s[o.option] = o);
890
619
  this.parser = this.newCommandParser({
891
620
  io: this.io,
892
- options: i,
621
+ options: s,
893
622
  arguments: this.tmp?.arguments ?? {}
894
- }), t = this.parser.init(e.args);
623
+ }), e = this.parser.init(t.args);
895
624
  for (const o of this.defaultOptions())
896
- if (t.options[o.option] === !0) {
897
- const u = await o.handler.call(this);
898
- if (u && u !== 0)
899
- return u;
625
+ if (e.options[o.option] === !0) {
626
+ const m = await o.handler.call(this);
627
+ if (m && m !== 0)
628
+ return m;
900
629
  }
901
630
  this.disablePromptingFlag && this.parser.disablePrompting(), await this.parser.validate();
902
631
  } else
903
- t = {
904
- options: e.options,
905
- arguments: e.arguments
632
+ e = {
633
+ options: t.options,
634
+ arguments: t.arguments
906
635
  };
907
- const r = this.preHandle ? await this.preHandle() : null;
908
- if (r && r !== 0)
909
- return r;
636
+ const i = this.preHandle ? await this.preHandle() : null;
637
+ if (i && i !== 0)
638
+ return i;
910
639
  if (!this._handler && this.handle)
911
640
  this._handler = this.handle.bind(this);
912
641
  else if (!this._handler)
913
642
  throw new Error(`No handler defined for command ${this.command || "(unknown)"}`);
914
- return await this._handler(e.ctx, t) ?? 0;
643
+ return await this._handler(t.ctx, e) ?? 0;
915
644
  }
916
645
  }
917
- class E extends J {
646
+ class $ extends k {
918
647
  command;
919
- constructor(e) {
920
- const t = E.parseSignature(e.signature, e.helperDefinitions, e.defaultOptions);
648
+ constructor(t) {
649
+ const e = $.parseSignature(t.signature, t.helperDefinitions, t.defaultOptions);
921
650
  super({
922
- io: e.io,
923
- options: t.options,
924
- arguments: t.arguments
925
- }), this.command = t.command;
651
+ io: t.io,
652
+ options: e.options,
653
+ arguments: e.arguments
654
+ }), this.command = e.command;
926
655
  }
927
656
  /**
928
657
  * Parses command signature string into command name and parameter schemas
929
658
  * Example: "migrate {name} {--force}" -> { command: "migrate", arguments: {name: ...}, options: {force: ...} }
930
659
  */
931
- static parseSignature(e, t, r) {
932
- const [s, ...i] = e.split(/\{(.*?)\}/g).map((m) => m.trim()).filter(Boolean), o = {}, u = {};
933
- for (const m of i) {
934
- const { name: h, isOption: l, definition: d } = E.parseParamSignature(m, t);
935
- l ? o[h] = d : u[h] = d;
660
+ static parseSignature(t, e, i) {
661
+ const [n, ...s] = t.split(/\{(.*?)\}/g).map((u) => u.trim()).filter(Boolean), o = {}, m = {};
662
+ for (const u of s) {
663
+ const { name: h, isOption: l, definition: d } = $.parseParamSignature(u, e);
664
+ l ? o[h] = d : m[h] = d;
936
665
  }
937
- for (const m of r)
938
- o[m.option] = {
939
- type: m.type,
940
- required: m.required,
941
- alias: m.alias,
942
- variadic: m.variadic ?? !1,
943
- description: m.description,
944
- default: m.default ?? null
666
+ for (const u of i)
667
+ o[u.option] = {
668
+ type: u.type,
669
+ required: u.required,
670
+ alias: u.alias,
671
+ variadic: u.variadic ?? !1,
672
+ description: u.description,
673
+ default: u.default ?? null
945
674
  };
946
675
  return {
947
- command: s,
676
+ command: n,
948
677
  options: o,
949
- arguments: u
678
+ arguments: m
950
679
  };
951
680
  }
952
681
  /**
@@ -963,38 +692,38 @@ class E extends J {
963
692
  * - {--opt=} -> string option
964
693
  * - {--opt|o} -> option with alias
965
694
  */
966
- static parseParamSignature(e, t) {
967
- let r = e, s = !1;
968
- const i = {
695
+ static parseParamSignature(t, e) {
696
+ let i = t, n = !1;
697
+ const s = {
969
698
  required: !0,
970
699
  type: "string",
971
700
  description: void 0,
972
701
  default: null,
973
702
  variadic: !1
974
703
  };
975
- if (r.includes(":")) {
976
- const [o, u] = r.split(":");
977
- r = o.trim(), i.description = u.trim();
704
+ if (i.includes(":")) {
705
+ const [o, m] = i.split(":");
706
+ i = o.trim(), s.description = m.trim();
978
707
  }
979
- if (r.includes("=")) {
980
- const [o, u] = r.split("=");
981
- r = o.trim(), i.default = u.trim(), i.required = !1, typeof i.default == "string" && !i.default.length ? i.default = null : i.default === "true" ? (i.default = !0, i.type = "boolean") : i.default === "false" && (i.default = !1, i.type = "boolean");
982
- } else r.startsWith("--") && (i.required = !1, i.default = !1, i.type = "boolean");
983
- if (r.includes("|")) {
984
- const [o, ...u] = r.split("|");
985
- r = o.trim(), i.alias = u.map((m) => m.trim());
708
+ if (i.includes("=")) {
709
+ const [o, m] = i.split("=");
710
+ i = o.trim(), s.default = m.trim(), s.required = !1, typeof s.default == "string" && !s.default.length ? s.default = null : s.default === "true" ? (s.default = !0, s.type = "boolean") : s.default === "false" && (s.default = !1, s.type = "boolean");
711
+ } else i.startsWith("--") && (s.required = !1, s.default = !1, s.type = "boolean");
712
+ if (i.includes("|")) {
713
+ const [o, ...m] = i.split("|");
714
+ i = o.trim(), s.alias = m.map((u) => u.trim());
986
715
  }
987
- return r.startsWith("--") && (s = !0, r = r.slice(2)), i.default === "*" && (i.default = [], i.type = ["string"]), r.endsWith("?") && (i.required = !1, r = r.slice(0, -1)), r.endsWith("*") && (i.type = ["string"], i.variadic = !0, i.default = [], r = r.slice(0, -1)), i.description = i.description ?? t[r] ?? t[`--${r}`], { name: r, isOption: s, definition: i };
716
+ return i.startsWith("--") && (n = !0, i = i.slice(2)), s.default === "*" && (s.default = [], s.type = ["string"]), i.endsWith("?") && (s.required = !1, i = i.slice(0, -1)), i.endsWith("*") && (s.type = ["string"], s.variadic = !0, s.default = [], i = i.slice(0, -1)), s.description = s.description ?? e[i] ?? e[`--${i}`], { name: i, isOption: n, definition: s };
988
717
  }
989
718
  }
990
- class $e extends x {
719
+ class z extends v {
991
720
  helperDefinitions = {};
992
721
  get command() {
993
722
  return this.parser ? this.parser.command : this.signature.split(" ")[0];
994
723
  }
995
- newCommandParser(e) {
996
- return new E({
997
- io: e.io,
724
+ newCommandParser(t) {
725
+ return new $({
726
+ io: t.io,
998
727
  signature: this.signature,
999
728
  helperDefinitions: this.helperDefinitions,
1000
729
  defaultOptions: this.defaultOptions()
@@ -1003,66 +732,109 @@ class $e extends x {
1003
732
  constructor() {
1004
733
  super("");
1005
734
  }
1006
- option(e, t = null) {
1007
- return this.parser.option(e, t);
735
+ option(t, e = null) {
736
+ return this.parser.option(t, e);
1008
737
  }
1009
- argument(e, t = null) {
1010
- return this.parser.argument(e, t);
738
+ argument(t, e = null) {
739
+ return this.parser.argument(t, e);
1011
740
  }
1012
741
  // Prompt utils
1013
- async askForConfirmation(...e) {
1014
- return this.io.askForConfirmation(...e);
742
+ async askForConfirmation(...t) {
743
+ return this.io.askForConfirmation(...t);
1015
744
  }
1016
- async askForInput(...e) {
1017
- return this.io.askForInput(...e);
745
+ async askForInput(...t) {
746
+ return this.io.askForInput(...t);
1018
747
  }
1019
- async askForSelect(...e) {
1020
- return this.io.askForSelect(...e);
748
+ async askForSelect(...t) {
749
+ return this.io.askForSelect(...t);
1021
750
  }
1022
- newLoader(...e) {
1023
- return this.io.newLoader(...e);
751
+ newLoader(...t) {
752
+ return this.io.newLoader(...t);
1024
753
  }
1025
754
  }
1026
- class K {
755
+ class N {
1027
756
  level;
1028
- constructor(e = {}) {
1029
- this.level = e.level ?? "info";
757
+ constructor(t = {}) {
758
+ this.level = t.level ?? "info";
1030
759
  }
1031
- shouldLog(e) {
1032
- const t = ["debug", "info", "warn", "error"], r = t.indexOf(this.level);
1033
- return t.indexOf(e) >= r;
760
+ shouldLog(t) {
761
+ const e = ["debug", "info", "warn", "error"], i = e.indexOf(this.level);
762
+ return e.indexOf(t) >= i;
1034
763
  }
1035
- setLevel(e) {
1036
- this.level = e;
764
+ setLevel(t) {
765
+ this.level = t;
1037
766
  }
1038
767
  getLevel() {
1039
768
  return this.level;
1040
769
  }
1041
- log(...e) {
1042
- console.log(...e);
770
+ log(...t) {
771
+ console.log(...t);
1043
772
  }
1044
- info(...e) {
1045
- this.shouldLog("info") && console.log(...e);
773
+ info(...t) {
774
+ this.shouldLog("info") && console.log(...t);
1046
775
  }
1047
- warn(...e) {
1048
- this.shouldLog("warn") && console.warn(...e);
776
+ warn(...t) {
777
+ this.shouldLog("warn") && console.warn(...t);
1049
778
  }
1050
- error(...e) {
1051
- this.shouldLog("error") && console.error(...e);
779
+ error(...t) {
780
+ this.shouldLog("error") && console.error(...t);
1052
781
  }
1053
- debug(...e) {
1054
- this.shouldLog("debug") && console.log(...e);
782
+ debug(...t) {
783
+ this.shouldLog("debug") && console.log(...t);
1055
784
  }
1056
785
  }
1057
- class ge {
786
+ class H {
787
+ /**
788
+ * Generate bigrams (character pairs) from a string
789
+ */
790
+ getBigrams(t) {
791
+ const e = [], i = t.toLowerCase();
792
+ for (let n = 0; n < i.length - 1; n++)
793
+ e.push(i.slice(n, n + 2));
794
+ return e;
795
+ }
796
+ /**
797
+ * Calculate Dice's Coefficient similarity between two strings (0-1 scale)
798
+ */
799
+ calculateSimilarity(t, e) {
800
+ if (t === e) return 1;
801
+ if (t.length < 2 || e.length < 2) return 0;
802
+ const i = this.getBigrams(t), n = this.getBigrams(e), s = new Set(n);
803
+ let o = 0;
804
+ for (const m of i)
805
+ s.has(m) && (o++, s.delete(m));
806
+ return 2 * o / (i.length + n.length);
807
+ }
808
+ /**
809
+ * Find best matching string and ratings for all candidates
810
+ */
811
+ findBestMatch(t, e) {
812
+ const i = e.map((o) => ({
813
+ target: o,
814
+ rating: this.calculateSimilarity(t, o)
815
+ }));
816
+ let n = 0, s = i[0]?.rating ?? 0;
817
+ for (let o = 1; o < i.length; o++)
818
+ i[o].rating > s && (s = i[o].rating, n = o);
819
+ return {
820
+ ratings: i,
821
+ bestMatch: i[n],
822
+ bestMatchIndex: n
823
+ };
824
+ }
825
+ }
826
+ class j {
1058
827
  commands = {};
1059
828
  io;
1060
829
  logger;
1061
- get CommandIOClass() {
1062
- return z;
830
+ stringSimilarity;
831
+ newCommandIO(t) {
832
+ return new S(t);
1063
833
  }
1064
- constructor(e) {
1065
- this.logger = e ?? new K(), this.io = new this.CommandIOClass(this.logger);
834
+ constructor(t) {
835
+ this.logger = t?.logger ?? new N(), this.io = this.newCommandIO({
836
+ logger: this.logger
837
+ }), this.stringSimilarity = t?.stringSimilarity ?? new H();
1066
838
  }
1067
839
  getAvailableCommands() {
1068
840
  return Object.keys(this.commands);
@@ -1070,188 +842,189 @@ class ge {
1070
842
  getCommands() {
1071
843
  return Object.values(this.commands);
1072
844
  }
1073
- importFile = async (e) => (await import(e)).default;
1074
- commandResolver = async (e) => {
1075
- let t = await this.importFile(e);
1076
- if (!t)
1077
- throw new Error(`The command at path ${e} does not have a default export.`);
1078
- return t && typeof t == "object" && "default" in t && (t = t.default), typeof t == "function" ? new t() : t instanceof x ? t : null;
845
+ importFile = async (t) => (await import(t)).default;
846
+ commandResolver = async (t) => {
847
+ let e = await this.importFile(t);
848
+ if (!e)
849
+ throw new Error(`The command at path ${t} does not have a default export.`);
850
+ return e && typeof e == "object" && "default" in e && (e = e.default), typeof e == "function" ? new e() : e instanceof v ? e : null;
1079
851
  };
1080
- withCommandResolver(e) {
1081
- return this.commandResolver = e, this;
852
+ withCommandResolver(t) {
853
+ return this.commandResolver = t, this;
1082
854
  }
1083
- withFileImporter(e) {
1084
- return this.importFile = e, this;
855
+ withFileImporter(t) {
856
+ return this.importFile = t, this;
1085
857
  }
1086
- registerCommand(e, t = !1) {
1087
- const r = e.command;
1088
- if (!r)
858
+ registerCommand(t, e = !1) {
859
+ const i = t.command;
860
+ if (!i)
1089
861
  throw new Error("Command signature is invalid, it must have a command name.");
1090
- if (!t && this.commands[r])
1091
- throw new Error(`Command ${r} already registered.`);
1092
- this.commands[r] = e;
862
+ if (!e && this.commands[i])
863
+ throw new Error(`Command ${i} already registered.`);
864
+ this.commands[i] = t;
1093
865
  }
1094
- async loadCommandsPath(e) {
1095
- for await (const t of this.listCommandsFiles(e))
866
+ async loadCommandsPath(t) {
867
+ for await (const e of this.listCommandsFiles(t))
1096
868
  try {
1097
- const r = await this.commandResolver(t);
1098
- r instanceof x && this.registerCommand(r);
1099
- } catch (r) {
1100
- throw new Error(`Command ${t} failed to load. ${r}`, {
1101
- cause: r
869
+ const i = await this.commandResolver(e);
870
+ i instanceof v && this.registerCommand(i);
871
+ } catch (i) {
872
+ throw new Error(`Command ${e} failed to load. ${i}`, {
873
+ cause: i
1102
874
  });
1103
875
  }
1104
876
  }
1105
- async runCommand(e, t, ...r) {
1106
- const s = typeof t == "string" ? this.commands[t] : t, i = typeof t == "string" ? t : s.command;
1107
- if (!s) {
1108
- const o = await this.suggestCommand(i);
1109
- return o ? await this.runCommand(e, o, ...r) : 1;
877
+ async runCommand(t, e, ...i) {
878
+ const n = typeof e == "string" ? this.commands[e] : e, s = typeof e == "string" ? e : n.command;
879
+ if (!n) {
880
+ const o = await this.suggestCommand(s);
881
+ return o ? await this.runCommand(t, o, ...i) : 1;
1110
882
  }
1111
- return await s.run({
1112
- ctx: e,
883
+ return await n.run({
884
+ ctx: t,
1113
885
  logger: this.logger,
1114
- args: r
886
+ args: i
1115
887
  }) ?? 0;
1116
888
  }
1117
- async suggestCommand(e) {
1118
- const t = this.getAvailableCommands(), { bestMatch: r, bestMatchIndex: s, ratings: i } = ee.findBestMatch(e, t), o = i.filter((u) => u.rating > 0.3).map((u) => u.target);
1119
- if (r.rating > 0 && o.length <= 1 || r.rating > 0.7 && o.length > 1) {
1120
- const u = t[s];
1121
- return await this.askRunSimilarCommand(e, u) ? u : null;
889
+ async suggestCommand(t) {
890
+ const e = this.getAvailableCommands(), { bestMatch: i, bestMatchIndex: n, ratings: s } = this.stringSimilarity.findBestMatch(t, e), o = s.filter((m) => m.rating > 0.3).map((m) => m.target);
891
+ if (i.rating > 0 && o.length <= 1 || i.rating > 0.7 && o.length > 1) {
892
+ const m = e[n];
893
+ return await this.askRunSimilarCommand(t, m) ? m : null;
1122
894
  }
1123
895
  if (o.length) {
1124
- this.io.error(`${a.bgRed(" ERROR ")} Command ${a.yellow(e)} not found.
896
+ this.io.error(`${a.bgRed(" ERROR ")} Command ${a.yellow(t)} not found.
1125
897
  `);
1126
- const u = await this.io.askForSelect(a.green("Did you mean to run one of these commands instead?"), o);
1127
- if (u)
1128
- return u;
898
+ const m = await this.io.askForSelect(a.green("Did you mean to run one of these commands instead?"), o);
899
+ if (m)
900
+ return m;
1129
901
  }
1130
- throw new he(e);
1131
- }
1132
- async askRunSimilarCommand(e, t) {
1133
- return this.io.error(`${a.bgRed(" ERROR ")} Command ${a.yellow(e)} not found.
1134
- `), this.io.askForConfirmation(`${a.green(`Do you want to run ${a.yellow(t)} instead?`)} `);
1135
- }
1136
- async *listCommandsFiles(e) {
1137
- const t = Z.readdirSync(e, { withFileTypes: !0 });
1138
- for (const r of t) {
1139
- const s = I.resolve(e, r.name);
1140
- if (r.isDirectory())
1141
- yield* this.listCommandsFiles(I.resolve(e, r.name));
902
+ throw new P(t);
903
+ }
904
+ async askRunSimilarCommand(t, e) {
905
+ return this.io.error(`${a.bgRed(" ERROR ")} Command ${a.yellow(t)} not found.
906
+ `), this.io.askForConfirmation(`${a.green(`Do you want to run ${a.yellow(e)} instead?`)} `);
907
+ }
908
+ async *listCommandsFiles(t) {
909
+ const e = I.readdirSync(t, { withFileTypes: !0 });
910
+ for (const i of e) {
911
+ const n = R.resolve(t, i.name);
912
+ if (i.isDirectory())
913
+ yield* this.listCommandsFiles(R.resolve(t, i.name));
1142
914
  else {
1143
- if (!s.endsWith(".ts") && !s.endsWith(".js") && !s.endsWith(".mjs") && !s.endsWith(".cjs"))
915
+ if (!n.endsWith(".ts") && !n.endsWith(".js") && !n.endsWith(".mjs") && !n.endsWith(".cjs"))
1144
916
  continue;
1145
- yield s;
917
+ yield n;
1146
918
  }
1147
919
  }
1148
920
  }
1149
921
  }
1150
- class fe {
922
+ class W {
1151
923
  logger;
1152
- constructor(e) {
1153
- this.logger = e;
924
+ constructor(t) {
925
+ this.logger = t;
1154
926
  }
1155
- handle(e) {
1156
- if (e instanceof w)
1157
- return e.pretty(this.logger), -1;
1158
- throw e;
927
+ handle(t) {
928
+ if (t instanceof f)
929
+ return t.pretty(this.logger), -1;
930
+ throw t;
1159
931
  }
1160
932
  }
1161
- class ye extends x {
1162
- constructor(e) {
933
+ class M extends v {
934
+ constructor(t) {
1163
935
  super("help", {
1164
936
  description: a.bold("Show help information about the CLI and its commands")
1165
- }), this.opts = e;
937
+ }), this.opts = t;
1166
938
  }
1167
939
  async handle() {
1168
- const e = this.opts.commandRegistry.getCommands(), t = this.opts.cliName ?? "Bob CLI", r = this.opts.cliVersion ?? "0.0.0", s = (await import("./package-CtFSlXKR.js"))?.default?.version ?? "0.0.0";
1169
- this.io.log(`${t} ${a.green(r)} (core: ${a.yellow(s)})
940
+ const t = this.opts.commandRegistry.getCommands(), e = this.opts.cliName ?? "Bob CLI", i = this.opts.cliVersion ?? "0.0.0", n = (await import("./package-C-2LYcDa.js"))?.default?.version ?? "0.0.0";
941
+ this.io.log(`${e} ${a.green(i)} (core: ${a.yellow(n)})
1170
942
 
1171
943
  ${a.yellow("Usage")}:
1172
944
  command [options] [arguments]
1173
945
 
1174
946
  ${a.yellow("Available commands")}:
1175
947
  `);
1176
- const i = Math.max(...e.map((m) => m.command.length)) ?? 0, o = {};
1177
- for (const m of e) {
1178
- const h = m.group ?? m.command.split(":")[0];
1179
- o[h] || (o[h] = []), o[h].push(m);
948
+ const s = Math.max(...t.map((u) => u.command.length)) ?? 0, o = {};
949
+ for (const u of t) {
950
+ const h = u.group ?? u.command.split(":")[0];
951
+ o[h] || (o[h] = []), o[h].push(u);
1180
952
  }
1181
- const u = Object.entries(o).sort(([m], [h]) => m.toLowerCase().localeCompare(h.toLowerCase())).sort(([, m], [, h]) => m.length - h.length);
1182
- for (const [m, h] of u) {
953
+ const m = Object.entries(o).sort(([u], [h]) => u.toLowerCase().localeCompare(h.toLowerCase())).sort(([, u], [, h]) => u.length - h.length);
954
+ for (const [u, h] of m) {
1183
955
  const l = h.length > 1;
1184
- l && this.io.log(a.yellow(`${m}:`));
1185
- const d = h.sort((p, g) => p.command.toLowerCase().localeCompare(g.command.toLowerCase()));
1186
- for (const p of d) {
1187
- let g = j(i - p.command.length);
1188
- l && (g = g.slice(2)), this.io.log(`${l ? " " : ""}${a.green(p.command)} ${g} ${p.description}`);
956
+ l && this.io.log(a.yellow(`${u}:`));
957
+ const d = h.sort((c, p) => c.command.toLowerCase().localeCompare(p.command.toLowerCase()));
958
+ for (const c of d) {
959
+ let p = A(s - c.command.length);
960
+ l && (p = p.slice(2)), this.io.log(`${l ? " " : ""}${a.green(c.command)} ${p} ${c.description}`);
1189
961
  }
1190
962
  }
1191
963
  }
1192
964
  }
1193
- class Ce {
965
+ class J {
1194
966
  ctx;
1195
967
  logger;
1196
968
  commandRegistry;
1197
969
  exceptionHandler;
1198
970
  helpCommand;
1199
- newCommandRegistry(e) {
1200
- return new ge(e.logger);
971
+ newCommandRegistry(t) {
972
+ return new j(t);
1201
973
  }
1202
- newHelpCommand(e) {
1203
- return new ye(e);
974
+ newHelpCommand(t) {
975
+ return new M(t);
1204
976
  }
1205
- newExceptionHandler(e) {
1206
- return new fe(e.logger);
977
+ newExceptionHandler(t) {
978
+ return new W(t.logger);
1207
979
  }
1208
- constructor(e = {}) {
1209
- this.ctx = e.ctx, this.logger = e.logger ?? new K(), this.commandRegistry = this.newCommandRegistry({
980
+ constructor(t = {}) {
981
+ this.ctx = t.ctx, this.logger = t.logger ?? new N(), this.commandRegistry = this.newCommandRegistry({
1210
982
  logger: this.logger
1211
983
  }), this.exceptionHandler = this.newExceptionHandler({
1212
984
  logger: this.logger
1213
985
  }), this.helpCommand = this.newHelpCommand({
1214
- cliName: e.name,
1215
- cliVersion: e.version,
986
+ cliName: t.name,
987
+ cliVersion: t.version,
1216
988
  commandRegistry: this.commandRegistry
1217
989
  });
1218
990
  }
1219
- withCommandResolver(e) {
1220
- return this.commandRegistry.withCommandResolver(e), this;
991
+ withCommandResolver(t) {
992
+ return this.commandRegistry.withCommandResolver(t), this;
1221
993
  }
1222
- withFileImporter(e) {
1223
- return this.commandRegistry.withFileImporter(e), this;
994
+ withFileImporter(t) {
995
+ return this.commandRegistry.withFileImporter(t), this;
1224
996
  }
1225
- async withCommands(...e) {
1226
- for (const t of e)
1227
- typeof t == "string" ? await this.commandRegistry.loadCommandsPath(t) : typeof t == "function" ? this.registerCommand(new t()) : this.registerCommand(t);
997
+ async withCommands(...t) {
998
+ for (const e of t)
999
+ typeof e == "string" ? await this.commandRegistry.loadCommandsPath(e) : typeof e == "function" ? this.registerCommand(new e()) : this.registerCommand(e);
1228
1000
  }
1229
- async runCommand(e, ...t) {
1230
- return e ? await this.commandRegistry.runCommand(this.ctx ?? {}, e, ...t).catch(this.exceptionHandler.handle.bind(this.exceptionHandler)) : await this.runHelpCommand();
1001
+ async runCommand(t, ...e) {
1002
+ return t ? await this.commandRegistry.runCommand(this.ctx ?? {}, t, ...e).catch(this.exceptionHandler.handle.bind(this.exceptionHandler)) : await this.runHelpCommand();
1231
1003
  }
1232
1004
  async runHelpCommand() {
1233
1005
  return await this.runCommand(this.helpCommand);
1234
1006
  }
1235
- registerCommand(e) {
1236
- this.commandRegistry.registerCommand(e);
1007
+ registerCommand(t) {
1008
+ this.commandRegistry.registerCommand(t);
1237
1009
  }
1238
1010
  }
1239
1011
  export {
1240
- B as BadCommandOption,
1241
- Ae as BadCommandParameter,
1242
- w as BobError,
1243
- Ce as Cli,
1244
- x as Command,
1245
- z as CommandIO,
1246
- he as CommandNotFoundError,
1247
- J as CommandParser,
1248
- ge as CommandRegistry,
1249
- E as CommandSignatureParser,
1250
- $e as CommandWithSignature,
1251
- fe as ExceptionHandler,
1252
- pe as HelpOption,
1253
- k as InvalidOption,
1254
- K as Logger,
1255
- Y as MissingRequiredArgumentValue,
1256
- ce as MissingRequiredOptionValue
1012
+ C as BadCommandOption,
1013
+ U as BadCommandParameter,
1014
+ f as BobError,
1015
+ J as Cli,
1016
+ v as Command,
1017
+ S as CommandIO,
1018
+ P as CommandNotFoundError,
1019
+ k as CommandParser,
1020
+ j as CommandRegistry,
1021
+ $ as CommandSignatureParser,
1022
+ z as CommandWithSignature,
1023
+ W as ExceptionHandler,
1024
+ D as HelpOption,
1025
+ b as InvalidOption,
1026
+ N as Logger,
1027
+ F as MissingRequiredArgumentValue,
1028
+ V as MissingRequiredOptionValue,
1029
+ H as StringSimilarity
1257
1030
  };