bob-core 3.0.0-beta.4 → 3.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{src/Cli.d.ts → Cli.d.ts} +20 -0
  3. package/dist/cjs/Command.d.ts +91 -0
  4. package/dist/cjs/CommandParser.d.ts +122 -0
  5. package/dist/cjs/{src/CommandRegistry.d.ts → CommandRegistry.d.ts} +12 -0
  6. package/dist/cjs/ExceptionHandler.d.ts +14 -0
  7. package/dist/cjs/HelpFlag.d.ts +27 -0
  8. package/dist/cjs/StringSimilarity.d.ts +31 -0
  9. package/dist/cjs/args/index.d.ts +131 -0
  10. package/dist/{esm/src → cjs}/errors/BadCommandArgument.d.ts +4 -2
  11. package/dist/cjs/{src/errors → errors}/BadCommandFlag.d.ts +4 -2
  12. package/dist/cjs/errors/BobError.d.ts +13 -0
  13. package/dist/cjs/errors/CommandNotFoundError.d.ts +9 -0
  14. package/dist/{esm/src → cjs}/errors/InvalidFlag.d.ts +4 -2
  15. package/dist/cjs/errors/MissingRequiredArgumentValue.d.ts +9 -0
  16. package/dist/cjs/errors/MissingRequiredFlagValue.d.ts +9 -0
  17. package/dist/cjs/errors/TooManyArguments.d.ts +10 -0
  18. package/dist/cjs/errors/ValidationError.d.ts +10 -0
  19. package/dist/{esm/src → cjs}/errors/renderError.d.ts +2 -2
  20. package/dist/cjs/flags/boolean.d.ts +20 -0
  21. package/dist/cjs/flags/custom.d.ts +12 -0
  22. package/dist/cjs/flags/directory.d.ts +27 -0
  23. package/dist/cjs/flags/file.d.ts +27 -0
  24. package/dist/cjs/flags/helpers.d.ts +9 -0
  25. package/dist/cjs/flags/index.d.ts +160 -0
  26. package/dist/cjs/flags/number.d.ts +32 -0
  27. package/dist/cjs/flags/option.d.ts +8 -0
  28. package/dist/cjs/flags/string.d.ts +19 -0
  29. package/dist/cjs/flags/url.d.ts +19 -0
  30. package/dist/cjs/index.js +10 -0
  31. package/dist/cjs/{src/lib → lib}/helpers.d.ts +1 -1
  32. package/dist/cjs/lib/types.d.ts +99 -0
  33. package/dist/cjs/shared/ask-helpers.d.ts +7 -0
  34. package/dist/cjs/shared/flagsUtils.d.ts +5 -0
  35. package/dist/cjs/ux/askForConfirmation.d.ts +10 -0
  36. package/dist/cjs/{src/ux → ux}/askForToggle.d.ts +5 -1
  37. package/dist/cjs/ux/helpers.d.ts +6 -0
  38. package/dist/{esm/src → cjs}/ux/index.d.ts +30 -2
  39. package/dist/esm/{src/Cli.d.ts → Cli.d.ts} +20 -0
  40. package/dist/esm/Command.d.ts +91 -0
  41. package/dist/esm/CommandParser.d.ts +122 -0
  42. package/dist/esm/{src/CommandRegistry.d.ts → CommandRegistry.d.ts} +12 -0
  43. package/dist/esm/ExceptionHandler.d.ts +14 -0
  44. package/dist/esm/HelpFlag.d.ts +27 -0
  45. package/dist/esm/StringSimilarity.d.ts +31 -0
  46. package/dist/esm/args/index.d.ts +131 -0
  47. package/dist/{cjs/src → esm}/errors/BadCommandArgument.d.ts +4 -2
  48. package/dist/esm/{src/errors → errors}/BadCommandFlag.d.ts +4 -2
  49. package/dist/esm/errors/BobError.d.ts +13 -0
  50. package/dist/esm/errors/CommandNotFoundError.d.ts +9 -0
  51. package/dist/{cjs/src → esm}/errors/InvalidFlag.d.ts +4 -2
  52. package/dist/esm/errors/MissingRequiredArgumentValue.d.ts +9 -0
  53. package/dist/esm/errors/MissingRequiredFlagValue.d.ts +9 -0
  54. package/dist/esm/errors/TooManyArguments.d.ts +10 -0
  55. package/dist/esm/errors/ValidationError.d.ts +10 -0
  56. package/dist/{cjs/src → esm}/errors/renderError.d.ts +2 -2
  57. package/dist/esm/flags/boolean.d.ts +20 -0
  58. package/dist/esm/flags/custom.d.ts +12 -0
  59. package/dist/esm/flags/directory.d.ts +27 -0
  60. package/dist/esm/flags/file.d.ts +27 -0
  61. package/dist/esm/flags/helpers.d.ts +9 -0
  62. package/dist/esm/flags/index.d.ts +160 -0
  63. package/dist/esm/flags/number.d.ts +32 -0
  64. package/dist/esm/flags/option.d.ts +8 -0
  65. package/dist/esm/flags/string.d.ts +19 -0
  66. package/dist/esm/flags/url.d.ts +19 -0
  67. package/dist/esm/{src/index.js → index.js} +346 -267
  68. package/dist/esm/{src/lib → lib}/helpers.d.ts +1 -1
  69. package/dist/esm/lib/types.d.ts +99 -0
  70. package/dist/esm/shared/ask-helpers.d.ts +7 -0
  71. package/dist/esm/shared/flagsUtils.d.ts +5 -0
  72. package/dist/esm/ux/askForConfirmation.d.ts +10 -0
  73. package/dist/esm/{src/ux → ux}/askForToggle.d.ts +5 -1
  74. package/dist/esm/ux/helpers.d.ts +6 -0
  75. package/dist/{cjs/src → esm}/ux/index.d.ts +30 -2
  76. package/package.json +1 -1
  77. package/dist/cjs/package-BYPkkzPN.cjs +0 -1
  78. package/dist/cjs/src/Command.d.ts +0 -48
  79. package/dist/cjs/src/CommandParser.d.ts +0 -110
  80. package/dist/cjs/src/ExceptionHandler.d.ts +0 -6
  81. package/dist/cjs/src/HelpFlag.d.ts +0 -12
  82. package/dist/cjs/src/StringSimilarity.d.ts +0 -26
  83. package/dist/cjs/src/args/index.d.ts +0 -67
  84. package/dist/cjs/src/errors/BobError.d.ts +0 -5
  85. package/dist/cjs/src/errors/CommandNotFoundError.d.ts +0 -7
  86. package/dist/cjs/src/errors/MissingRequiredArgumentValue.d.ts +0 -7
  87. package/dist/cjs/src/errors/MissingRequiredFlagValue.d.ts +0 -7
  88. package/dist/cjs/src/errors/TooManyArguments.d.ts +0 -8
  89. package/dist/cjs/src/errors/ValidationError.d.ts +0 -3
  90. package/dist/cjs/src/flags/boolean.d.ts +0 -9
  91. package/dist/cjs/src/flags/custom.d.ts +0 -9
  92. package/dist/cjs/src/flags/directory.d.ts +0 -14
  93. package/dist/cjs/src/flags/file.d.ts +0 -14
  94. package/dist/cjs/src/flags/helpers.d.ts +0 -3
  95. package/dist/cjs/src/flags/index.d.ts +0 -76
  96. package/dist/cjs/src/flags/number.d.ts +0 -17
  97. package/dist/cjs/src/flags/option.d.ts +0 -6
  98. package/dist/cjs/src/flags/string.d.ts +0 -8
  99. package/dist/cjs/src/flags/url.d.ts +0 -8
  100. package/dist/cjs/src/index.js +0 -10
  101. package/dist/cjs/src/lib/types.d.ts +0 -59
  102. package/dist/cjs/src/shared/ask-helpers.d.ts +0 -7
  103. package/dist/cjs/src/ux/askForConfirmation.d.ts +0 -5
  104. package/dist/cjs/src/ux/helpers.d.ts +0 -1
  105. package/dist/esm/package-LkysKcR6.js +0 -60
  106. package/dist/esm/src/Command.d.ts +0 -48
  107. package/dist/esm/src/CommandParser.d.ts +0 -110
  108. package/dist/esm/src/ExceptionHandler.d.ts +0 -6
  109. package/dist/esm/src/HelpFlag.d.ts +0 -12
  110. package/dist/esm/src/StringSimilarity.d.ts +0 -26
  111. package/dist/esm/src/args/index.d.ts +0 -67
  112. package/dist/esm/src/errors/BobError.d.ts +0 -5
  113. package/dist/esm/src/errors/CommandNotFoundError.d.ts +0 -7
  114. package/dist/esm/src/errors/MissingRequiredArgumentValue.d.ts +0 -7
  115. package/dist/esm/src/errors/MissingRequiredFlagValue.d.ts +0 -7
  116. package/dist/esm/src/errors/TooManyArguments.d.ts +0 -8
  117. package/dist/esm/src/errors/ValidationError.d.ts +0 -3
  118. package/dist/esm/src/flags/boolean.d.ts +0 -9
  119. package/dist/esm/src/flags/custom.d.ts +0 -9
  120. package/dist/esm/src/flags/directory.d.ts +0 -14
  121. package/dist/esm/src/flags/file.d.ts +0 -14
  122. package/dist/esm/src/flags/helpers.d.ts +0 -3
  123. package/dist/esm/src/flags/index.d.ts +0 -76
  124. package/dist/esm/src/flags/number.d.ts +0 -17
  125. package/dist/esm/src/flags/option.d.ts +0 -6
  126. package/dist/esm/src/flags/string.d.ts +0 -8
  127. package/dist/esm/src/flags/url.d.ts +0 -8
  128. package/dist/esm/src/lib/types.d.ts +0 -59
  129. package/dist/esm/src/shared/ask-helpers.d.ts +0 -7
  130. package/dist/esm/src/ux/askForConfirmation.d.ts +0 -5
  131. package/dist/esm/src/ux/helpers.d.ts +0 -1
  132. /package/dist/cjs/{src/CommandSignatureParser.d.ts → CommandSignatureParser.d.ts} +0 -0
  133. /package/dist/cjs/{src/CommandWithSignature.d.ts → CommandWithSignature.d.ts} +0 -0
  134. /package/dist/cjs/{src/Logger.d.ts → Logger.d.ts} +0 -0
  135. /package/dist/cjs/{src/commands → commands}/HelpCommand.d.ts +0 -0
  136. /package/dist/cjs/{src/contracts → contracts}/LoggerContract.d.ts +0 -0
  137. /package/dist/cjs/{src/contracts → contracts}/index.d.ts +0 -0
  138. /package/dist/cjs/{src/errors → errors}/index.d.ts +0 -0
  139. /package/dist/cjs/{src/index.d.ts → index.d.ts} +0 -0
  140. /package/dist/cjs/{src/lib → lib}/string.d.ts +0 -0
  141. /package/dist/cjs/{src/shared → shared}/parsers.d.ts +0 -0
  142. /package/dist/cjs/{src/ux → ux}/askForCheckbox.d.ts +0 -0
  143. /package/dist/cjs/{src/ux → ux}/askForEditor.d.ts +0 -0
  144. /package/dist/cjs/{src/ux → ux}/askForExpand.d.ts +0 -0
  145. /package/dist/cjs/{src/ux → ux}/askForFileSelector.d.ts +0 -0
  146. /package/dist/cjs/{src/ux → ux}/askForInput.d.ts +0 -0
  147. /package/dist/cjs/{src/ux → ux}/askForList.d.ts +0 -0
  148. /package/dist/cjs/{src/ux → ux}/askForNumber.d.ts +0 -0
  149. /package/dist/cjs/{src/ux → ux}/askForPassword.d.ts +0 -0
  150. /package/dist/cjs/{src/ux → ux}/askForRawList.d.ts +0 -0
  151. /package/dist/cjs/{src/ux → ux}/askForSearch.d.ts +0 -0
  152. /package/dist/cjs/{src/ux → ux}/askForSelect.d.ts +0 -0
  153. /package/dist/cjs/{src/ux → ux}/keyValue.d.ts +0 -0
  154. /package/dist/cjs/{src/ux → ux}/loader.d.ts +0 -0
  155. /package/dist/cjs/{src/ux → ux}/progressBar.d.ts +0 -0
  156. /package/dist/cjs/{src/ux → ux}/table.d.ts +0 -0
  157. /package/dist/cjs/{src/ux → ux}/types.d.ts +0 -0
  158. /package/dist/esm/{src/CommandSignatureParser.d.ts → CommandSignatureParser.d.ts} +0 -0
  159. /package/dist/esm/{src/CommandWithSignature.d.ts → CommandWithSignature.d.ts} +0 -0
  160. /package/dist/esm/{src/Logger.d.ts → Logger.d.ts} +0 -0
  161. /package/dist/esm/{src/commands → commands}/HelpCommand.d.ts +0 -0
  162. /package/dist/esm/{src/contracts → contracts}/LoggerContract.d.ts +0 -0
  163. /package/dist/esm/{src/contracts → contracts}/index.d.ts +0 -0
  164. /package/dist/esm/{src/errors → errors}/index.d.ts +0 -0
  165. /package/dist/esm/{src/index.d.ts → index.d.ts} +0 -0
  166. /package/dist/esm/{src/lib → lib}/string.d.ts +0 -0
  167. /package/dist/esm/{src/shared → shared}/parsers.d.ts +0 -0
  168. /package/dist/esm/{src/ux → ux}/askForCheckbox.d.ts +0 -0
  169. /package/dist/esm/{src/ux → ux}/askForEditor.d.ts +0 -0
  170. /package/dist/esm/{src/ux → ux}/askForExpand.d.ts +0 -0
  171. /package/dist/esm/{src/ux → ux}/askForFileSelector.d.ts +0 -0
  172. /package/dist/esm/{src/ux → ux}/askForInput.d.ts +0 -0
  173. /package/dist/esm/{src/ux → ux}/askForList.d.ts +0 -0
  174. /package/dist/esm/{src/ux → ux}/askForNumber.d.ts +0 -0
  175. /package/dist/esm/{src/ux → ux}/askForPassword.d.ts +0 -0
  176. /package/dist/esm/{src/ux → ux}/askForRawList.d.ts +0 -0
  177. /package/dist/esm/{src/ux → ux}/askForSearch.d.ts +0 -0
  178. /package/dist/esm/{src/ux → ux}/askForSelect.d.ts +0 -0
  179. /package/dist/esm/{src/ux → ux}/keyValue.d.ts +0 -0
  180. /package/dist/esm/{src/ux → ux}/loader.d.ts +0 -0
  181. /package/dist/esm/{src/ux → ux}/progressBar.d.ts +0 -0
  182. /package/dist/esm/{src/ux → ux}/table.d.ts +0 -0
  183. /package/dist/esm/{src/ux → ux}/types.d.ts +0 -0
@@ -1,11 +1,20 @@
1
1
  import e from "chalk";
2
- import t from "node:fs";
3
- import n from "node:path";
4
- import r from "minimist";
5
- import { checkbox as i, confirm as a, editor as o, expand as s, input as c, number as l, password as u, rawlist as d, search as f, select as p } from "@inquirer/prompts";
6
- import { fileSelector as ee } from "inquirer-file-selector";
7
- //#region src/Logger.ts
8
- var m = class {
2
+ import t, { readFileSync as n } from "node:fs";
3
+ import r from "node:path";
4
+ import i from "minimist";
5
+ import { checkbox as a, confirm as o, editor as s, expand as c, input as l, number as u, password as d, rawlist as f, search as p, select as ee } from "@inquirer/prompts";
6
+ import { fileSelector as te } from "inquirer-file-selector";
7
+ //#region \0rolldown/runtime.js
8
+ var ne = Object.create, re = Object.defineProperty, ie = Object.getOwnPropertyDescriptor, ae = Object.getOwnPropertyNames, oe = Object.getPrototypeOf, se = Object.prototype.hasOwnProperty, ce = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), le = (e, t, n, r) => {
9
+ if (t && typeof t == "object" || typeof t == "function") for (var i = ae(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !se.call(e, s) && s !== n && re(e, s, {
10
+ get: ((e) => t[e]).bind(null, s),
11
+ enumerable: !(r = ie(t, s)) || r.enumerable
12
+ });
13
+ return e;
14
+ }, ue = (e, t, n) => (n = e == null ? {} : ne(oe(e)), le(t || !e || !e.__esModule ? re(n, "default", {
15
+ value: e,
16
+ enumerable: !0
17
+ }) : n, e)), m = class {
9
18
  level;
10
19
  constructor(e = {}) {
11
20
  this.level = e.level ?? "info";
@@ -40,18 +49,35 @@ var m = class {
40
49
  debug(...e) {
41
50
  this.shouldLog("debug") && console.log(...e);
42
51
  }
43
- }, h = class {
44
- getBigrams(e) {
45
- let t = [], n = e.toLowerCase();
46
- for (let e = 0; e < n.length - 1; e++) t.push(n.slice(e, e + 2));
47
- return t;
48
- }
52
+ }, de = .1, fe = 4, h = .5, g = class {
49
53
  calculateSimilarity(e, t) {
50
54
  if (e === t) return 1;
51
- if (e.length < 2 || t.length < 2) return 0;
52
- let n = this.getBigrams(e), r = this.getBigrams(t), i = new Set(r), a = 0;
53
- for (let e of n) i.has(e) && (a++, i.delete(e));
54
- return 2 * a / (n.length + r.length);
55
+ let n = e.toLowerCase(), r = t.toLowerCase();
56
+ if (n === r) return 1;
57
+ if (n.length === 0 || r.length === 0) return 0;
58
+ let i = this.jaro(n, r);
59
+ if (i === 0) return 0;
60
+ let a = 0, o = Math.min(fe, n.length, r.length);
61
+ for (; a < o && n[a] === r[a];) a++;
62
+ let s = i + a * de * (1 - i), c = Math.min(n.length, r.length) / Math.max(n.length, r.length);
63
+ return s * (c < h ? c / h : 1);
64
+ }
65
+ jaro(e, t) {
66
+ let n = Math.max(0, Math.floor(Math.max(e.length, t.length) / 2) - 1), r = Array(e.length).fill(!1), i = Array(t.length).fill(!1), a = 0;
67
+ for (let o = 0; o < e.length; o++) {
68
+ let s = Math.max(0, o - n), c = Math.min(o + n + 1, t.length);
69
+ for (let n = s; n < c; n++) if (!i[n] && e[o] === t[n]) {
70
+ r[o] = !0, i[n] = !0, a++;
71
+ break;
72
+ }
73
+ }
74
+ if (a === 0) return 0;
75
+ let o = 0, s = 0;
76
+ for (let n = 0; n < e.length; n++) if (r[n]) {
77
+ for (; !i[s];) s++;
78
+ e[n] !== t[s] && o++, s++;
79
+ }
80
+ return o /= 2, (a / e.length + a / t.length + (a - o) / a) / 3;
55
81
  }
56
82
  findBestMatch(e, t) {
57
83
  let n = t.map((t) => ({
@@ -65,23 +91,21 @@ var m = class {
65
91
  bestMatchIndex: r
66
92
  };
67
93
  }
68
- }, g = class extends Error {
69
- $type = "BobError";
70
- };
94
+ }, _ = class extends Error {};
71
95
  //#endregion
72
96
  //#region src/errors/renderError.ts
73
- function _(t) {
97
+ function v(t) {
74
98
  return e.bold.yellow(`'${t}'`);
75
99
  }
76
- var te = /\x1b\[[0-9;]*m/g;
77
- function ne(e) {
78
- return e.replace(te, "").length;
100
+ var pe = /\x1b\[[0-9;]*m/g;
101
+ function me(e) {
102
+ return e.replace(pe, "").length;
79
103
  }
80
- function v(t, n) {
104
+ function y(t, n) {
81
105
  let { title: r, details: i, hint: a } = n, o = i && i.length > 0 || a != null, s = e.dim("│"), c = e.dim("└─");
82
106
  if (t.log(""), t.log(` ${e.red("error:")} ${r}`), o) {
83
107
  if (t.log(` ${s}`), i && i.length > 0) {
84
- let e = i.map(([e]) => ne(e)), n = Math.max(...e);
108
+ let e = i.map(([e]) => me(e)), n = Math.max(...e);
85
109
  for (let r = 0; r < i.length; r++) {
86
110
  let [a, o] = i[r], c = " ".repeat(n - e[r]);
87
111
  t.log(` ${s} ${a}${c} ${o}`);
@@ -93,92 +117,107 @@ function v(t, n) {
93
117
  }
94
118
  //#endregion
95
119
  //#region src/errors/CommandNotFoundError.ts
96
- var y = class extends g {
120
+ var he = class extends _ {
121
+ $type = "CommandNotFoundError";
97
122
  constructor(e) {
98
123
  super(`Command "${e}" not found.`), this.command = e;
99
124
  }
100
125
  pretty(e) {
101
- v(e, { title: `command ${_(this.command)} not found` });
126
+ y(e, { title: `command ${v(this.command)} not found` });
102
127
  }
103
128
  };
104
129
  //#endregion
105
130
  //#region src/flags/helpers.ts
106
131
  function b(t, n) {
107
- let r = "multiple" in n && n.multiple, i = `${e.yellow.bold(t)} is required`;
132
+ let r = n.multiple === !0, i = n.required ? `${e.yellow.bold(t)} is required` : `Enter ${e.yellow.bold(t)}`;
108
133
  return n.description && (i += `: ${e.gray(`(${n.description})`)}`), i += ` ${e.green(`(${n.type}${r ? "[]" : ""})`)}\n`, i;
109
134
  }
110
135
  function x(e) {
111
136
  return e == null ? [] : typeof e == "string" ? [e] : e;
112
137
  }
138
+ function S(e) {
139
+ return e.length === 1 ? `-${e}` : `--${e}`;
140
+ }
141
+ //#endregion
142
+ //#region src/shared/flagsUtils.ts
143
+ function C(e) {
144
+ return e.type === "option" && "options" in e;
145
+ }
113
146
  //#endregion
114
147
  //#region src/errors/InvalidFlag.ts
115
- var S = class extends g {
148
+ var w = class extends _ {
149
+ $type = "InvalidFlag";
116
150
  constructor(e, t = {}) {
117
151
  super(`Flag ${e} is not recognized`), this.flag = e, this.flagsSchema = t;
118
152
  }
119
153
  pretty(t) {
120
154
  let n = Object.entries(this.flagsSchema).map(([t, n]) => {
121
- let r = x(n.alias), i = `--${t}${r.length > 0 ? r.map((e) => `, -${e}`).join("") : ""}`, a = n.type === "option" && "options" in n && n.options ? n.options.join(" | ") : n.type, o = n.description ?? "", s = o ? `${o} ${e.dim(`(${a})`)}` : e.dim(`(${a})`);
155
+ let r = x(n.alias), i = `--${t}${r.length > 0 ? r.map((e) => `, ${S(e)}`).join("") : ""}`, a = C(n) ? n.options.join(" | ") : n.type, o = n.description ?? "", s = o ? `${o} ${e.dim(`(${a})`)}` : e.dim(`(${a})`);
122
156
  return [e.cyan(i), s];
123
157
  });
124
- v(t, {
125
- title: `flag ${_(this.flag)} is not recognized`,
158
+ y(t, {
159
+ title: `flag ${v(this.flag)} is not recognized`,
126
160
  details: n
127
161
  });
128
162
  }
129
- }, C = class extends g {
163
+ }, T = class extends _ {
164
+ $type = "MissingRequiredArgumentValue";
130
165
  constructor(e) {
131
166
  super(`Argument "${e}" is required.`), this.argument = e;
132
167
  }
133
168
  pretty(e) {
134
- v(e, { title: `argument ${_(this.argument)} is required` });
169
+ y(e, { title: `argument ${v(this.argument)} is required` });
135
170
  }
136
- }, w = class extends g {
171
+ }, E = class extends _ {
172
+ $type = "MissingRequiredFlagValue";
137
173
  constructor(e) {
138
174
  super(`Flag "${e}" is required.`), this.flag = e;
139
175
  }
140
176
  pretty(e) {
141
- v(e, { title: `flag ${_(this.flag)} is required` });
177
+ y(e, { title: `flag ${v(this.flag)} is required` });
178
+ }
179
+ }, D = class extends Error {
180
+ constructor(e) {
181
+ super(e);
142
182
  }
143
- }, T = class extends g {
183
+ }, O = class extends _ {
184
+ $type = "BadCommandArgument";
144
185
  constructor(e, t) {
145
186
  let n = `Argument "${e.arg}" value is invalid.`;
146
187
  e.reason ? n += ` Reason: ${e.reason}` : n += ` Value: "${e.value}"`, super(n), this.detail = e, this.argDefinition = t;
147
188
  }
148
189
  pretty(t) {
149
190
  let n = [];
150
- this.detail.value != null && n.push([e.dim("value"), e.yellow(`"${this.detail.value}"`)]), this.detail.reason != null && n.push([e.dim("reason"), this.detail.reason]), this.argDefinition?.help != null && n.push([e.dim("help"), e.green(this.argDefinition.help)]), v(t, {
151
- title: `argument ${_(this.detail.arg)} is invalid`,
191
+ this.detail.value != null && n.push([e.dim("value"), e.yellow(`"${this.detail.value}"`)]), this.detail.reason != null && n.push([e.dim("reason"), this.detail.reason]), this.argDefinition?.help != null && n.push([e.dim("help"), e.green(this.argDefinition.help)]), y(t, {
192
+ title: `argument ${v(this.detail.arg)} is invalid`,
152
193
  details: n
153
194
  });
154
195
  }
155
- }, E = class extends g {
196
+ }, k = class extends _ {
197
+ $type = "BadCommandFlag";
156
198
  constructor(e, t) {
157
199
  let n = `Flag "${e.flag}" value is invalid.`;
158
200
  e.reason ? n += ` Reason: ${e.reason}` : n += ` Value: "${e.value}"`, super(n), this.param = e, this.flagDefinition = t;
159
201
  }
160
202
  pretty(t) {
161
203
  let n = [];
162
- this.param.value != null && n.push([e.dim("value"), e.yellow(`"${this.param.value}"`)]), this.param.reason != null && n.push([e.dim("reason"), this.param.reason]), this.flagDefinition?.help != null && n.push([e.dim("help"), e.green(this.flagDefinition.help)]), v(t, {
163
- title: `flag ${_(this.param.flag)} is invalid`,
204
+ this.param.value != null && n.push([e.dim("value"), e.yellow(`"${this.param.value}"`)]), this.param.reason != null && n.push([e.dim("reason"), this.param.reason]), this.flagDefinition?.help != null && n.push([e.dim("help"), e.green(this.flagDefinition.help)]), y(t, {
205
+ title: `flag ${v(this.param.flag)} is invalid`,
164
206
  details: n
165
207
  });
166
208
  }
167
- }, D = class extends g {
209
+ }, A = class extends _ {
210
+ $type = "TooManyArguments";
168
211
  constructor(e, t) {
169
212
  super(`Too many arguments provided. Expected ${e}, got ${t}.`), this.expected = e, this.received = t;
170
213
  }
171
214
  pretty(t) {
172
- v(t, {
215
+ y(t, {
173
216
  title: "too many arguments",
174
217
  details: [[e.dim("expected"), e.green(String(this.expected))], [e.dim("received"), e.bold.yellow(String(this.received))]]
175
218
  });
176
219
  }
177
- }, O = class extends Error {
178
- constructor(e) {
179
- super(e);
180
- }
181
- }, k = class {
220
+ }, j = class {
182
221
  flags;
183
222
  parsedFlags = null;
184
223
  args;
@@ -191,7 +230,7 @@ var S = class extends g {
191
230
  this.opts = e, this.ux = e.ux, this.flags = e.flags, this.args = e.args;
192
231
  }
193
232
  async init(e) {
194
- let { _: t, ...n } = r(e);
233
+ let { _: t, ...n } = i(e);
195
234
  return this.shouldValidateUnknownFlags && this.validateUnknownFlags(n), this.parsedFlags = await this.handleOptions(n), this.parsedArgs = await this.handleArguments(t), {
196
235
  flags: this.parsedFlags,
197
236
  args: this.parsedArgs
@@ -206,7 +245,7 @@ var S = class extends g {
206
245
  }
207
246
  async setFlag(e, t) {
208
247
  if (!this.parsedFlags) throw Error("Flags have not been parsed yet. Call init() first.");
209
- if (!(e in this.flags)) throw new S(e, this.flags);
248
+ if (!(e in this.flags)) throw new w(e, this.flags);
210
249
  this.parsedFlags[e] = t;
211
250
  }
212
251
  argument(e, t) {
@@ -215,7 +254,7 @@ var S = class extends g {
215
254
  }
216
255
  async setArgument(e, t) {
217
256
  if (!this.parsedArgs) throw Error("Arguments have not been parsed yet. Call init() first.");
218
- if (!(e in this.args)) throw new T({
257
+ if (!(e in this.args)) throw new O({
219
258
  arg: e,
220
259
  reason: `Argument "${e}" is not recognized`
221
260
  });
@@ -224,6 +263,9 @@ var S = class extends g {
224
263
  isEmptyValue(e) {
225
264
  return e == null || typeof e == "string" && e.trim() === "" || Array.isArray(e) && e.length === 0;
226
265
  }
266
+ isMissing(e) {
267
+ return e == null || Array.isArray(e) && e.length === 0;
268
+ }
227
269
  validateUnknownFlags(e) {
228
270
  let t = /* @__PURE__ */ new Set();
229
271
  for (let e in this.flags) {
@@ -231,7 +273,7 @@ var S = class extends g {
231
273
  let n = this.flags[e], r = Array.isArray(n.alias) ? n.alias : n.alias ? [n.alias] : [];
232
274
  for (let e of r) t.add(e);
233
275
  }
234
- for (let n in e) if (!t.has(n)) throw new S(n, this.flags);
276
+ for (let n in e) if (!t.has(n)) throw new w(n, this.flags);
235
277
  }
236
278
  async handleOptions(e) {
237
279
  let t = {};
@@ -242,13 +284,13 @@ var S = class extends g {
242
284
  let t = {}, n = [...e], r = Object.keys(this.args).length;
243
285
  for (let e in this.args) {
244
286
  let r = this.args[e];
245
- if ("multiple" in r && r.multiple) {
287
+ if (r.multiple) {
246
288
  t[e] = await this.parseValue(n, r, "arg", { name: e }), n.length = 0;
247
289
  continue;
248
290
  }
249
291
  t[e] = await this.parseValue(n.shift(), r, "arg", { name: e });
250
292
  }
251
- if (this.shouldRejectExtraArguments && n.length > 0) throw new D(r, r + n.length);
293
+ if (this.shouldRejectExtraArguments && n.length > 0) throw new A(r, r + n.length);
252
294
  return t;
253
295
  }
254
296
  async resolveFlagValue(e, t, n) {
@@ -261,8 +303,8 @@ var S = class extends g {
261
303
  return this.parseValue(r, t, "flag", { name: e });
262
304
  }
263
305
  async parseValue(e, t, n, r) {
264
- if (this.isEmptyValue(e)) return typeof t.default == "function" ? await t.default() : t.default;
265
- if ("multiple" in t && t.multiple) {
306
+ if (this.isMissing(e)) return typeof t.default == "function" ? await t.default() : t.default;
307
+ if (t.multiple) {
266
308
  Array.isArray(e) || (e = [e]);
267
309
  let i = [];
268
310
  for (let a of e) i.push(await this.safeParse(a, t, n, r));
@@ -276,20 +318,20 @@ var S = class extends g {
276
318
  ux: this.ux,
277
319
  ctx: this.opts.ctx,
278
320
  definition: t,
279
- cmd: this.opts.cmd ?? X
321
+ cmd: this.opts.cmd ?? Q
280
322
  };
281
323
  }
282
324
  async safeParse(e, t, n, r) {
283
325
  try {
284
326
  return t.parse(e, this.buildOpts(r?.name ?? "", t));
285
327
  } catch (t) {
286
- if (t instanceof E || t instanceof T || !r) throw t;
287
- let i = t instanceof Error ? t.message : String(t);
288
- throw n === "flag" ? new E({
328
+ if (t instanceof k || t instanceof O || !(t instanceof D) || !r) throw t;
329
+ let i = t.message;
330
+ throw n === "flag" ? new k({
289
331
  flag: r.name,
290
332
  value: e,
291
333
  reason: i
292
- }) : new T({
334
+ }) : new O({
293
335
  arg: r.name,
294
336
  value: e,
295
337
  reason: i
@@ -300,10 +342,10 @@ var S = class extends g {
300
342
  for (let r in e) {
301
343
  let i = e[r], a = t?.[r], o = this.isEmptyValue(a);
302
344
  if (i.required && o) {
303
- if (!this.shouldPromptForMissingFlags) throw n === "flag" ? new w(r) : new C(r);
345
+ if (!this.shouldPromptForMissingFlags) throw n === "flag" ? new E(r) : new T(r);
304
346
  let e = await this.promptFor(r, i);
305
347
  if (e != null && t) a = await this.parseValue(e, i, n, { name: r }), t[r] = a;
306
- else throw n === "flag" ? new w(r) : new C(r);
348
+ else throw n === "flag" ? new E(r) : new T(r);
307
349
  }
308
350
  }
309
351
  }
@@ -322,68 +364,78 @@ var S = class extends g {
322
364
  };
323
365
  //#endregion
324
366
  //#region src/flags/custom.ts
325
- function A(e) {
326
- function t(t) {
367
+ function M(e = {}) {
368
+ return function(t) {
327
369
  return {
328
370
  type: "custom",
329
- default: e?.multiple || t?.multiple ? [] : null,
371
+ default: e.multiple || t?.multiple ? [] : null,
372
+ parse: (e) => e,
330
373
  ...e,
331
374
  ...t
332
375
  };
333
- }
334
- return t;
376
+ };
335
377
  }
336
378
  //#endregion
337
379
  //#region src/shared/parsers.ts
338
- function re(e) {
339
- if (typeof e == "boolean") throw Error(`Expected a string, got boolean "${e}"`);
380
+ function ge(e) {
381
+ if (typeof e == "boolean") throw new D(`Expected a string, got boolean "${e}"`);
340
382
  return String(e);
341
383
  }
342
- function ie(e, t) {
384
+ function _e(e, t) {
343
385
  let n = typeof e == "number" ? e : Number(e);
344
- if (isNaN(n)) throw new O("must be a valid number");
345
- if (t?.min !== void 0 && n < t.min) throw new O(`is below minimum ${t.min}`);
346
- if (t?.max !== void 0 && n > t.max) throw new O(`exceeds maximum ${t.max}`);
386
+ if (isNaN(n)) throw new D("must be a valid number");
387
+ if (t?.min !== void 0 && n < t.min) throw new D(`is below minimum ${t.min}`);
388
+ if (t?.max !== void 0 && n > t.max) throw new D(`exceeds maximum ${t.max}`);
347
389
  return n;
348
390
  }
349
- function ae(e) {
391
+ function ve(e) {
350
392
  if (typeof e == "boolean") return e;
351
393
  let t = String(e).toLowerCase();
352
394
  if (t === "true" || t === "1") return !0;
353
395
  if (t === "false" || t === "0") return !1;
354
- throw new O(`Invalid boolean value: "${e}". Expected true, false, 1, or 0.`);
396
+ throw new D(`Invalid boolean value: "${e}". Expected true, false, 1, or 0.`);
355
397
  }
356
- function oe(e, t) {
398
+ function ye(e, t) {
357
399
  let n = String(e);
358
- if (!t.includes(n)) throw new O(`must be one of: ${t.map((e) => `"${e}"`).join(", ")}`);
400
+ if (!t.includes(n)) throw new D(`must be one of: ${t.map((e) => `"${e}"`).join(", ")}`);
359
401
  return n;
360
402
  }
361
- function se(e, n) {
403
+ function be(e, n) {
362
404
  let r = String(e);
363
- if (n?.exists && !t.existsSync(r)) throw new O("file does not exist");
405
+ if (n?.exists) try {
406
+ t.accessSync(r, t.constants.F_OK);
407
+ } catch (e) {
408
+ let t = e.code;
409
+ throw t === "ENOENT" ? new D("file does not exist") : t === "EACCES" ? new D("file is not accessible (permission denied)") : new D(`file is not accessible (${t ?? e.message})`);
410
+ }
364
411
  return r;
365
412
  }
366
- function ce(e, n) {
413
+ function xe(e, n) {
367
414
  let r = String(e);
368
- if (n?.exists) try {
369
- if (!t.lstatSync(r).isDirectory()) throw new O("directory does not exist");
370
- } catch (e) {
371
- throw e instanceof O ? e : new O("directory does not exist");
415
+ if (n?.exists) {
416
+ let e;
417
+ try {
418
+ e = t.lstatSync(r);
419
+ } catch (e) {
420
+ let t = e.code;
421
+ throw t === "ENOENT" ? new D("directory does not exist") : t === "EACCES" ? new D("directory is not accessible (permission denied)") : t === "ELOOP" ? new D("symlink loop detected") : new D(`directory is not accessible (${t ?? e.message})`);
422
+ }
423
+ if (!e.isDirectory()) throw new D("path is not a directory");
372
424
  }
373
425
  return r;
374
426
  }
375
- function le(e) {
427
+ function Se(e) {
376
428
  try {
377
429
  return new URL(String(e));
378
- } catch {
379
- throw new O(`Invalid URL: "${e}"`);
430
+ } catch (t) {
431
+ throw new D(`Invalid URL "${e}": ${t instanceof Error ? t.message : String(t)}`);
380
432
  }
381
433
  }
382
434
  //#endregion
383
435
  //#region src/flags/boolean.ts
384
- var ue = A({
436
+ var Ce = M({
385
437
  default: !1,
386
- parse: (e) => ae(e),
438
+ parse: (e) => ve(e),
387
439
  ask: async (e) => {
388
440
  let t = b(e.name, e.definition);
389
441
  return await e.ux.askForToggle(t);
@@ -392,18 +444,19 @@ var ue = A({
392
444
  });
393
445
  //#endregion
394
446
  //#region src/shared/ask-helpers.ts
395
- function j(e, t) {
447
+ function N(e, t) {
396
448
  return (n) => {
397
449
  if ((n == null || typeof n == "string" && n.trim() === "") && e.required) return "This value is required";
398
450
  try {
399
451
  e.parse(n, t);
400
452
  } catch (e) {
401
- return e instanceof O ? e.message : "Invalid value";
453
+ if (e instanceof D) return e.message;
454
+ throw e;
402
455
  }
403
456
  return !0;
404
457
  };
405
458
  }
406
- function M(e, t) {
459
+ function P(e, t) {
407
460
  return (n) => {
408
461
  if ((n == null || n.trim() === "") && e.required) return "Please enter at least one value";
409
462
  for (let r of n.split(",")) {
@@ -411,123 +464,126 @@ function M(e, t) {
411
464
  if (n !== "") try {
412
465
  e.parse(n, t);
413
466
  } catch (e) {
414
- return e instanceof O ? `"${n}": ${e.message}` : `"${n}": Invalid value`;
467
+ if (e instanceof D) return `"${n}": ${e.message}`;
468
+ throw e;
415
469
  }
416
470
  }
417
471
  return !0;
418
472
  };
419
473
  }
420
- async function de(e) {
421
- let t = e.definition, n = "multiple" in t && t.multiple, r = b(e.name, t);
474
+ async function we(e) {
475
+ let t = e.definition, n = t.multiple === !0, r = b(e.name, t);
422
476
  return n ? await e.ux.askForList(r + "Please provide one or more values, separated by commas:\n", {
423
477
  separator: ",",
424
- validate: M(t, e)
425
- }) : "secret" in t && t.secret ? e.ux.askForPassword(r, { validate: j(t, e) }) : await e.ux.askForInput(r, { validate: j(t, e) });
478
+ validate: P(t, e)
479
+ }) : t.secret ? e.ux.askForPassword(r, { validate: N(t, e) }) : await e.ux.askForInput(r, { validate: N(t, e) });
426
480
  }
427
- async function fe(e) {
428
- let t = e.definition, n = "multiple" in t && t.multiple, r = b(e.name, t);
481
+ async function Te(e) {
482
+ let t = e.definition, n = t.multiple === !0, r = b(e.name, t);
429
483
  return n ? await e.ux.askForList(r + "Please provide one or more values, separated by commas:\n", {
430
484
  separator: ",",
431
- validate: M(t, e)
485
+ validate: P(t, e)
432
486
  }) : await e.ux.askForNumber(r, { validate: (n) => {
433
487
  if (n === void 0 && t.required) return "This value is required";
434
488
  if (n !== void 0) try {
435
489
  t.parse(String(n), e);
436
490
  } catch (e) {
437
- return e instanceof O ? e.message : "Invalid value";
491
+ if (e instanceof D) return e.message;
492
+ throw e;
438
493
  }
439
494
  return !0;
440
495
  } });
441
496
  }
442
- async function pe(e) {
443
- let t = e.definition, n = "multiple" in t && t.multiple, r = b(e.name, t);
444
- if (t.type !== "option") return null;
497
+ async function Ee(e) {
498
+ let t = e.definition, n = t.multiple === !0, r = b(e.name, t);
499
+ if (!C(t)) return null;
445
500
  let i = t.options.map((e) => ({
446
501
  name: e,
447
502
  value: e
448
503
  }));
449
504
  return n ? await e.ux.askForCheckbox(r, i) : await e.ux.askForSelect(r, i);
450
505
  }
451
- async function me(e) {
506
+ async function De(e) {
452
507
  let t = b(e.name, e.definition);
453
508
  return e.ux.askForFile(t, { basePath: process.cwd() });
454
509
  }
455
- async function he(e) {
510
+ async function Oe(e) {
456
511
  let t = b(e.name, e.definition);
457
512
  return e.ux.askForDirectory(t, { basePath: process.cwd() });
458
513
  }
459
- async function ge(e) {
514
+ async function ke(e) {
460
515
  let t = b(e.name, e.definition);
461
- return await e.ux.askForInput(t, { validate: j(e.definition, e) });
516
+ return await e.ux.askForInput(t, { validate: N(e.definition, e) });
462
517
  }
463
518
  //#endregion
464
519
  //#region src/flags/directory.ts
465
- var N = A({
466
- parse: (e, t) => ce(e, { exists: t.definition.exists }),
467
- ask: he,
520
+ var F = M({
521
+ parse: (e, t) => xe(e, { exists: t.definition.exists }),
522
+ ask: Oe,
468
523
  type: "directory"
469
- }), P = A({
470
- parse: (e, t) => se(e, { exists: t.definition.exists }),
471
- ask: me,
524
+ }), I = M({
525
+ parse: (e, t) => be(e, { exists: t.definition.exists }),
526
+ ask: De,
472
527
  type: "file"
473
- }), F = A({
474
- parse: (e, t) => ie(e, {
528
+ }), L = M({
529
+ parse: (e, t) => _e(e, {
475
530
  min: t.definition.min,
476
531
  max: t.definition.max
477
532
  }),
478
- ask: fe,
533
+ ask: Te,
479
534
  type: "number"
480
535
  });
481
536
  //#endregion
482
537
  //#region src/flags/option.ts
483
- function I(e) {
484
- return A({
485
- parse: (e, t) => oe(e, t.definition.options),
486
- ask: pe,
487
- ...e,
488
- type: "option"
489
- })();
538
+ function R(e) {
539
+ let { options: t, ...n } = e;
540
+ return M({
541
+ type: "option",
542
+ ask: Ee,
543
+ parse: (e) => ye(e, t ?? []),
544
+ ...e
545
+ })(n);
490
546
  }
491
547
  //#endregion
492
548
  //#region src/flags/string.ts
493
- var L = A({
494
- parse: (e) => re(e),
495
- ask: de,
549
+ var z = M({
550
+ parse: (e) => ge(e),
551
+ ask: we,
496
552
  type: "string"
497
- }), R = A({
498
- parse: (e) => le(e),
499
- ask: ge,
553
+ }), B = M({
554
+ parse: (e) => Se(e),
555
+ ask: ke,
500
556
  type: "url"
501
- }), z = {
502
- string: L,
503
- number: F,
504
- option: I,
505
- file: P,
506
- directory: N,
507
- url: R,
508
- custom: A
509
- }, B = {
510
- string: L,
511
- number: F,
512
- boolean: ue,
513
- option: I,
514
- file: P,
515
- directory: N,
516
- url: R,
517
- custom: A
557
+ }), V = {
558
+ string: z,
559
+ number: L,
560
+ option: R,
561
+ file: I,
562
+ directory: F,
563
+ url: B,
564
+ custom: M
565
+ }, H = {
566
+ string: z,
567
+ number: L,
568
+ boolean: Ce,
569
+ option: R,
570
+ file: I,
571
+ directory: F,
572
+ url: B,
573
+ custom: M
518
574
  };
519
575
  //#endregion
520
576
  //#region src/lib/string.ts
521
- function V(e) {
577
+ function U(e) {
522
578
  return Array(e + 5).join(" ");
523
579
  }
524
580
  //#endregion
525
581
  //#region src/HelpFlag.ts
526
- function _e(e) {
582
+ function Ae(e) {
527
583
  let t = e.type;
528
- return t === "option" && "options" in e && e.options ? `enum: ${e.options.join("|")}` : t ?? "custom";
584
+ return C(e) ? `enum: ${e.options.join("|")}` : t ?? "custom";
529
585
  }
530
- var ve = B.boolean({
586
+ var je = H.boolean({
531
587
  alias: ["h"],
532
588
  description: "Displays help information about the command",
533
589
  handler: (t, n) => {
@@ -540,7 +596,7 @@ var ve = B.boolean({
540
596
  return {
541
597
  name: e,
542
598
  ...t,
543
- flagWithAlias: `--${e}${n.map((e) => `, -${e}`).join("")}`
599
+ flagWithAlias: `--${e}${n.map((e) => `, ${S(e)}`).join("")}`
544
600
  };
545
601
  }), l = o.filter(([, e]) => e.required);
546
602
  console.log(e.yellow("Description:")), console.log(` ${r.description}\n`), r.aliases.length > 0 && (console.log(e.yellow("Aliases:")), console.log(` ${r.aliases.join(", ")}\n`)), console.log(e.yellow("Usage:")), console.log(` ${r.command} ${l.length > 0 ? l.map(([e]) => `<${e}>`).join(" ") : "\b"} [options]`);
@@ -548,19 +604,19 @@ var ve = B.boolean({
548
604
  if (o.length > 0) {
549
605
  console.log(`\n${e.yellow("Arguments")}:`);
550
606
  for (let [t, n] of o) {
551
- let r = V(f - t.length), i = ` ${e.green(t)} ${r} ${n.description ?? "\b"}`;
607
+ let r = U(f - t.length), i = ` ${e.green(t)} ${r} ${n.description ?? "\b"}`;
552
608
  if (n.default !== void 0 && !n.required) {
553
609
  let t = typeof n.default == "function" ? "[function]" : n.multiple ? JSON.stringify(n.default) : n.default;
554
610
  i += ` ${e.yellow(`[default: ${t}]`)}`;
555
611
  }
556
- "multiple" in n && n.multiple && (i += ` ${e.white("(variadic)")}`), console.log(i);
612
+ n.multiple && (i += ` ${e.white("(multiple)")}`), console.log(i);
557
613
  }
558
614
  }
559
615
  if (s.length > 0) {
560
616
  console.log(`\n${e.yellow("Options")}:`);
561
617
  for (let t of c) {
562
- let n = V(f - t.flagWithAlias.length), r = ` ${e.green(t.flagWithAlias)} ${n} ${t.description ?? "\b"}`;
563
- if (t.type && (r += ` ${e.white(`(${_e(t)})`)}`), t.default !== void 0 && !t.required) {
618
+ let n = U(f - t.flagWithAlias.length), r = ` ${e.green(t.flagWithAlias)} ${n} ${t.description ?? "\b"}`;
619
+ if (t.type && (r += ` ${e.white(`(${Ae(t)})`)}`), t.default !== void 0 && !t.required) {
564
620
  let n = typeof t.default == "function" ? "(function)" : t.default;
565
621
  r += ` ${e.yellow(`[default: ${n}]`)}`;
566
622
  }
@@ -576,22 +632,24 @@ var ve = B.boolean({
576
632
  }
577
633
  return { shouldStop: !0 };
578
634
  }
579
- }), ye = class extends Error {
635
+ }), Me = class extends Error {
580
636
  name = "ExitPromptError";
581
- };
637
+ }, Ne = /* @__PURE__ */ ce(((e, t) => {
638
+ t.exports = {};
639
+ }));
582
640
  //#endregion
583
641
  //#region src/ux/helpers.ts
584
- async function H(e, t) {
642
+ async function W(e, t) {
585
643
  try {
586
644
  return await e();
587
645
  } catch (e) {
588
- if (e instanceof ye || e instanceof Error && e.name === "ExitPromptError") return t;
646
+ if (e instanceof Me || e instanceof Error && e.name === "ExitPromptError") return t;
589
647
  throw e;
590
648
  }
591
649
  }
592
650
  //#endregion
593
651
  //#region src/ux/askForCheckbox.ts
594
- async function U(e, t, n) {
652
+ async function G(e, t, n) {
595
653
  if (t.length === 0) throw Error("No options provided");
596
654
  let r = t.map((e) => typeof e == "string" ? {
597
655
  name: e,
@@ -603,7 +661,7 @@ async function U(e, t, n) {
603
661
  checked: e.checked,
604
662
  description: e.description
605
663
  });
606
- return H(() => i({
664
+ return W(() => a({
607
665
  message: e,
608
666
  choices: r,
609
667
  required: n?.required,
@@ -615,17 +673,17 @@ async function U(e, t, n) {
615
673
  }
616
674
  //#endregion
617
675
  //#region src/ux/askForConfirmation.ts
618
- async function W(e = "Do you want to continue?", t) {
619
- return H(() => a({
676
+ async function K(e = "Do you want to continue?", t) {
677
+ return W(() => o({
620
678
  message: e,
621
679
  default: t?.default ?? !1,
622
680
  transformer: t?.transformer
623
- }), !1);
681
+ }), null);
624
682
  }
625
683
  //#endregion
626
684
  //#region src/ux/askForEditor.ts
627
- async function G(e, t) {
628
- return H(() => o({
685
+ async function q(e, t) {
686
+ return W(() => s({
629
687
  message: e,
630
688
  default: t?.default,
631
689
  postfix: t?.postfix,
@@ -635,8 +693,8 @@ async function G(e, t) {
635
693
  }
636
694
  //#endregion
637
695
  //#region src/ux/askForExpand.ts
638
- async function K(e, t, n) {
639
- return H(() => s({
696
+ async function Pe(e, t, n) {
697
+ return W(() => c({
640
698
  message: e,
641
699
  choices: t,
642
700
  default: n?.default
@@ -644,9 +702,9 @@ async function K(e, t, n) {
644
702
  }
645
703
  //#endregion
646
704
  //#region src/ux/askForFileSelector.ts
647
- async function q(e, t) {
648
- return H(async () => {
649
- let n = await ee({
705
+ async function J(e, t) {
706
+ return W(async () => {
707
+ let n = await te({
650
708
  message: e,
651
709
  basePath: t?.basePath,
652
710
  type: t?.type === "file+directory" ? void 0 : t?.type,
@@ -660,8 +718,8 @@ async function q(e, t) {
660
718
  }
661
719
  //#endregion
662
720
  //#region src/ux/askForInput.ts
663
- async function J(e, t) {
664
- return H(() => c({
721
+ async function Y(e, t) {
722
+ return W(() => l({
665
723
  message: e,
666
724
  default: t?.default,
667
725
  required: t?.required,
@@ -671,9 +729,9 @@ async function J(e, t) {
671
729
  }
672
730
  //#endregion
673
731
  //#region src/ux/askForList.ts
674
- async function be(e, t) {
732
+ async function Fe(e, t) {
675
733
  let n = t?.separator ?? ",";
676
- return H(async () => (await c({
734
+ return W(async () => (await l({
677
735
  message: e,
678
736
  default: t?.default,
679
737
  validate: t?.validate
@@ -681,8 +739,8 @@ async function be(e, t) {
681
739
  }
682
740
  //#endregion
683
741
  //#region src/ux/askForNumber.ts
684
- async function xe(e, t) {
685
- return H(async () => await l({
742
+ async function Ie(e, t) {
743
+ return W(async () => await u({
686
744
  message: e,
687
745
  default: t?.default,
688
746
  required: t?.required,
@@ -694,8 +752,8 @@ async function xe(e, t) {
694
752
  }
695
753
  //#endregion
696
754
  //#region src/ux/askForPassword.ts
697
- async function Se(e, t) {
698
- return H(() => u({
755
+ async function Le(e, t) {
756
+ return W(() => d({
699
757
  message: e,
700
758
  mask: t?.mask,
701
759
  validate: t?.validate
@@ -703,8 +761,8 @@ async function Se(e, t) {
703
761
  }
704
762
  //#endregion
705
763
  //#region src/ux/askForRawList.ts
706
- async function Ce(e, t, n) {
707
- return H(() => d({
764
+ async function Re(e, t, n) {
765
+ return W(() => f({
708
766
  message: e,
709
767
  choices: t,
710
768
  loop: n?.loop
@@ -712,8 +770,8 @@ async function Ce(e, t, n) {
712
770
  }
713
771
  //#endregion
714
772
  //#region src/ux/askForSearch.ts
715
- async function we(e, t, n) {
716
- return H(() => f({
773
+ async function ze(e, t, n) {
774
+ return W(() => p({
717
775
  message: e,
718
776
  source: t,
719
777
  pageSize: n?.pageSize,
@@ -722,13 +780,13 @@ async function we(e, t, n) {
722
780
  }
723
781
  //#endregion
724
782
  //#region src/ux/askForSelect.ts
725
- async function Te(e, t, n) {
783
+ async function Be(e, t, n) {
726
784
  if (t.length === 0) throw Error("No options provided");
727
785
  let r = t.map((e) => typeof e == "string" ? {
728
786
  name: e,
729
787
  value: e
730
788
  } : e);
731
- return H(() => p({
789
+ return W(() => ee({
732
790
  message: e,
733
791
  choices: r,
734
792
  default: n?.default,
@@ -738,17 +796,17 @@ async function Te(e, t, n) {
738
796
  }
739
797
  //#endregion
740
798
  //#region src/ux/askForToggle.ts
741
- async function Ee(e, t) {
799
+ async function X(e, t) {
742
800
  let n = t?.active ?? "Yes", r = t?.inactive ?? "No";
743
- return H(() => a({
801
+ return W(() => o({
744
802
  message: e,
745
803
  default: t?.default ?? !1,
746
804
  transformer: (e) => e ? n : r
747
- }), !1);
805
+ }), null);
748
806
  }
749
807
  //#endregion
750
808
  //#region src/ux/keyValue.ts
751
- function De(t, n) {
809
+ function Ve(t, n) {
752
810
  let r = n?.separator ?? ": ", i = n?.keyStyle ?? e.bold, a = Array.isArray(t) ? t : Object.entries(t);
753
811
  if (a.length === 0) return;
754
812
  let o = Math.max(...a.map(([e]) => e.length));
@@ -756,7 +814,7 @@ function De(t, n) {
756
814
  }
757
815
  //#endregion
758
816
  //#region src/ux/loader.ts
759
- function Oe(e = "", t = [
817
+ function He(e = "", t = [
760
818
  "⠙",
761
819
  "⠘",
762
820
  "⠰",
@@ -770,7 +828,7 @@ function Oe(e = "", t = [
770
828
  ], n = 100) {
771
829
  let r = e, i = null, a = e.length, o = 0, s = (e) => {
772
830
  let t = process.stdout.columns || 80, n = e + 2, r = Math.max(1, Math.ceil(n / t));
773
- if (process.stdout.isTTY && process.stdout.clearLine && process.stdout.moveCursor) {
831
+ if (process.stdout.isTTY && process.stdout.clearLine && process.stdout.moveCursor && process.stdout.cursorTo) {
774
832
  r > 1 && process.stdout.moveCursor(0, -(r - 1));
775
833
  for (let e = 0; e < r; e++) process.stdout.cursorTo(0), process.stdout.clearLine(1), e < r - 1 && process.stdout.moveCursor(0, 1);
776
834
  r > 1 && process.stdout.moveCursor(0, -(r - 1)), process.stdout.cursorTo(0);
@@ -791,11 +849,11 @@ function Oe(e = "", t = [
791
849
  }
792
850
  //#endregion
793
851
  //#region src/ux/progressBar.ts
794
- function ke(e, t) {
852
+ function Ue(e, t) {
795
853
  let n = t?.width ?? 30, r = t?.completeChar ?? "█", i = t?.incompleteChar ?? "░", a = 0, o = !1, s = () => {
796
854
  if (o) return;
797
- let t = e <= 0 ? 1 : Math.min(a / e, 1), s = Math.round(t * n), c = `${r.repeat(s) + i.repeat(n - s)} ${Math.round(t * 100)}% ${a}/${e}`;
798
- process.stdout.write("\r" + c);
855
+ let t = e <= 0 ? 1 : Math.min(a / e, 1), s = Math.round(t * n), l = `${r.repeat(s) + i.repeat(n - s)} ${Math.round(t * 100)}% ${a}/${e}`;
856
+ process.stdout.write("\r" + l), (e <= 0 || a >= e) && c();
799
857
  }, c = () => {
800
858
  o || (o = !0, process.stdout.write("\n"));
801
859
  };
@@ -813,7 +871,7 @@ function ke(e, t) {
813
871
  }
814
872
  //#endregion
815
873
  //#region src/ux/table.ts
816
- function Ae(t, n) {
874
+ function We(t, n) {
817
875
  if (t.length === 0) return;
818
876
  let r = n ?? Object.keys(t[0]).map((e) => ({ key: e })), i = r.map((e) => e.header ?? e.key.toUpperCase()), a = r.map((e, n) => {
819
877
  let r = Math.max(i[n].length, ...t.map((t) => (e.format ? e.format(t[e.key]) : String(t[e.key] ?? "")).length));
@@ -839,71 +897,71 @@ function Ae(t, n) {
839
897
  }
840
898
  //#endregion
841
899
  //#region src/ux/index.ts
842
- var Y = class {
900
+ var Z = class {
843
901
  askForConfirmation(e, t) {
844
- return W(e, t);
902
+ return K(e, t);
845
903
  }
846
904
  askForInput(e, t) {
847
- return J(e, t);
905
+ return Y(e, t);
848
906
  }
849
907
  askForPassword(e, t) {
850
- return Se(e, t);
908
+ return Le(e, t);
851
909
  }
852
910
  askForNumber(e, t) {
853
- return xe(e, t);
911
+ return Ie(e, t);
854
912
  }
855
913
  askForSelect(e, t, n) {
856
- return Te(e, t, n);
914
+ return Be(e, t, n);
857
915
  }
858
916
  askForCheckbox(e, t, n) {
859
- return U(e, t, n);
917
+ return G(e, t, n);
860
918
  }
861
919
  askForSearch(e, t, n) {
862
- return we(e, t, n);
920
+ return ze(e, t, n);
863
921
  }
864
922
  askForList(e, t) {
865
- return be(e, t);
923
+ return Fe(e, t);
866
924
  }
867
925
  askForToggle(e, t) {
868
- return Ee(e, t);
926
+ return X(e, t);
869
927
  }
870
928
  askForEditor(e, t) {
871
- return G(e, t);
929
+ return q(e, t);
872
930
  }
873
931
  askForRawList(e, t, n) {
874
- return Ce(e, t, n);
932
+ return Re(e, t, n);
875
933
  }
876
934
  askForExpand(e, t, n) {
877
- return K(e, t, n);
935
+ return Pe(e, t, n);
878
936
  }
879
937
  askForFile(e, t) {
880
- return q(e, {
938
+ return J(e, {
881
939
  ...t,
882
940
  type: "file"
883
941
  });
884
942
  }
885
943
  askForDirectory(e, t) {
886
- return q(e, {
944
+ return J(e, {
887
945
  ...t,
888
946
  type: "directory"
889
947
  });
890
948
  }
891
949
  askForFileSelector(e, t) {
892
- return q(e, t);
950
+ return J(e, t);
893
951
  }
894
952
  keyValue(e, t) {
895
- return De(e, t);
953
+ return Ve(e, t);
896
954
  }
897
955
  table(e, t) {
898
- return Ae(e, t);
956
+ return We(e, t);
899
957
  }
900
958
  newProgressBar(e, t) {
901
- return ke(e, t);
959
+ return Ue(e, t);
902
960
  }
903
961
  newLoader(e, t, n) {
904
- return Oe(e, t, n);
962
+ return He(e, t, n);
905
963
  }
906
- }, X = class {
964
+ }, Q = class {
907
965
  static $type = "BobCommand";
908
966
  static command = "";
909
967
  static description = "";
@@ -921,9 +979,9 @@ var Y = class {
921
979
  logger;
922
980
  ux;
923
981
  parser;
924
- static baseFlags = { help: ve };
982
+ static baseFlags = { help: je };
925
983
  newCommandParser(e) {
926
- return new k({
984
+ return new j({
927
985
  ux: e.ux,
928
986
  ctx: e.ctx,
929
987
  flags: e.flags,
@@ -932,7 +990,7 @@ var Y = class {
932
990
  });
933
991
  }
934
992
  newUX() {
935
- return new Y();
993
+ return new Z();
936
994
  }
937
995
  async run(e) {
938
996
  let t = this.constructor;
@@ -964,7 +1022,7 @@ var Y = class {
964
1022
  definition: a,
965
1023
  cmd: t
966
1024
  }, o = a.handler(i, r);
967
- if (o && o.shouldStop) return -1;
1025
+ if (o && o.shouldStop) return 0;
968
1026
  }
969
1027
  }
970
1028
  await this.parser.validate(), n = {
@@ -981,22 +1039,22 @@ var Y = class {
981
1039
  };
982
1040
  //#endregion
983
1041
  //#region src/lib/helpers.ts
984
- function je(e) {
985
- return typeof e == "object" && !!e && "$type" in e && e.$type === "BobError";
1042
+ function Ge(e) {
1043
+ return e instanceof _;
986
1044
  }
987
- function Z(e) {
988
- return typeof e == "function" ? e.prototype instanceof X || e.$type === "BobCommand" : !1;
1045
+ function $(e) {
1046
+ return typeof e == "function" ? e.prototype instanceof Q || e.$type === "BobCommand" : !1;
989
1047
  }
990
1048
  //#endregion
991
1049
  //#region src/CommandRegistry.ts
992
- var Q = class {
1050
+ var Ke = .75, qe = .55, Je = .05, Ye = class {
993
1051
  commands = {};
994
1052
  aliases = {};
995
1053
  ux;
996
1054
  logger;
997
1055
  stringSimilarity;
998
1056
  constructor(e) {
999
- this.logger = e?.logger ?? new m(), this.ux = e?.ux ?? new Y(), this.stringSimilarity = e?.stringSimilarity ?? new h();
1057
+ this.logger = e?.logger ?? new m(), this.ux = e?.ux ?? new Z(), this.stringSimilarity = e?.stringSimilarity ?? new g();
1000
1058
  }
1001
1059
  getAvailableCommands() {
1002
1060
  return [...Object.keys(this.commands), ...Object.keys(this.aliases)];
@@ -1007,7 +1065,7 @@ var Q = class {
1007
1065
  importFile = async (e) => (await import(e)).default;
1008
1066
  commandResolver = async (e) => {
1009
1067
  let t = await this.importFile(e);
1010
- return t ? (t && typeof t == "object" && "default" in t && (t = t.default), typeof t == "function" && Z(t) ? t : null) : null;
1068
+ return t ? (t && typeof t == "object" && "default" in t && (t = t.default), typeof t == "function" && $(t) ? t : null) : null;
1011
1069
  };
1012
1070
  withCommandResolver(e) {
1013
1071
  return this.commandResolver = e, this;
@@ -1016,7 +1074,7 @@ var Q = class {
1016
1074
  return this.importFile = e, this;
1017
1075
  }
1018
1076
  registerCommand(e, t = !1) {
1019
- if (!Z(e)) throw Error("Invalid command, it must extend the Command class.");
1077
+ if (!$(e)) throw Error("Invalid command, it must extend the Command class.");
1020
1078
  let n = e.command;
1021
1079
  if (!n) throw Error(`Cannot register a command with no name. ${e.name} `);
1022
1080
  if (!t && this.commands[n]) throw Error(`Command ${n} already registered.`);
@@ -1031,7 +1089,7 @@ var Q = class {
1031
1089
  async loadCommandsPath(e) {
1032
1090
  for await (let t of this.listCommandsFiles(e)) try {
1033
1091
  let e = await this.commandResolver(t);
1034
- Z(e) && this.registerCommand(e);
1092
+ $(e) && this.registerCommand(e);
1035
1093
  } catch (e) {
1036
1094
  throw Error(`Command ${t} failed to load. ${e}`, { cause: e });
1037
1095
  }
@@ -1043,10 +1101,10 @@ var Q = class {
1043
1101
  if (!i) {
1044
1102
  let r = await this.suggestCommand(t);
1045
1103
  if (r) return await this.runCommand(e, r, ...n);
1046
- throw new y(t);
1104
+ throw new he(t);
1047
1105
  }
1048
1106
  r = new i();
1049
- } else r = Z(t) ? new t() : t;
1107
+ } else r = $(t) ? new t() : t;
1050
1108
  return await r.run({
1051
1109
  ctx: e,
1052
1110
  logger: this.logger,
@@ -1054,47 +1112,68 @@ var Q = class {
1054
1112
  }) ?? 0;
1055
1113
  }
1056
1114
  async suggestCommand(t) {
1057
- let n = this.getAvailableCommands(), { bestMatch: r, bestMatchIndex: i, ratings: a } = this.stringSimilarity.findBestMatch(t, n), o = a.filter((e) => e.rating > .3).map((e) => e.target);
1058
- if (r && (r.rating > 0 && o.length <= 1 || r.rating > .7 && o.length > 1)) {
1059
- let e = n[i];
1060
- return await this.askRunSimilarCommand(t, e) ? e : null;
1115
+ let n = this.getAvailableCommands();
1116
+ if (n.length === 0) return null;
1117
+ let { bestMatch: r, bestMatchIndex: i, ratings: a } = this.stringSimilarity.findBestMatch(t, n), o = [...a].sort((e, t) => t.rating - e.rating), s = o[1]?.rating ?? 0, c = o.filter((e) => e.rating >= qe).map((e) => e.target);
1118
+ if (r && r.rating >= Ke && r.rating - s > Je) {
1119
+ let e = n[i], r = await this.askRunSimilarCommand(t, e);
1120
+ return r === !0 ? e : (r === null && this.logger.debug(`suggestion prompt cancelled for "${t}"`), null);
1121
+ }
1122
+ if (c.length === 1) {
1123
+ let e = c[0], n = await this.askRunSimilarCommand(t, e);
1124
+ return n === !0 ? e : (n === null && this.logger.debug(`suggestion prompt cancelled for "${t}"`), null);
1061
1125
  }
1062
- if (o.length) return await this.ux.askForSelect(`${e.red("unknown command")} ${e.bold.yellow(`'${t}'`)} ${e.dim("—")} did you mean one of these?`, o) || null;
1063
- throw new y(t);
1126
+ if (c.length > 1) {
1127
+ let n = await this.ux.askForSelect(`${e.red("unknown command")} ${e.bold.yellow(`'${t}'`)} ${e.dim("—")} did you mean one of these?`, c);
1128
+ return n || (n === null && this.logger.debug(`suggestion selection cancelled for "${t}"`), null);
1129
+ }
1130
+ return null;
1064
1131
  }
1065
1132
  async askRunSimilarCommand(t, n) {
1066
1133
  return this.ux.askForConfirmation(`${e.red("unknown command")} ${e.bold.yellow(`'${t}'`)} ${e.dim("—")} did you mean ${e.bold.green(`'${n}'`)}?`);
1067
1134
  }
1068
1135
  async *listCommandsFiles(e) {
1069
- let r = await t.promises.readdir(e, { withFileTypes: !0 });
1070
- for (let t of r) {
1071
- let r = n.resolve(e, t.name);
1072
- if (t.isDirectory()) yield* this.listCommandsFiles(n.resolve(e, t.name));
1136
+ let n;
1137
+ try {
1138
+ n = await t.promises.readdir(e, { withFileTypes: !0 });
1139
+ } catch (t) {
1140
+ throw Error(`Failed to read commands directory "${e}": ${t.message}`, { cause: t });
1141
+ }
1142
+ for (let t of n) {
1143
+ let n = r.resolve(e, t.name);
1144
+ if (t.isDirectory()) yield* this.listCommandsFiles(r.resolve(e, t.name));
1073
1145
  else {
1074
- if (!r.endsWith(".ts") && !r.endsWith(".js") && !r.endsWith(".mjs") && !r.endsWith(".cjs")) continue;
1075
- yield r;
1146
+ if (!n.endsWith(".ts") && !n.endsWith(".js") && !n.endsWith(".mjs") && !n.endsWith(".cjs")) continue;
1147
+ yield n;
1076
1148
  }
1077
1149
  }
1078
1150
  }
1079
- }, Me = class {
1151
+ }, Xe = class {
1080
1152
  logger;
1081
1153
  constructor(e) {
1082
1154
  this.logger = e;
1083
1155
  }
1084
1156
  handle(e) {
1085
- if (je(e)) return e.pretty(this.logger), -1;
1157
+ if (Ge(e)) return e.pretty(this.logger), -1;
1086
1158
  throw e;
1087
1159
  }
1088
- }, Ne, Pe = class extends X {
1160
+ }, Ze = /* @__PURE__ */ ue(Ne(), 1);
1161
+ function Qe() {
1162
+ try {
1163
+ let e = n((0, Ze.fileURLToPath)(new URL("data:application/json;base64,ewogICJuYW1lIjogImJvYi1jb3JlIiwKICAidmVyc2lvbiI6ICIzLjAuMC1iZXRhLjYiLAogICJkZXNjcmlwdGlvbiI6ICJCT0IgQ29yZSIsCiAgInR5cGUiOiAibW9kdWxlIiwKICAibWFpbiI6ICIuL2Rpc3QvY2pzL3NyYy9pbmRleC5qcyIsCiAgIm1vZHVsZSI6ICIuL2Rpc3QvZXNtL3NyYy9pbmRleC5qcyIsCiAgInR5cGVzIjogIi4vZGlzdC9lc20vc3JjL2luZGV4LmQudHMiLAogICJmaWxlcyI6IFsKICAgICJkaXN0IgogIF0sCiAgImV4cG9ydHMiOiB7CiAgICAiLiI6IHsKICAgICAgImltcG9ydCI6IHsKICAgICAgICAidHlwZXMiOiAiLi9kaXN0L2VzbS9zcmMvaW5kZXguZC50cyIsCiAgICAgICAgImRlZmF1bHQiOiAiLi9kaXN0L2VzbS9zcmMvaW5kZXguanMiCiAgICAgIH0sCiAgICAgICJyZXF1aXJlIjogewogICAgICAgICJ0eXBlcyI6ICIuL2Rpc3QvY2pzL3NyYy9pbmRleC5kLnRzIiwKICAgICAgICAiZGVmYXVsdCI6ICIuL2Rpc3QvY2pzL3NyYy9pbmRleC5qcyIKICAgICAgfQogICAgfQogIH0sCiAgInNjcmlwdHMiOiB7CiAgICAic3RhcnQiOiAibm9kZSAtciBAc3djLW5vZGUvcmVnaXN0ZXIgZGVidWcvbWFpbi50cyIsCiAgICAiYnVpbGQiOiAicm0gLXJmIC4vZGlzdCAmJiB2aXRlIGJ1aWxkIiwKICAgICJ0eXBlY2hlY2siOiAidHNjIC0tbm9FbWl0IiwKICAgICJwcmVwYWNrIjogIm5wbSBydW4gYnVpbGQiLAogICAgInRlc3QiOiAidml0ZXN0IHJ1biIsCiAgICAibGludCI6ICJlc2xpbnQgLiIsCiAgICAibGludDpmaXgiOiAiZXNsaW50IC4gLS1maXgiCiAgfSwKICAiYXV0aG9yIjogIkzDqW8gSHViZXJ0IiwKICAibGljZW5zZSI6ICJJU0MiLAogICJkZXZEZXBlbmRlbmNpZXMiOiB7CiAgICAiQGVzbGludC9qcyI6ICJeOS4zOS40IiwKICAgICJAZmFrZXItanMvZmFrZXIiOiAiXjEwLjMuMCIsCiAgICAiQHN3Yy1ub2RlL3JlZ2lzdGVyIjogIl4xLjExLjEiLAogICAgIkB0cml2YWdvL3ByZXR0aWVyLXBsdWdpbi1zb3J0LWltcG9ydHMiOiAiXjUuMi4yIiwKICAgICJAdHlwZXMvbWluaW1pc3QiOiAiXjEuMi41IiwKICAgICJAdHlwZXMvbm9kZSI6ICJeMjAuMTQuNSIsCiAgICAiQHR5cGVzL3N0cmluZy1zaW1pbGFyaXR5IjogIl40LjAuMiIsCiAgICAiQHZpdGVzdC9jb3ZlcmFnZS12OCI6ICJeNC4xLjAiLAogICAgImVzbGludCI6ICJeOS4zOS40IiwKICAgICJlc2xpbnQtY29uZmlnLXByZXR0aWVyIjogIl4xMC4xLjgiLAogICAgImVzbGludC1wbHVnaW4tcHJldHRpZXIiOiAiXjUuNS41IiwKICAgICJwcmV0dGllciI6ICJeMy42LjIiLAogICAgInRzeCI6ICJeNC4yMS4wIiwKICAgICJ0eXBlc2NyaXB0IjogIl41LjkuMyIsCiAgICAidHlwZXNjcmlwdC1lc2xpbnQiOiAiXjguNTcuMCIsCiAgICAidml0ZSI6ICJeOC4wLjAiLAogICAgInZpdGUtcGx1Z2luLWR0cyI6ICJeNC41LjQiLAogICAgInZpdGVzdCI6ICJeNC4xLjAiCiAgfSwKICAiZGVwZW5kZW5jaWVzIjogewogICAgIkBpbnF1aXJlci9jb3JlIjogIl4xMS4xLjgiLAogICAgIkBpbnF1aXJlci9wcm9tcHRzIjogIl44LjQuMSIsCiAgICAiY2hhbGsiOiAiXjUuNi4yIiwKICAgICJpbnF1aXJlci1maWxlLXNlbGVjdG9yIjogIl4xLjAuMSIsCiAgICAibWluaW1pc3QiOiAiXjEuMi44IgogIH0KfQo=", "" + import.meta.url)), "utf8");
1164
+ return JSON.parse(e).version ?? "0.0.0";
1165
+ } catch {
1166
+ return "0.0.0";
1167
+ }
1168
+ }
1169
+ var $e = class extends Q {
1089
1170
  static command = "help";
1090
1171
  static description = e.bold("Show help information about the CLI and its commands");
1091
1172
  constructor(e) {
1092
1173
  super(), this.opts = e;
1093
1174
  }
1094
1175
  async handle() {
1095
- let t = this.opts.commandRegistry.getCommands().filter((e) => !e.hidden), n = this.opts.cliName ?? "Bob CLI", r = this.opts.cliVersion ?? "0.0.0";
1096
- Ne ??= (await import("../package-LkysKcR6.js"))?.default?.version ?? "0.0.0";
1097
- let i = Ne;
1176
+ let t = this.opts.commandRegistry.getCommands().filter((e) => !e.hidden), n = this.opts.cliName ?? "Bob CLI", r = this.opts.cliVersion ?? "0.0.0", i = Qe();
1098
1177
  this.logger.log(`${n} ${e.green(r)} (core: ${e.yellow(i)})
1099
1178
 
1100
1179
  ${e.yellow("Usage")}:
@@ -1116,25 +1195,25 @@ ${e.yellow("Available commands")}:
1116
1195
  r && this.logger.log(e.yellow(`${t}:`));
1117
1196
  let i = n.sort((e, t) => e.command.toLowerCase().localeCompare(t.command.toLowerCase()));
1118
1197
  for (let t of i) {
1119
- let n = t.aliases.length > 0 ? e.gray(` (${t.aliases.join(", ")})`) : "", i = V(a - (t.command.length + (t.aliases.length > 0 ? ` (${t.aliases.join(", ")})`.length : 0)));
1198
+ let n = t.aliases.length > 0 ? e.gray(` (${t.aliases.join(", ")})`) : "", i = U(a - (t.command.length + (t.aliases.length > 0 ? ` (${t.aliases.join(", ")})`.length : 0)));
1120
1199
  r && (i = i.slice(2)), this.logger.log(`${r ? " " : ""}${e.green(t.command)}${n} ${i} ${t.description}`);
1121
1200
  }
1122
1201
  }
1123
1202
  }
1124
- }, Fe = class {
1203
+ }, et = class {
1125
1204
  ctx;
1126
1205
  logger;
1127
1206
  commandRegistry;
1128
1207
  exceptionHandler;
1129
1208
  helpCommand;
1130
1209
  newCommandRegistry(e) {
1131
- return new Q(e);
1210
+ return new Ye(e);
1132
1211
  }
1133
1212
  newHelpCommand(e) {
1134
- return new Pe(e);
1213
+ return new $e(e);
1135
1214
  }
1136
1215
  newExceptionHandler(e) {
1137
- return new Me(e.logger);
1216
+ return new Xe(e.logger);
1138
1217
  }
1139
1218
  constructor(e = {}) {
1140
1219
  this.ctx = e.ctx, this.logger = e.logger ?? new m(), this.commandRegistry = this.newCommandRegistry({ logger: this.logger }), this.exceptionHandler = this.newExceptionHandler({ logger: this.logger }), this.helpCommand = this.newHelpCommand({
@@ -1161,7 +1240,7 @@ ${e.yellow("Available commands")}:
1161
1240
  registerCommand(e) {
1162
1241
  this.commandRegistry.registerCommand(e);
1163
1242
  }
1164
- }, $ = class e {
1243
+ }, tt = class e {
1165
1244
  static parse(t, n = {}) {
1166
1245
  let [r, ...i] = t.split(/\{(.*?)\}/g).map((e) => e.trim()).filter(Boolean), a = {}, o = {};
1167
1246
  for (let t of i) {
@@ -1192,27 +1271,27 @@ ${e.yellow("Available commands")}:
1192
1271
  }
1193
1272
  n.startsWith("--") && (r = !0, n = n.slice(2)), n.endsWith("?") && (l = !1, n = n.slice(0, -1)), n.endsWith("*") && (c = !0, a = [], n = n.slice(0, -1)), i = i ?? t[n] ?? t[`--${n}`];
1194
1273
  let u;
1195
- return u = r ? s ? B.boolean({
1274
+ return u = r ? s ? H.boolean({
1196
1275
  description: i,
1197
1276
  alias: o,
1198
1277
  ...a === void 0 ? {} : { default: a }
1199
- }) : c ? B.string({
1278
+ }) : c ? H.string({
1200
1279
  description: i,
1201
1280
  alias: o,
1202
1281
  multiple: !0,
1203
1282
  ...l ? { required: !0 } : {},
1204
1283
  default: a ?? []
1205
- }) : B.string({
1284
+ }) : H.string({
1206
1285
  description: i,
1207
1286
  alias: o,
1208
1287
  ...l ? { required: !0 } : {},
1209
1288
  ...a === void 0 ? {} : { default: a }
1210
- }) : c ? z.string({
1289
+ }) : c ? V.string({
1211
1290
  description: i,
1212
1291
  multiple: !0,
1213
1292
  ...l ? { required: !0 } : {},
1214
1293
  default: a ?? []
1215
- }) : z.string({
1294
+ }) : V.string({
1216
1295
  description: i,
1217
1296
  ...l ? { required: !0 } : {},
1218
1297
  ...a === void 0 ? {} : { default: a }
@@ -1222,7 +1301,7 @@ ${e.yellow("Available commands")}:
1222
1301
  definition: u
1223
1302
  };
1224
1303
  }
1225
- }, Ie = class extends X {
1304
+ }, nt = class extends Q {
1226
1305
  static signature = "";
1227
1306
  static helperDefinitions = {};
1228
1307
  static get command() {
@@ -1231,7 +1310,7 @@ ${e.yellow("Available commands")}:
1231
1310
  async run(e) {
1232
1311
  let t = this.constructor;
1233
1312
  if (t.signature && !Object.prototype.hasOwnProperty.call(t, "_signatureParsed")) {
1234
- let e = $.parse(t.signature, t.helperDefinitions), n = Object.prototype.hasOwnProperty.call(t, "flags") ? t.flags : {}, r = Object.prototype.hasOwnProperty.call(t, "args") ? t.args : {};
1313
+ let e = tt.parse(t.signature, t.helperDefinitions), n = Object.prototype.hasOwnProperty.call(t, "flags") ? t.flags : {}, r = Object.prototype.hasOwnProperty.call(t, "args") ? t.args : {};
1235
1314
  t.flags = {
1236
1315
  ...e.flags,
1237
1316
  ...n
@@ -1250,4 +1329,4 @@ ${e.yellow("Available commands")}:
1250
1329
  }
1251
1330
  };
1252
1331
  //#endregion
1253
- export { z as Args, T as BadCommandArgument, E as BadCommandFlag, g as BobError, Fe as Cli, X as Command, y as CommandNotFoundError, k as CommandParser, Q as CommandRegistry, $ as CommandSignatureParser, Ie as CommandWithSignature, Me as ExceptionHandler, B as Flags, S as InvalidFlag, m as Logger, C as MissingRequiredArgumentValue, w as MissingRequiredFlagValue, h as StringSimilarity, D as TooManyArguments, Y as UX, O as ValidationError, U as askForCheckbox, W as askForConfirmation, G as askForEditor, K as askForExpand, q as askForFileSelector, J as askForInput, be as askForList, xe as askForNumber, Se as askForPassword, Ce as askForRawList, we as askForSearch, Te as askForSelect, Ee as askForToggle, De as keyValue, Oe as newLoader, ke as newProgressBar, Ae as table, H as withCancelHandling };
1332
+ export { V as Args, O as BadCommandArgument, k as BadCommandFlag, _ as BobError, et as Cli, Q as Command, he as CommandNotFoundError, j as CommandParser, Ye as CommandRegistry, tt as CommandSignatureParser, nt as CommandWithSignature, Xe as ExceptionHandler, H as Flags, w as InvalidFlag, m as Logger, T as MissingRequiredArgumentValue, E as MissingRequiredFlagValue, g as StringSimilarity, A as TooManyArguments, Z as UX, D as ValidationError, G as askForCheckbox, K as askForConfirmation, q as askForEditor, Pe as askForExpand, J as askForFileSelector, Y as askForInput, Fe as askForList, Ie as askForNumber, Le as askForPassword, Re as askForRawList, ze as askForSearch, Be as askForSelect, X as askForToggle, Ve as keyValue, He as newLoader, Ue as newProgressBar, We as table, W as withCancelHandling };