agent-yes 1.60.0 → 1.60.2

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/cli.js CHANGED
@@ -1,4508 +1,16 @@
1
1
  #!/usr/bin/env bun
2
- import { c as __toESM, i as __commonJSMin, r as require_ms, t as logger } from "./logger-DH1Rx9HI.js";
3
- import "./agent-yes.config-CrgoI5sj.js";
4
- import { c as PidStore, o as name, s as version, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-B5LK6-HJ.js";
5
- import { createRequire } from "node:module";
2
+ import { c as PidStore, o as name, s as version, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-TKiMwx-X.js";
3
+ import "./agent-yes.config-B-sre0vp.js";
4
+ import { t as logger } from "./logger-CY9ormLF.js";
6
5
  import { argv } from "process";
7
6
  import { spawn } from "child_process";
8
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, unlinkSync, writeFile } from "fs";
9
- import path, { basename, dirname, extname, join, normalize, relative, resolve } from "path";
10
- import { format, inspect } from "util";
11
- import { notStrictEqual, strictEqual } from "assert";
12
- import { fileURLToPath } from "url";
13
- import { readFileSync as readFileSync$1, readdirSync as readdirSync$1 } from "node:fs";
7
+ import { existsSync, mkdirSync, unlinkSync } from "fs";
8
+ import path from "path";
9
+ import ms from "ms";
10
+ import yargs from "yargs";
11
+ import { hideBin } from "yargs/helpers";
14
12
  import { chmod, copyFile, rename } from "fs/promises";
15
13
 
16
- //#region node_modules/cliui/build/lib/index.js
17
- var import_ms = /* @__PURE__ */ __toESM(require_ms(), 1);
18
- const align = {
19
- right: alignRight,
20
- center: alignCenter
21
- };
22
- const top = 0;
23
- const right = 1;
24
- const bottom = 2;
25
- const left = 3;
26
- var UI = class {
27
- constructor(opts) {
28
- var _a;
29
- this.width = opts.width;
30
- this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
31
- this.rows = [];
32
- }
33
- span(...args) {
34
- const cols = this.div(...args);
35
- cols.span = true;
36
- }
37
- resetOutput() {
38
- this.rows = [];
39
- }
40
- div(...args) {
41
- if (args.length === 0) this.div("");
42
- if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === "string") return this.applyLayoutDSL(args[0]);
43
- const cols = args.map((arg) => {
44
- if (typeof arg === "string") return this.colFromString(arg);
45
- return arg;
46
- });
47
- this.rows.push(cols);
48
- return cols;
49
- }
50
- shouldApplyLayoutDSL(...args) {
51
- return args.length === 1 && typeof args[0] === "string" && /[\t\n]/.test(args[0]);
52
- }
53
- applyLayoutDSL(str) {
54
- const rows = str.split("\n").map((row) => row.split(" "));
55
- let leftColumnWidth = 0;
56
- rows.forEach((columns) => {
57
- if (columns.length > 1 && mixin$1.stringWidth(columns[0]) > leftColumnWidth) leftColumnWidth = Math.min(Math.floor(this.width * .5), mixin$1.stringWidth(columns[0]));
58
- });
59
- rows.forEach((columns) => {
60
- this.div(...columns.map((r, i) => {
61
- return {
62
- text: r.trim(),
63
- padding: this.measurePadding(r),
64
- width: i === 0 && columns.length > 1 ? leftColumnWidth : void 0
65
- };
66
- }));
67
- });
68
- return this.rows[this.rows.length - 1];
69
- }
70
- colFromString(text) {
71
- return {
72
- text,
73
- padding: this.measurePadding(text)
74
- };
75
- }
76
- measurePadding(str) {
77
- const noAnsi = mixin$1.stripAnsi(str);
78
- return [
79
- 0,
80
- noAnsi.match(/\s*$/)[0].length,
81
- 0,
82
- noAnsi.match(/^\s*/)[0].length
83
- ];
84
- }
85
- toString() {
86
- const lines = [];
87
- this.rows.forEach((row) => {
88
- this.rowToString(row, lines);
89
- });
90
- return lines.filter((line) => !line.hidden).map((line) => line.text).join("\n");
91
- }
92
- rowToString(row, lines) {
93
- this.rasterize(row).forEach((rrow, r) => {
94
- let str = "";
95
- rrow.forEach((col, c) => {
96
- const { width } = row[c];
97
- const wrapWidth = this.negatePadding(row[c]);
98
- let ts = col;
99
- if (wrapWidth > mixin$1.stringWidth(col)) ts += " ".repeat(wrapWidth - mixin$1.stringWidth(col));
100
- if (row[c].align && row[c].align !== "left" && this.wrap) {
101
- const fn = align[row[c].align];
102
- ts = fn(ts, wrapWidth);
103
- if (mixin$1.stringWidth(ts) < wrapWidth) ts += " ".repeat((width || 0) - mixin$1.stringWidth(ts) - 1);
104
- }
105
- const padding = row[c].padding || [
106
- 0,
107
- 0,
108
- 0,
109
- 0
110
- ];
111
- if (padding[left]) str += " ".repeat(padding[left]);
112
- str += addBorder(row[c], ts, "| ");
113
- str += ts;
114
- str += addBorder(row[c], ts, " |");
115
- if (padding[right]) str += " ".repeat(padding[right]);
116
- if (r === 0 && lines.length > 0) str = this.renderInline(str, lines[lines.length - 1]);
117
- });
118
- lines.push({
119
- text: str.replace(/ +$/, ""),
120
- span: row.span
121
- });
122
- });
123
- return lines;
124
- }
125
- renderInline(source, previousLine) {
126
- const match = source.match(/^ */);
127
- const leadingWhitespace = match ? match[0].length : 0;
128
- const target = previousLine.text;
129
- const targetTextWidth = mixin$1.stringWidth(target.trimRight());
130
- if (!previousLine.span) return source;
131
- if (!this.wrap) {
132
- previousLine.hidden = true;
133
- return target + source;
134
- }
135
- if (leadingWhitespace < targetTextWidth) return source;
136
- previousLine.hidden = true;
137
- return target.trimRight() + " ".repeat(leadingWhitespace - targetTextWidth) + source.trimLeft();
138
- }
139
- rasterize(row) {
140
- const rrows = [];
141
- const widths = this.columnWidths(row);
142
- let wrapped;
143
- row.forEach((col, c) => {
144
- col.width = widths[c];
145
- if (this.wrap) wrapped = mixin$1.wrap(col.text, this.negatePadding(col), { hard: true }).split("\n");
146
- else wrapped = col.text.split("\n");
147
- if (col.border) {
148
- wrapped.unshift("." + "-".repeat(this.negatePadding(col) + 2) + ".");
149
- wrapped.push("'" + "-".repeat(this.negatePadding(col) + 2) + "'");
150
- }
151
- if (col.padding) {
152
- wrapped.unshift(...new Array(col.padding[top] || 0).fill(""));
153
- wrapped.push(...new Array(col.padding[bottom] || 0).fill(""));
154
- }
155
- wrapped.forEach((str, r) => {
156
- if (!rrows[r]) rrows.push([]);
157
- const rrow = rrows[r];
158
- for (let i = 0; i < c; i++) if (rrow[i] === void 0) rrow.push("");
159
- rrow.push(str);
160
- });
161
- });
162
- return rrows;
163
- }
164
- negatePadding(col) {
165
- let wrapWidth = col.width || 0;
166
- if (col.padding) wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
167
- if (col.border) wrapWidth -= 4;
168
- return wrapWidth;
169
- }
170
- columnWidths(row) {
171
- if (!this.wrap) return row.map((col) => {
172
- return col.width || mixin$1.stringWidth(col.text);
173
- });
174
- let unset = row.length;
175
- let remainingWidth = this.width;
176
- const widths = row.map((col) => {
177
- if (col.width) {
178
- unset--;
179
- remainingWidth -= col.width;
180
- return col.width;
181
- }
182
- });
183
- const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
184
- return widths.map((w, i) => {
185
- if (w === void 0) return Math.max(unsetWidth, _minWidth(row[i]));
186
- return w;
187
- });
188
- }
189
- };
190
- function addBorder(col, ts, style) {
191
- if (col.border) {
192
- if (/[.']-+[.']/.test(ts)) return "";
193
- if (ts.trim().length !== 0) return style;
194
- return " ";
195
- }
196
- return "";
197
- }
198
- function _minWidth(col) {
199
- const padding = col.padding || [];
200
- const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
201
- if (col.border) return minWidth + 4;
202
- return minWidth;
203
- }
204
- function getWindowWidth() {
205
- /* c8 ignore next 5: depends on terminal */
206
- if (typeof process === "object" && process.stdout && process.stdout.columns) return process.stdout.columns;
207
- return 80;
208
- }
209
- function alignRight(str, width) {
210
- str = str.trim();
211
- const strWidth = mixin$1.stringWidth(str);
212
- if (strWidth < width) return " ".repeat(width - strWidth) + str;
213
- return str;
214
- }
215
- function alignCenter(str, width) {
216
- str = str.trim();
217
- const strWidth = mixin$1.stringWidth(str);
218
- /* c8 ignore next 3 */
219
- if (strWidth >= width) return str;
220
- return " ".repeat(width - strWidth >> 1) + str;
221
- }
222
- let mixin$1;
223
- function cliui(opts, _mixin) {
224
- mixin$1 = _mixin;
225
- return new UI({
226
- width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
227
- wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
228
- });
229
- }
230
-
231
- //#endregion
232
- //#region node_modules/ansi-regex/index.js
233
- function ansiRegex({ onlyFirst = false } = {}) {
234
- const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
235
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
236
- }
237
-
238
- //#endregion
239
- //#region node_modules/strip-ansi/index.js
240
- const regex = ansiRegex();
241
- function stripAnsi(string) {
242
- if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
243
- return string.replace(regex, "");
244
- }
245
-
246
- //#endregion
247
- //#region node_modules/get-east-asian-width/lookup.js
248
- function isAmbiguous(x) {
249
- return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
250
- }
251
- function isFullWidth(x) {
252
- return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
253
- }
254
- function isWide(x) {
255
- return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
256
- }
257
-
258
- //#endregion
259
- //#region node_modules/get-east-asian-width/index.js
260
- function validate(codePoint) {
261
- if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
262
- }
263
- function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
264
- validate(codePoint);
265
- if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
266
- return 1;
267
- }
268
-
269
- //#endregion
270
- //#region node_modules/emoji-regex/index.js
271
- var require_emoji_regex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
272
- module.exports = () => {
273
- return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
274
- };
275
- }));
276
-
277
- //#endregion
278
- //#region node_modules/string-width/index.js
279
- var import_emoji_regex = /* @__PURE__ */ __toESM(require_emoji_regex(), 1);
280
- const segmenter = new Intl.Segmenter();
281
- const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
282
- function stringWidth(string, options = {}) {
283
- if (typeof string !== "string" || string.length === 0) return 0;
284
- const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
285
- if (!countAnsiEscapeCodes) string = stripAnsi(string);
286
- if (string.length === 0) return 0;
287
- let width = 0;
288
- const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
289
- for (const { segment: character } of segmenter.segment(string)) {
290
- const codePoint = character.codePointAt(0);
291
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
292
- if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
293
- if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
294
- if (codePoint >= 55296 && codePoint <= 57343) continue;
295
- if (codePoint >= 65024 && codePoint <= 65039) continue;
296
- if (defaultIgnorableCodePointRegex.test(character)) continue;
297
- if ((0, import_emoji_regex.default)().test(character)) {
298
- width += 2;
299
- continue;
300
- }
301
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
302
- }
303
- return width;
304
- }
305
-
306
- //#endregion
307
- //#region node_modules/wrap-ansi/node_modules/ansi-styles/index.js
308
- const ANSI_BACKGROUND_OFFSET = 10;
309
- const wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
310
- const wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
311
- const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
312
- const styles = {
313
- modifier: {
314
- reset: [0, 0],
315
- bold: [1, 22],
316
- dim: [2, 22],
317
- italic: [3, 23],
318
- underline: [4, 24],
319
- overline: [53, 55],
320
- inverse: [7, 27],
321
- hidden: [8, 28],
322
- strikethrough: [9, 29]
323
- },
324
- color: {
325
- black: [30, 39],
326
- red: [31, 39],
327
- green: [32, 39],
328
- yellow: [33, 39],
329
- blue: [34, 39],
330
- magenta: [35, 39],
331
- cyan: [36, 39],
332
- white: [37, 39],
333
- blackBright: [90, 39],
334
- gray: [90, 39],
335
- grey: [90, 39],
336
- redBright: [91, 39],
337
- greenBright: [92, 39],
338
- yellowBright: [93, 39],
339
- blueBright: [94, 39],
340
- magentaBright: [95, 39],
341
- cyanBright: [96, 39],
342
- whiteBright: [97, 39]
343
- },
344
- bgColor: {
345
- bgBlack: [40, 49],
346
- bgRed: [41, 49],
347
- bgGreen: [42, 49],
348
- bgYellow: [43, 49],
349
- bgBlue: [44, 49],
350
- bgMagenta: [45, 49],
351
- bgCyan: [46, 49],
352
- bgWhite: [47, 49],
353
- bgBlackBright: [100, 49],
354
- bgGray: [100, 49],
355
- bgGrey: [100, 49],
356
- bgRedBright: [101, 49],
357
- bgGreenBright: [102, 49],
358
- bgYellowBright: [103, 49],
359
- bgBlueBright: [104, 49],
360
- bgMagentaBright: [105, 49],
361
- bgCyanBright: [106, 49],
362
- bgWhiteBright: [107, 49]
363
- }
364
- };
365
- const modifierNames = Object.keys(styles.modifier);
366
- const foregroundColorNames = Object.keys(styles.color);
367
- const backgroundColorNames = Object.keys(styles.bgColor);
368
- const colorNames = [...foregroundColorNames, ...backgroundColorNames];
369
- function assembleStyles() {
370
- const codes = /* @__PURE__ */ new Map();
371
- for (const [groupName, group] of Object.entries(styles)) {
372
- for (const [styleName, style] of Object.entries(group)) {
373
- styles[styleName] = {
374
- open: `\u001B[${style[0]}m`,
375
- close: `\u001B[${style[1]}m`
376
- };
377
- group[styleName] = styles[styleName];
378
- codes.set(style[0], style[1]);
379
- }
380
- Object.defineProperty(styles, groupName, {
381
- value: group,
382
- enumerable: false
383
- });
384
- }
385
- Object.defineProperty(styles, "codes", {
386
- value: codes,
387
- enumerable: false
388
- });
389
- styles.color.close = "\x1B[39m";
390
- styles.bgColor.close = "\x1B[49m";
391
- styles.color.ansi = wrapAnsi16();
392
- styles.color.ansi256 = wrapAnsi256();
393
- styles.color.ansi16m = wrapAnsi16m();
394
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
395
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
396
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
397
- Object.defineProperties(styles, {
398
- rgbToAnsi256: {
399
- value: (red, green, blue) => {
400
- if (red === green && green === blue) {
401
- if (red < 8) return 16;
402
- if (red > 248) return 231;
403
- return Math.round((red - 8) / 247 * 24) + 232;
404
- }
405
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
406
- },
407
- enumerable: false
408
- },
409
- hexToRgb: {
410
- value: (hex) => {
411
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
412
- if (!matches) return [
413
- 0,
414
- 0,
415
- 0
416
- ];
417
- let [colorString] = matches;
418
- if (colorString.length === 3) colorString = [...colorString].map((character) => character + character).join("");
419
- const integer = Number.parseInt(colorString, 16);
420
- return [
421
- integer >> 16 & 255,
422
- integer >> 8 & 255,
423
- integer & 255
424
- ];
425
- },
426
- enumerable: false
427
- },
428
- hexToAnsi256: {
429
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
430
- enumerable: false
431
- },
432
- ansi256ToAnsi: {
433
- value: (code) => {
434
- if (code < 8) return 30 + code;
435
- if (code < 16) return 90 + (code - 8);
436
- let red;
437
- let green;
438
- let blue;
439
- if (code >= 232) {
440
- red = ((code - 232) * 10 + 8) / 255;
441
- green = red;
442
- blue = red;
443
- } else {
444
- code -= 16;
445
- const remainder = code % 36;
446
- red = Math.floor(code / 36) / 5;
447
- green = Math.floor(remainder / 6) / 5;
448
- blue = remainder % 6 / 5;
449
- }
450
- const value = Math.max(red, green, blue) * 2;
451
- if (value === 0) return 30;
452
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
453
- if (value === 2) result += 60;
454
- return result;
455
- },
456
- enumerable: false
457
- },
458
- rgbToAnsi: {
459
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
460
- enumerable: false
461
- },
462
- hexToAnsi: {
463
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
464
- enumerable: false
465
- }
466
- });
467
- return styles;
468
- }
469
- const ansiStyles = assembleStyles();
470
-
471
- //#endregion
472
- //#region node_modules/wrap-ansi/index.js
473
- const ESCAPES = new Set(["\x1B", "›"]);
474
- const END_CODE = 39;
475
- const ANSI_ESCAPE_BELL = "\x07";
476
- const ANSI_CSI = "[";
477
- const ANSI_OSC = "]";
478
- const ANSI_SGR_TERMINATOR = "m";
479
- const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
480
- const wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
481
- const wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
482
- const wordLengths = (string) => string.split(" ").map((character) => stringWidth(character));
483
- const wrapWord = (rows, word, columns) => {
484
- const characters = [...word];
485
- let isInsideEscape = false;
486
- let isInsideLinkEscape = false;
487
- let visible = stringWidth(stripAnsi(rows.at(-1)));
488
- for (const [index, character] of characters.entries()) {
489
- const characterLength = stringWidth(character);
490
- if (visible + characterLength <= columns) rows[rows.length - 1] += character;
491
- else {
492
- rows.push(character);
493
- visible = 0;
494
- }
495
- if (ESCAPES.has(character)) {
496
- isInsideEscape = true;
497
- isInsideLinkEscape = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join("") === ANSI_ESCAPE_LINK;
498
- }
499
- if (isInsideEscape) {
500
- if (isInsideLinkEscape) {
501
- if (character === ANSI_ESCAPE_BELL) {
502
- isInsideEscape = false;
503
- isInsideLinkEscape = false;
504
- }
505
- } else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
506
- continue;
507
- }
508
- visible += characterLength;
509
- if (visible === columns && index < characters.length - 1) {
510
- rows.push("");
511
- visible = 0;
512
- }
513
- }
514
- if (!visible && rows.at(-1).length > 0 && rows.length > 1) rows[rows.length - 2] += rows.pop();
515
- };
516
- const stringVisibleTrimSpacesRight = (string) => {
517
- const words = string.split(" ");
518
- let last = words.length;
519
- while (last > 0) {
520
- if (stringWidth(words[last - 1]) > 0) break;
521
- last--;
522
- }
523
- if (last === words.length) return string;
524
- return words.slice(0, last).join(" ") + words.slice(last).join("");
525
- };
526
- const exec = (string, columns, options = {}) => {
527
- if (options.trim !== false && string.trim() === "") return "";
528
- let returnValue = "";
529
- let escapeCode;
530
- let escapeUrl;
531
- const lengths = wordLengths(string);
532
- let rows = [""];
533
- for (const [index, word] of string.split(" ").entries()) {
534
- if (options.trim !== false) rows[rows.length - 1] = rows.at(-1).trimStart();
535
- let rowLength = stringWidth(rows.at(-1));
536
- if (index !== 0) {
537
- if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
538
- rows.push("");
539
- rowLength = 0;
540
- }
541
- if (rowLength > 0 || options.trim === false) {
542
- rows[rows.length - 1] += " ";
543
- rowLength++;
544
- }
545
- }
546
- if (options.hard && lengths[index] > columns) {
547
- const remainingColumns = columns - rowLength;
548
- const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
549
- if (Math.floor((lengths[index] - 1) / columns) < breaksStartingThisLine) rows.push("");
550
- wrapWord(rows, word, columns);
551
- continue;
552
- }
553
- if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
554
- if (options.wordWrap === false && rowLength < columns) {
555
- wrapWord(rows, word, columns);
556
- continue;
557
- }
558
- rows.push("");
559
- }
560
- if (rowLength + lengths[index] > columns && options.wordWrap === false) {
561
- wrapWord(rows, word, columns);
562
- continue;
563
- }
564
- rows[rows.length - 1] += word;
565
- }
566
- if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
567
- const preString = rows.join("\n");
568
- const pre = [...preString];
569
- let preStringIndex = 0;
570
- for (const [index, character] of pre.entries()) {
571
- returnValue += character;
572
- if (ESCAPES.has(character)) {
573
- const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} };
574
- if (groups.code !== void 0) {
575
- const code = Number.parseFloat(groups.code);
576
- escapeCode = code === END_CODE ? void 0 : code;
577
- } else if (groups.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
578
- }
579
- const code = ansiStyles.codes.get(Number(escapeCode));
580
- if (pre[index + 1] === "\n") {
581
- if (escapeUrl) returnValue += wrapAnsiHyperlink("");
582
- if (escapeCode && code) returnValue += wrapAnsiCode(code);
583
- } else if (character === "\n") {
584
- if (escapeCode && code) returnValue += wrapAnsiCode(escapeCode);
585
- if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
586
- }
587
- preStringIndex += character.length;
588
- }
589
- return returnValue;
590
- };
591
- function wrapAnsi(string, columns, options) {
592
- return String(string).normalize().replaceAll("\r\n", "\n").split("\n").map((line) => exec(line, columns, options)).join("\n");
593
- }
594
-
595
- //#endregion
596
- //#region node_modules/cliui/index.mjs
597
- function ui(opts) {
598
- return cliui(opts, {
599
- stringWidth,
600
- stripAnsi,
601
- wrap: wrapAnsi
602
- });
603
- }
604
-
605
- //#endregion
606
- //#region node_modules/escalade/sync/index.mjs
607
- function sync_default(start, callback) {
608
- let dir = resolve(".", start);
609
- let tmp;
610
- if (!statSync(dir).isDirectory()) dir = dirname(dir);
611
- while (true) {
612
- tmp = callback(dir, readdirSync(dir));
613
- if (tmp) return resolve(dir, tmp);
614
- dir = dirname(tmp = dir);
615
- if (tmp === dir) break;
616
- }
617
- }
618
-
619
- //#endregion
620
- //#region node_modules/yargs-parser/build/lib/string-utils.js
621
- /**
622
- * @license
623
- * Copyright (c) 2016, Contributors
624
- * SPDX-License-Identifier: ISC
625
- */
626
- function camelCase(str) {
627
- if (!(str !== str.toLowerCase() && str !== str.toUpperCase())) str = str.toLowerCase();
628
- if (str.indexOf("-") === -1 && str.indexOf("_") === -1) return str;
629
- else {
630
- let camelcase = "";
631
- let nextChrUpper = false;
632
- const leadingHyphens = str.match(/^-+/);
633
- for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
634
- let chr = str.charAt(i);
635
- if (nextChrUpper) {
636
- nextChrUpper = false;
637
- chr = chr.toUpperCase();
638
- }
639
- if (i !== 0 && (chr === "-" || chr === "_")) nextChrUpper = true;
640
- else if (chr !== "-" && chr !== "_") camelcase += chr;
641
- }
642
- return camelcase;
643
- }
644
- }
645
- function decamelize(str, joinString) {
646
- const lowercase = str.toLowerCase();
647
- joinString = joinString || "-";
648
- let notCamelcase = "";
649
- for (let i = 0; i < str.length; i++) {
650
- const chrLower = lowercase.charAt(i);
651
- const chrString = str.charAt(i);
652
- if (chrLower !== chrString && i > 0) notCamelcase += `${joinString}${lowercase.charAt(i)}`;
653
- else notCamelcase += chrString;
654
- }
655
- return notCamelcase;
656
- }
657
- function looksLikeNumber(x) {
658
- if (x === null || x === void 0) return false;
659
- if (typeof x === "number") return true;
660
- if (/^0x[0-9a-f]+$/i.test(x)) return true;
661
- if (/^0[^.]/.test(x)) return false;
662
- return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
663
- }
664
-
665
- //#endregion
666
- //#region node_modules/yargs-parser/build/lib/tokenize-arg-string.js
667
- /**
668
- * @license
669
- * Copyright (c) 2016, Contributors
670
- * SPDX-License-Identifier: ISC
671
- */
672
- function tokenizeArgString(argString) {
673
- if (Array.isArray(argString)) return argString.map((e) => typeof e !== "string" ? e + "" : e);
674
- argString = argString.trim();
675
- let i = 0;
676
- let prevC = null;
677
- let c = null;
678
- let opening = null;
679
- const args = [];
680
- for (let ii = 0; ii < argString.length; ii++) {
681
- prevC = c;
682
- c = argString.charAt(ii);
683
- if (c === " " && !opening) {
684
- if (!(prevC === " ")) i++;
685
- continue;
686
- }
687
- if (c === opening) opening = null;
688
- else if ((c === "'" || c === "\"") && !opening) opening = c;
689
- if (!args[i]) args[i] = "";
690
- args[i] += c;
691
- }
692
- return args;
693
- }
694
-
695
- //#endregion
696
- //#region node_modules/yargs-parser/build/lib/yargs-parser-types.js
697
- /**
698
- * @license
699
- * Copyright (c) 2016, Contributors
700
- * SPDX-License-Identifier: ISC
701
- */
702
- var DefaultValuesForTypeKey;
703
- (function(DefaultValuesForTypeKey) {
704
- DefaultValuesForTypeKey["BOOLEAN"] = "boolean";
705
- DefaultValuesForTypeKey["STRING"] = "string";
706
- DefaultValuesForTypeKey["NUMBER"] = "number";
707
- DefaultValuesForTypeKey["ARRAY"] = "array";
708
- })(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
709
-
710
- //#endregion
711
- //#region node_modules/yargs-parser/build/lib/yargs-parser.js
712
- /**
713
- * @license
714
- * Copyright (c) 2016, Contributors
715
- * SPDX-License-Identifier: ISC
716
- */
717
- let mixin;
718
- var YargsParser = class {
719
- constructor(_mixin) {
720
- mixin = _mixin;
721
- }
722
- parse(argsInput, options) {
723
- const opts = Object.assign({
724
- alias: void 0,
725
- array: void 0,
726
- boolean: void 0,
727
- config: void 0,
728
- configObjects: void 0,
729
- configuration: void 0,
730
- coerce: void 0,
731
- count: void 0,
732
- default: void 0,
733
- envPrefix: void 0,
734
- narg: void 0,
735
- normalize: void 0,
736
- string: void 0,
737
- number: void 0,
738
- __: void 0,
739
- key: void 0
740
- }, options);
741
- const args = tokenizeArgString(argsInput);
742
- const inputIsString = typeof argsInput === "string";
743
- const aliases = combineAliases(Object.assign(Object.create(null), opts.alias));
744
- const configuration = Object.assign({
745
- "boolean-negation": true,
746
- "camel-case-expansion": true,
747
- "combine-arrays": false,
748
- "dot-notation": true,
749
- "duplicate-arguments-array": true,
750
- "flatten-duplicate-arrays": true,
751
- "greedy-arrays": true,
752
- "halt-at-non-option": false,
753
- "nargs-eats-options": false,
754
- "negation-prefix": "no-",
755
- "parse-numbers": true,
756
- "parse-positional-numbers": true,
757
- "populate--": false,
758
- "set-placeholder-key": false,
759
- "short-option-groups": true,
760
- "strip-aliased": false,
761
- "strip-dashed": false,
762
- "unknown-options-as-args": false
763
- }, opts.configuration);
764
- const defaults = Object.assign(Object.create(null), opts.default);
765
- const configObjects = opts.configObjects || [];
766
- const envPrefix = opts.envPrefix;
767
- const notFlagsOption = configuration["populate--"];
768
- const notFlagsArgv = notFlagsOption ? "--" : "_";
769
- const newAliases = Object.create(null);
770
- const defaulted = Object.create(null);
771
- const __ = opts.__ || mixin.format;
772
- const flags = {
773
- aliases: Object.create(null),
774
- arrays: Object.create(null),
775
- bools: Object.create(null),
776
- strings: Object.create(null),
777
- numbers: Object.create(null),
778
- counts: Object.create(null),
779
- normalize: Object.create(null),
780
- configs: Object.create(null),
781
- nargs: Object.create(null),
782
- coercions: Object.create(null),
783
- keys: []
784
- };
785
- const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
786
- const negatedBoolean = new RegExp("^--" + configuration["negation-prefix"] + "(.+)");
787
- [].concat(opts.array || []).filter(Boolean).forEach(function(opt) {
788
- const key = typeof opt === "object" ? opt.key : opt;
789
- const assignment = Object.keys(opt).map(function(key) {
790
- return {
791
- boolean: "bools",
792
- string: "strings",
793
- number: "numbers"
794
- }[key];
795
- }).filter(Boolean).pop();
796
- if (assignment) flags[assignment][key] = true;
797
- flags.arrays[key] = true;
798
- flags.keys.push(key);
799
- });
800
- [].concat(opts.boolean || []).filter(Boolean).forEach(function(key) {
801
- flags.bools[key] = true;
802
- flags.keys.push(key);
803
- });
804
- [].concat(opts.string || []).filter(Boolean).forEach(function(key) {
805
- flags.strings[key] = true;
806
- flags.keys.push(key);
807
- });
808
- [].concat(opts.number || []).filter(Boolean).forEach(function(key) {
809
- flags.numbers[key] = true;
810
- flags.keys.push(key);
811
- });
812
- [].concat(opts.count || []).filter(Boolean).forEach(function(key) {
813
- flags.counts[key] = true;
814
- flags.keys.push(key);
815
- });
816
- [].concat(opts.normalize || []).filter(Boolean).forEach(function(key) {
817
- flags.normalize[key] = true;
818
- flags.keys.push(key);
819
- });
820
- if (typeof opts.narg === "object") Object.entries(opts.narg).forEach(([key, value]) => {
821
- if (typeof value === "number") {
822
- flags.nargs[key] = value;
823
- flags.keys.push(key);
824
- }
825
- });
826
- if (typeof opts.coerce === "object") Object.entries(opts.coerce).forEach(([key, value]) => {
827
- if (typeof value === "function") {
828
- flags.coercions[key] = value;
829
- flags.keys.push(key);
830
- }
831
- });
832
- if (typeof opts.config !== "undefined") {
833
- if (Array.isArray(opts.config) || typeof opts.config === "string") [].concat(opts.config).filter(Boolean).forEach(function(key) {
834
- flags.configs[key] = true;
835
- });
836
- else if (typeof opts.config === "object") Object.entries(opts.config).forEach(([key, value]) => {
837
- if (typeof value === "boolean" || typeof value === "function") flags.configs[key] = value;
838
- });
839
- }
840
- extendAliases(opts.key, aliases, opts.default, flags.arrays);
841
- Object.keys(defaults).forEach(function(key) {
842
- (flags.aliases[key] || []).forEach(function(alias) {
843
- defaults[alias] = defaults[key];
844
- });
845
- });
846
- let error = null;
847
- checkConfiguration();
848
- let notFlags = [];
849
- const argv = Object.assign(Object.create(null), { _: [] });
850
- const argvReturn = {};
851
- for (let i = 0; i < args.length; i++) {
852
- const arg = args[i];
853
- const truncatedArg = arg.replace(/^-{3,}/, "---");
854
- let broken;
855
- let key;
856
- let letters;
857
- let m;
858
- let next;
859
- let value;
860
- if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) pushPositional(arg);
861
- else if (truncatedArg.match(/^---+(=|$)/)) {
862
- pushPositional(arg);
863
- continue;
864
- } else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
865
- m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
866
- if (m !== null && Array.isArray(m) && m.length >= 3) if (checkAllAliases(m[1], flags.arrays)) i = eatArray(i, m[1], args, m[2]);
867
- else if (checkAllAliases(m[1], flags.nargs) !== false) i = eatNargs(i, m[1], args, m[2]);
868
- else setArg(m[1], m[2], true);
869
- } else if (arg.match(negatedBoolean) && configuration["boolean-negation"]) {
870
- m = arg.match(negatedBoolean);
871
- if (m !== null && Array.isArray(m) && m.length >= 2) {
872
- key = m[1];
873
- setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false);
874
- }
875
- } else if (arg.match(/^--.+/) || !configuration["short-option-groups"] && arg.match(/^-[^-]+/)) {
876
- m = arg.match(/^--?(.+)/);
877
- if (m !== null && Array.isArray(m) && m.length >= 2) {
878
- key = m[1];
879
- if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args);
880
- else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args);
881
- else {
882
- next = args[i + 1];
883
- if (next !== void 0 && (!next.match(/^-/) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
884
- setArg(key, next);
885
- i++;
886
- } else if (/^(true|false)$/.test(next)) {
887
- setArg(key, next);
888
- i++;
889
- } else setArg(key, defaultValue(key));
890
- }
891
- }
892
- } else if (arg.match(/^-.\..+=/)) {
893
- m = arg.match(/^-([^=]+)=([\s\S]*)$/);
894
- if (m !== null && Array.isArray(m) && m.length >= 3) setArg(m[1], m[2]);
895
- } else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
896
- next = args[i + 1];
897
- m = arg.match(/^-(.\..+)/);
898
- if (m !== null && Array.isArray(m) && m.length >= 2) {
899
- key = m[1];
900
- if (next !== void 0 && !next.match(/^-/) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
901
- setArg(key, next);
902
- i++;
903
- } else setArg(key, defaultValue(key));
904
- }
905
- } else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
906
- letters = arg.slice(1, -1).split("");
907
- broken = false;
908
- for (let j = 0; j < letters.length; j++) {
909
- next = arg.slice(j + 2);
910
- if (letters[j + 1] && letters[j + 1] === "=") {
911
- value = arg.slice(j + 3);
912
- key = letters[j];
913
- if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args, value);
914
- else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args, value);
915
- else setArg(key, value);
916
- broken = true;
917
- break;
918
- }
919
- if (next === "-") {
920
- setArg(letters[j], next);
921
- continue;
922
- }
923
- if (/[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) && checkAllAliases(next, flags.bools) === false) {
924
- setArg(letters[j], next);
925
- broken = true;
926
- break;
927
- }
928
- if (letters[j + 1] && letters[j + 1].match(/\W/)) {
929
- setArg(letters[j], next);
930
- broken = true;
931
- break;
932
- } else setArg(letters[j], defaultValue(letters[j]));
933
- }
934
- key = arg.slice(-1)[0];
935
- if (!broken && key !== "-") if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args);
936
- else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args);
937
- else {
938
- next = args[i + 1];
939
- if (next !== void 0 && (!/^(-|--)[^-]/.test(next) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
940
- setArg(key, next);
941
- i++;
942
- } else if (/^(true|false)$/.test(next)) {
943
- setArg(key, next);
944
- i++;
945
- } else setArg(key, defaultValue(key));
946
- }
947
- } else if (arg.match(/^-[0-9]$/) && arg.match(negative) && checkAllAliases(arg.slice(1), flags.bools)) {
948
- key = arg.slice(1);
949
- setArg(key, defaultValue(key));
950
- } else if (arg === "--") {
951
- notFlags = args.slice(i + 1);
952
- break;
953
- } else if (configuration["halt-at-non-option"]) {
954
- notFlags = args.slice(i);
955
- break;
956
- } else pushPositional(arg);
957
- }
958
- applyEnvVars(argv, true);
959
- applyEnvVars(argv, false);
960
- setConfig(argv);
961
- setConfigObjects();
962
- applyDefaultsAndAliases(argv, flags.aliases, defaults, true);
963
- applyCoercions(argv);
964
- if (configuration["set-placeholder-key"]) setPlaceholderKeys(argv);
965
- Object.keys(flags.counts).forEach(function(key) {
966
- if (!hasKey(argv, key.split("."))) setArg(key, 0);
967
- });
968
- if (notFlagsOption && notFlags.length) argv[notFlagsArgv] = [];
969
- notFlags.forEach(function(key) {
970
- argv[notFlagsArgv].push(key);
971
- });
972
- if (configuration["camel-case-expansion"] && configuration["strip-dashed"]) Object.keys(argv).filter((key) => key !== "--" && key.includes("-")).forEach((key) => {
973
- delete argv[key];
974
- });
975
- if (configuration["strip-aliased"]) [].concat(...Object.keys(aliases).map((k) => aliases[k])).forEach((alias) => {
976
- if (configuration["camel-case-expansion"] && alias.includes("-")) delete argv[alias.split(".").map((prop) => camelCase(prop)).join(".")];
977
- delete argv[alias];
978
- });
979
- function pushPositional(arg) {
980
- const maybeCoercedNumber = maybeCoerceNumber("_", arg);
981
- if (typeof maybeCoercedNumber === "string" || typeof maybeCoercedNumber === "number") argv._.push(maybeCoercedNumber);
982
- }
983
- function eatNargs(i, key, args, argAfterEqualSign) {
984
- let ii;
985
- let toEat = checkAllAliases(key, flags.nargs);
986
- toEat = typeof toEat !== "number" || isNaN(toEat) ? 1 : toEat;
987
- if (toEat === 0) {
988
- if (!isUndefined(argAfterEqualSign)) error = Error(__("Argument unexpected for: %s", key));
989
- setArg(key, defaultValue(key));
990
- return i;
991
- }
992
- let available = isUndefined(argAfterEqualSign) ? 0 : 1;
993
- if (configuration["nargs-eats-options"]) {
994
- if (args.length - (i + 1) + available < toEat) error = Error(__("Not enough arguments following: %s", key));
995
- available = toEat;
996
- } else {
997
- for (ii = i + 1; ii < args.length; ii++) if (!args[ii].match(/^-[^0-9]/) || args[ii].match(negative) || isUnknownOptionAsArg(args[ii])) available++;
998
- else break;
999
- if (available < toEat) error = Error(__("Not enough arguments following: %s", key));
1000
- }
1001
- let consumed = Math.min(available, toEat);
1002
- if (!isUndefined(argAfterEqualSign) && consumed > 0) {
1003
- setArg(key, argAfterEqualSign);
1004
- consumed--;
1005
- }
1006
- for (ii = i + 1; ii < consumed + i + 1; ii++) setArg(key, args[ii]);
1007
- return i + consumed;
1008
- }
1009
- function eatArray(i, key, args, argAfterEqualSign) {
1010
- let argsToSet = [];
1011
- let next = argAfterEqualSign || args[i + 1];
1012
- const nargsCount = checkAllAliases(key, flags.nargs);
1013
- if (checkAllAliases(key, flags.bools) && !/^(true|false)$/.test(next)) argsToSet.push(true);
1014
- else if (isUndefined(next) || isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) {
1015
- if (defaults[key] !== void 0) {
1016
- const defVal = defaults[key];
1017
- argsToSet = Array.isArray(defVal) ? defVal : [defVal];
1018
- }
1019
- } else {
1020
- if (!isUndefined(argAfterEqualSign)) argsToSet.push(processValue(key, argAfterEqualSign, true));
1021
- for (let ii = i + 1; ii < args.length; ii++) {
1022
- if (!configuration["greedy-arrays"] && argsToSet.length > 0 || nargsCount && typeof nargsCount === "number" && argsToSet.length >= nargsCount) break;
1023
- next = args[ii];
1024
- if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) break;
1025
- i = ii;
1026
- argsToSet.push(processValue(key, next, inputIsString));
1027
- }
1028
- }
1029
- if (typeof nargsCount === "number" && (nargsCount && argsToSet.length < nargsCount || isNaN(nargsCount) && argsToSet.length === 0)) error = Error(__("Not enough arguments following: %s", key));
1030
- setArg(key, argsToSet);
1031
- return i;
1032
- }
1033
- function setArg(key, val, shouldStripQuotes = inputIsString) {
1034
- if (/-/.test(key) && configuration["camel-case-expansion"]) addNewAlias(key, key.split(".").map(function(prop) {
1035
- return camelCase(prop);
1036
- }).join("."));
1037
- const value = processValue(key, val, shouldStripQuotes);
1038
- const splitKey = key.split(".");
1039
- setKey(argv, splitKey, value);
1040
- if (flags.aliases[key]) flags.aliases[key].forEach(function(x) {
1041
- setKey(argv, x.split("."), value);
1042
- });
1043
- if (splitKey.length > 1 && configuration["dot-notation"]) (flags.aliases[splitKey[0]] || []).forEach(function(x) {
1044
- let keyProperties = x.split(".");
1045
- const a = [].concat(splitKey);
1046
- a.shift();
1047
- keyProperties = keyProperties.concat(a);
1048
- if (!(flags.aliases[key] || []).includes(keyProperties.join("."))) setKey(argv, keyProperties, value);
1049
- });
1050
- if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) [key].concat(flags.aliases[key] || []).forEach(function(key) {
1051
- Object.defineProperty(argvReturn, key, {
1052
- enumerable: true,
1053
- get() {
1054
- return val;
1055
- },
1056
- set(value) {
1057
- val = typeof value === "string" ? mixin.normalize(value) : value;
1058
- }
1059
- });
1060
- });
1061
- }
1062
- function addNewAlias(key, alias) {
1063
- if (!(flags.aliases[key] && flags.aliases[key].length)) {
1064
- flags.aliases[key] = [alias];
1065
- newAliases[alias] = true;
1066
- }
1067
- if (!(flags.aliases[alias] && flags.aliases[alias].length)) addNewAlias(alias, key);
1068
- }
1069
- function processValue(key, val, shouldStripQuotes) {
1070
- if (shouldStripQuotes) val = stripQuotes(val);
1071
- if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
1072
- if (typeof val === "string") val = val === "true";
1073
- }
1074
- let value = Array.isArray(val) ? val.map(function(v) {
1075
- return maybeCoerceNumber(key, v);
1076
- }) : maybeCoerceNumber(key, val);
1077
- if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === "boolean")) value = increment();
1078
- if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) if (Array.isArray(val)) value = val.map((val) => {
1079
- return mixin.normalize(val);
1080
- });
1081
- else value = mixin.normalize(val);
1082
- return value;
1083
- }
1084
- function maybeCoerceNumber(key, value) {
1085
- if (!configuration["parse-positional-numbers"] && key === "_") return value;
1086
- if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) {
1087
- if (looksLikeNumber(value) && configuration["parse-numbers"] && Number.isSafeInteger(Math.floor(parseFloat(`${value}`))) || !isUndefined(value) && checkAllAliases(key, flags.numbers)) value = Number(value);
1088
- }
1089
- return value;
1090
- }
1091
- function setConfig(argv) {
1092
- const configLookup = Object.create(null);
1093
- applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
1094
- Object.keys(flags.configs).forEach(function(configKey) {
1095
- const configPath = argv[configKey] || configLookup[configKey];
1096
- if (configPath) try {
1097
- let config = null;
1098
- const resolvedConfigPath = mixin.resolve(mixin.cwd(), configPath);
1099
- const resolveConfig = flags.configs[configKey];
1100
- if (typeof resolveConfig === "function") {
1101
- try {
1102
- config = resolveConfig(resolvedConfigPath);
1103
- } catch (e) {
1104
- config = e;
1105
- }
1106
- if (config instanceof Error) {
1107
- error = config;
1108
- return;
1109
- }
1110
- } else config = mixin.require(resolvedConfigPath);
1111
- setConfigObject(config);
1112
- } catch (ex) {
1113
- if (ex.name === "PermissionDenied") error = ex;
1114
- else if (argv[configKey]) error = Error(__("Invalid JSON config file: %s", configPath));
1115
- }
1116
- });
1117
- }
1118
- function setConfigObject(config, prev) {
1119
- Object.keys(config).forEach(function(key) {
1120
- const value = config[key];
1121
- const fullKey = prev ? prev + "." + key : key;
1122
- if (typeof value === "object" && value !== null && !Array.isArray(value) && configuration["dot-notation"]) setConfigObject(value, fullKey);
1123
- else if (!hasKey(argv, fullKey.split(".")) || checkAllAliases(fullKey, flags.arrays) && configuration["combine-arrays"]) setArg(fullKey, value);
1124
- });
1125
- }
1126
- function setConfigObjects() {
1127
- if (typeof configObjects !== "undefined") configObjects.forEach(function(configObject) {
1128
- setConfigObject(configObject);
1129
- });
1130
- }
1131
- function applyEnvVars(argv, configOnly) {
1132
- if (typeof envPrefix === "undefined") return;
1133
- const prefix = typeof envPrefix === "string" ? envPrefix : "";
1134
- const env = mixin.env();
1135
- Object.keys(env).forEach(function(envVar) {
1136
- if (prefix === "" || envVar.lastIndexOf(prefix, 0) === 0) {
1137
- const keys = envVar.split("__").map(function(key, i) {
1138
- if (i === 0) key = key.substring(prefix.length);
1139
- return camelCase(key);
1140
- });
1141
- if ((configOnly && flags.configs[keys.join(".")] || !configOnly) && !hasKey(argv, keys)) setArg(keys.join("."), env[envVar]);
1142
- }
1143
- });
1144
- }
1145
- function applyCoercions(argv) {
1146
- let coerce;
1147
- const applied = /* @__PURE__ */ new Set();
1148
- Object.keys(argv).forEach(function(key) {
1149
- if (!applied.has(key)) {
1150
- coerce = checkAllAliases(key, flags.coercions);
1151
- if (typeof coerce === "function") try {
1152
- const value = maybeCoerceNumber(key, coerce(argv[key]));
1153
- [].concat(flags.aliases[key] || [], key).forEach((ali) => {
1154
- applied.add(ali);
1155
- argv[ali] = value;
1156
- });
1157
- } catch (err) {
1158
- error = err;
1159
- }
1160
- }
1161
- });
1162
- }
1163
- function setPlaceholderKeys(argv) {
1164
- flags.keys.forEach((key) => {
1165
- if (~key.indexOf(".")) return;
1166
- if (typeof argv[key] === "undefined") argv[key] = void 0;
1167
- });
1168
- return argv;
1169
- }
1170
- function applyDefaultsAndAliases(obj, aliases, defaults, canLog = false) {
1171
- Object.keys(defaults).forEach(function(key) {
1172
- if (!hasKey(obj, key.split("."))) {
1173
- setKey(obj, key.split("."), defaults[key]);
1174
- if (canLog) defaulted[key] = true;
1175
- (aliases[key] || []).forEach(function(x) {
1176
- if (hasKey(obj, x.split("."))) return;
1177
- setKey(obj, x.split("."), defaults[key]);
1178
- });
1179
- }
1180
- });
1181
- }
1182
- function hasKey(obj, keys) {
1183
- let o = obj;
1184
- if (!configuration["dot-notation"]) keys = [keys.join(".")];
1185
- keys.slice(0, -1).forEach(function(key) {
1186
- o = o[key] || {};
1187
- });
1188
- const key = keys[keys.length - 1];
1189
- if (typeof o !== "object") return false;
1190
- else return key in o;
1191
- }
1192
- function setKey(obj, keys, value) {
1193
- let o = obj;
1194
- if (!configuration["dot-notation"]) keys = [keys.join(".")];
1195
- keys.slice(0, -1).forEach(function(key) {
1196
- key = sanitizeKey(key);
1197
- if (typeof o === "object" && o[key] === void 0) o[key] = {};
1198
- if (typeof o[key] !== "object" || Array.isArray(o[key])) {
1199
- if (Array.isArray(o[key])) o[key].push({});
1200
- else o[key] = [o[key], {}];
1201
- o = o[key][o[key].length - 1];
1202
- } else o = o[key];
1203
- });
1204
- const key = sanitizeKey(keys[keys.length - 1]);
1205
- const isTypeArray = checkAllAliases(keys.join("."), flags.arrays);
1206
- const isValueArray = Array.isArray(value);
1207
- let duplicate = configuration["duplicate-arguments-array"];
1208
- if (!duplicate && checkAllAliases(key, flags.nargs)) {
1209
- duplicate = true;
1210
- if (!isUndefined(o[key]) && flags.nargs[key] === 1 || Array.isArray(o[key]) && o[key].length === flags.nargs[key]) o[key] = void 0;
1211
- }
1212
- if (value === increment()) o[key] = increment(o[key]);
1213
- else if (Array.isArray(o[key])) if (duplicate && isTypeArray && isValueArray) o[key] = configuration["flatten-duplicate-arrays"] ? o[key].concat(value) : (Array.isArray(o[key][0]) ? o[key] : [o[key]]).concat([value]);
1214
- else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) o[key] = value;
1215
- else o[key] = o[key].concat([value]);
1216
- else if (o[key] === void 0 && isTypeArray) o[key] = isValueArray ? value : [value];
1217
- else if (duplicate && !(o[key] === void 0 || checkAllAliases(key, flags.counts) || checkAllAliases(key, flags.bools))) o[key] = [o[key], value];
1218
- else o[key] = value;
1219
- }
1220
- function extendAliases(...args) {
1221
- args.forEach(function(obj) {
1222
- Object.keys(obj || {}).forEach(function(key) {
1223
- if (flags.aliases[key]) return;
1224
- flags.aliases[key] = [].concat(aliases[key] || []);
1225
- flags.aliases[key].concat(key).forEach(function(x) {
1226
- if (/-/.test(x) && configuration["camel-case-expansion"]) {
1227
- const c = camelCase(x);
1228
- if (c !== key && flags.aliases[key].indexOf(c) === -1) {
1229
- flags.aliases[key].push(c);
1230
- newAliases[c] = true;
1231
- }
1232
- }
1233
- });
1234
- flags.aliases[key].concat(key).forEach(function(x) {
1235
- if (x.length > 1 && /[A-Z]/.test(x) && configuration["camel-case-expansion"]) {
1236
- const c = decamelize(x, "-");
1237
- if (c !== key && flags.aliases[key].indexOf(c) === -1) {
1238
- flags.aliases[key].push(c);
1239
- newAliases[c] = true;
1240
- }
1241
- }
1242
- });
1243
- flags.aliases[key].forEach(function(x) {
1244
- flags.aliases[x] = [key].concat(flags.aliases[key].filter(function(y) {
1245
- return x !== y;
1246
- }));
1247
- });
1248
- });
1249
- });
1250
- }
1251
- function checkAllAliases(key, flag) {
1252
- const toCheck = [].concat(flags.aliases[key] || [], key);
1253
- const keys = Object.keys(flag);
1254
- const setAlias = toCheck.find((key) => keys.includes(key));
1255
- return setAlias ? flag[setAlias] : false;
1256
- }
1257
- function hasAnyFlag(key) {
1258
- const flagsKeys = Object.keys(flags);
1259
- return [].concat(flagsKeys.map((k) => flags[k])).some(function(flag) {
1260
- return Array.isArray(flag) ? flag.includes(key) : flag[key];
1261
- });
1262
- }
1263
- function hasFlagsMatching(arg, ...patterns) {
1264
- return [].concat(...patterns).some(function(pattern) {
1265
- const match = arg.match(pattern);
1266
- return match && hasAnyFlag(match[1]);
1267
- });
1268
- }
1269
- function hasAllShortFlags(arg) {
1270
- if (arg.match(negative) || !arg.match(/^-[^-]+/)) return false;
1271
- let hasAllFlags = true;
1272
- let next;
1273
- const letters = arg.slice(1).split("");
1274
- for (let j = 0; j < letters.length; j++) {
1275
- next = arg.slice(j + 2);
1276
- if (!hasAnyFlag(letters[j])) {
1277
- hasAllFlags = false;
1278
- break;
1279
- }
1280
- if (letters[j + 1] && letters[j + 1] === "=" || next === "-" || /[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) || letters[j + 1] && letters[j + 1].match(/\W/)) break;
1281
- }
1282
- return hasAllFlags;
1283
- }
1284
- function isUnknownOptionAsArg(arg) {
1285
- return configuration["unknown-options-as-args"] && isUnknownOption(arg);
1286
- }
1287
- function isUnknownOption(arg) {
1288
- arg = arg.replace(/^-{3,}/, "--");
1289
- if (arg.match(negative)) return false;
1290
- if (hasAllShortFlags(arg)) return false;
1291
- return !hasFlagsMatching(arg, /^-+([^=]+?)=[\s\S]*$/, negatedBoolean, /^-+([^=]+?)$/, /^-+([^=]+?)-$/, /^-+([^=]+?\d+)$/, /^-+([^=]+?)\W+.*$/);
1292
- }
1293
- function defaultValue(key) {
1294
- if (!checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts) && `${key}` in defaults) return defaults[key];
1295
- else return defaultForType(guessType(key));
1296
- }
1297
- function defaultForType(type) {
1298
- return {
1299
- [DefaultValuesForTypeKey.BOOLEAN]: true,
1300
- [DefaultValuesForTypeKey.STRING]: "",
1301
- [DefaultValuesForTypeKey.NUMBER]: void 0,
1302
- [DefaultValuesForTypeKey.ARRAY]: []
1303
- }[type];
1304
- }
1305
- function guessType(key) {
1306
- let type = DefaultValuesForTypeKey.BOOLEAN;
1307
- if (checkAllAliases(key, flags.strings)) type = DefaultValuesForTypeKey.STRING;
1308
- else if (checkAllAliases(key, flags.numbers)) type = DefaultValuesForTypeKey.NUMBER;
1309
- else if (checkAllAliases(key, flags.bools)) type = DefaultValuesForTypeKey.BOOLEAN;
1310
- else if (checkAllAliases(key, flags.arrays)) type = DefaultValuesForTypeKey.ARRAY;
1311
- return type;
1312
- }
1313
- function isUndefined(num) {
1314
- return num === void 0;
1315
- }
1316
- function checkConfiguration() {
1317
- Object.keys(flags.counts).find((key) => {
1318
- if (checkAllAliases(key, flags.arrays)) {
1319
- error = Error(__("Invalid configuration: %s, opts.count excludes opts.array.", key));
1320
- return true;
1321
- } else if (checkAllAliases(key, flags.nargs)) {
1322
- error = Error(__("Invalid configuration: %s, opts.count excludes opts.narg.", key));
1323
- return true;
1324
- }
1325
- return false;
1326
- });
1327
- }
1328
- return {
1329
- aliases: Object.assign({}, flags.aliases),
1330
- argv: Object.assign(argvReturn, argv),
1331
- configuration,
1332
- defaulted: Object.assign({}, defaulted),
1333
- error,
1334
- newAliases: Object.assign({}, newAliases)
1335
- };
1336
- }
1337
- };
1338
- function combineAliases(aliases) {
1339
- const aliasArrays = [];
1340
- const combined = Object.create(null);
1341
- let change = true;
1342
- Object.keys(aliases).forEach(function(key) {
1343
- aliasArrays.push([].concat(aliases[key], key));
1344
- });
1345
- while (change) {
1346
- change = false;
1347
- for (let i = 0; i < aliasArrays.length; i++) for (let ii = i + 1; ii < aliasArrays.length; ii++) if (aliasArrays[i].filter(function(v) {
1348
- return aliasArrays[ii].indexOf(v) !== -1;
1349
- }).length) {
1350
- aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii]);
1351
- aliasArrays.splice(ii, 1);
1352
- change = true;
1353
- break;
1354
- }
1355
- }
1356
- aliasArrays.forEach(function(aliasArray) {
1357
- aliasArray = aliasArray.filter(function(v, i, self) {
1358
- return self.indexOf(v) === i;
1359
- });
1360
- const lastAlias = aliasArray.pop();
1361
- if (lastAlias !== void 0 && typeof lastAlias === "string") combined[lastAlias] = aliasArray;
1362
- });
1363
- return combined;
1364
- }
1365
- function increment(orig) {
1366
- return orig !== void 0 ? orig + 1 : 1;
1367
- }
1368
- function sanitizeKey(key) {
1369
- if (key === "__proto__") return "___proto___";
1370
- return key;
1371
- }
1372
- function stripQuotes(val) {
1373
- return typeof val === "string" && (val[0] === "'" || val[0] === "\"") && val[val.length - 1] === val[0] ? val.substring(1, val.length - 1) : val;
1374
- }
1375
-
1376
- //#endregion
1377
- //#region node_modules/yargs-parser/build/lib/index.js
1378
- /**
1379
- * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
1380
- *
1381
- * @license
1382
- * Copyright (c) 2016, Contributors
1383
- * SPDX-License-Identifier: ISC
1384
- */
1385
- var _a, _b, _c;
1386
- const minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 20;
1387
- const nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
1388
- if (nodeVersion) {
1389
- if (Number(nodeVersion.match(/^([^.]+)/)[1]) < minNodeVersion) throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
1390
- }
1391
- const env = process ? process.env : {};
1392
- const require$1 = createRequire ? createRequire(import.meta.url) : void 0;
1393
- const parser = new YargsParser({
1394
- cwd: process.cwd,
1395
- env: () => {
1396
- return env;
1397
- },
1398
- format,
1399
- normalize,
1400
- resolve,
1401
- require: (path) => {
1402
- if (typeof require$1 !== "undefined") return require$1(path);
1403
- else if (path.match(/\.json$/)) return JSON.parse(readFileSync(path, "utf8"));
1404
- else throw Error("only .json config files are supported in ESM");
1405
- }
1406
- });
1407
- const yargsParser = function Parser(args, opts) {
1408
- return parser.parse(args.slice(), opts).argv;
1409
- };
1410
- yargsParser.detailed = function(args, opts) {
1411
- return parser.parse(args.slice(), opts);
1412
- };
1413
- yargsParser.camelCase = camelCase;
1414
- yargsParser.decamelize = decamelize;
1415
- yargsParser.looksLikeNumber = looksLikeNumber;
1416
-
1417
- //#endregion
1418
- //#region node_modules/yargs/build/lib/utils/process-argv.js
1419
- function getProcessArgvBinIndex() {
1420
- if (isBundledElectronApp()) return 0;
1421
- return 1;
1422
- }
1423
- function isBundledElectronApp() {
1424
- return isElectronApp() && !process.defaultApp;
1425
- }
1426
- function isElectronApp() {
1427
- return !!process.versions.electron;
1428
- }
1429
- function hideBin(argv) {
1430
- return argv.slice(getProcessArgvBinIndex() + 1);
1431
- }
1432
- function getProcessArgvBin() {
1433
- return process.argv[getProcessArgvBinIndex()];
1434
- }
1435
-
1436
- //#endregion
1437
- //#region node_modules/y18n/build/lib/platform-shims/node.js
1438
- var node_default = {
1439
- fs: {
1440
- readFileSync,
1441
- writeFile
1442
- },
1443
- format,
1444
- resolve,
1445
- exists: (file) => {
1446
- try {
1447
- return statSync(file).isFile();
1448
- } catch (err) {
1449
- return false;
1450
- }
1451
- }
1452
- };
1453
-
1454
- //#endregion
1455
- //#region node_modules/y18n/build/lib/index.js
1456
- let shim$1;
1457
- var Y18N = class {
1458
- constructor(opts) {
1459
- opts = opts || {};
1460
- this.directory = opts.directory || "./locales";
1461
- this.updateFiles = typeof opts.updateFiles === "boolean" ? opts.updateFiles : true;
1462
- this.locale = opts.locale || "en";
1463
- this.fallbackToLanguage = typeof opts.fallbackToLanguage === "boolean" ? opts.fallbackToLanguage : true;
1464
- this.cache = Object.create(null);
1465
- this.writeQueue = [];
1466
- }
1467
- __(...args) {
1468
- if (typeof arguments[0] !== "string") return this._taggedLiteral(arguments[0], ...arguments);
1469
- const str = args.shift();
1470
- let cb = function() {};
1471
- if (typeof args[args.length - 1] === "function") cb = args.pop();
1472
- cb = cb || function() {};
1473
- if (!this.cache[this.locale]) this._readLocaleFile();
1474
- if (!this.cache[this.locale][str] && this.updateFiles) {
1475
- this.cache[this.locale][str] = str;
1476
- this._enqueueWrite({
1477
- directory: this.directory,
1478
- locale: this.locale,
1479
- cb
1480
- });
1481
- } else cb();
1482
- return shim$1.format.apply(shim$1.format, [this.cache[this.locale][str] || str].concat(args));
1483
- }
1484
- __n() {
1485
- const args = Array.prototype.slice.call(arguments);
1486
- const singular = args.shift();
1487
- const plural = args.shift();
1488
- const quantity = args.shift();
1489
- let cb = function() {};
1490
- if (typeof args[args.length - 1] === "function") cb = args.pop();
1491
- if (!this.cache[this.locale]) this._readLocaleFile();
1492
- let str = quantity === 1 ? singular : plural;
1493
- if (this.cache[this.locale][singular]) str = this.cache[this.locale][singular][quantity === 1 ? "one" : "other"];
1494
- if (!this.cache[this.locale][singular] && this.updateFiles) {
1495
- this.cache[this.locale][singular] = {
1496
- one: singular,
1497
- other: plural
1498
- };
1499
- this._enqueueWrite({
1500
- directory: this.directory,
1501
- locale: this.locale,
1502
- cb
1503
- });
1504
- } else cb();
1505
- const values = [str];
1506
- if (~str.indexOf("%d")) values.push(quantity);
1507
- return shim$1.format.apply(shim$1.format, values.concat(args));
1508
- }
1509
- setLocale(locale) {
1510
- this.locale = locale;
1511
- }
1512
- getLocale() {
1513
- return this.locale;
1514
- }
1515
- updateLocale(obj) {
1516
- if (!this.cache[this.locale]) this._readLocaleFile();
1517
- for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) this.cache[this.locale][key] = obj[key];
1518
- }
1519
- _taggedLiteral(parts, ...args) {
1520
- let str = "";
1521
- parts.forEach(function(part, i) {
1522
- const arg = args[i + 1];
1523
- str += part;
1524
- if (typeof arg !== "undefined") str += "%s";
1525
- });
1526
- return this.__.apply(this, [str].concat([].slice.call(args, 1)));
1527
- }
1528
- _enqueueWrite(work) {
1529
- this.writeQueue.push(work);
1530
- if (this.writeQueue.length === 1) this._processWriteQueue();
1531
- }
1532
- _processWriteQueue() {
1533
- const _this = this;
1534
- const work = this.writeQueue[0];
1535
- const directory = work.directory;
1536
- const locale = work.locale;
1537
- const cb = work.cb;
1538
- const languageFile = this._resolveLocaleFile(directory, locale);
1539
- const serializedLocale = JSON.stringify(this.cache[locale], null, 2);
1540
- shim$1.fs.writeFile(languageFile, serializedLocale, "utf-8", function(err) {
1541
- _this.writeQueue.shift();
1542
- if (_this.writeQueue.length > 0) _this._processWriteQueue();
1543
- cb(err);
1544
- });
1545
- }
1546
- _readLocaleFile() {
1547
- let localeLookup = {};
1548
- const languageFile = this._resolveLocaleFile(this.directory, this.locale);
1549
- try {
1550
- if (shim$1.fs.readFileSync) localeLookup = JSON.parse(shim$1.fs.readFileSync(languageFile, "utf-8"));
1551
- } catch (err) {
1552
- if (err instanceof SyntaxError) err.message = "syntax error in " + languageFile;
1553
- if (err.code === "ENOENT") localeLookup = {};
1554
- else throw err;
1555
- }
1556
- this.cache[this.locale] = localeLookup;
1557
- }
1558
- _resolveLocaleFile(directory, locale) {
1559
- let file = shim$1.resolve(directory, "./", locale + ".json");
1560
- if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf("_")) {
1561
- const languageFile = shim$1.resolve(directory, "./", locale.split("_")[0] + ".json");
1562
- if (this._fileExistsSync(languageFile)) file = languageFile;
1563
- }
1564
- return file;
1565
- }
1566
- _fileExistsSync(file) {
1567
- return shim$1.exists(file);
1568
- }
1569
- };
1570
- function y18n$1(opts, _shim) {
1571
- shim$1 = _shim;
1572
- const y18n = new Y18N(opts);
1573
- return {
1574
- __: y18n.__.bind(y18n),
1575
- __n: y18n.__n.bind(y18n),
1576
- setLocale: y18n.setLocale.bind(y18n),
1577
- getLocale: y18n.getLocale.bind(y18n),
1578
- updateLocale: y18n.updateLocale.bind(y18n),
1579
- locale: y18n.locale
1580
- };
1581
- }
1582
-
1583
- //#endregion
1584
- //#region node_modules/y18n/index.mjs
1585
- const y18n = (opts) => {
1586
- return y18n$1(opts, node_default);
1587
- };
1588
-
1589
- //#endregion
1590
- //#region node_modules/get-caller-file/index.js
1591
- var require_get_caller_file = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1592
- module.exports = function getCallerFile(position) {
1593
- if (position === void 0) position = 2;
1594
- if (position >= Error.stackTraceLimit) throw new TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `" + position + "` and Error.stackTraceLimit was: `" + Error.stackTraceLimit + "`");
1595
- var oldPrepareStackTrace = Error.prepareStackTrace;
1596
- Error.prepareStackTrace = function(_, stack) {
1597
- return stack;
1598
- };
1599
- var stack = (/* @__PURE__ */ new Error()).stack;
1600
- Error.prepareStackTrace = oldPrepareStackTrace;
1601
- if (stack !== null && typeof stack === "object") return stack[position] ? stack[position].getFileName() : void 0;
1602
- };
1603
- }));
1604
-
1605
- //#endregion
1606
- //#region node_modules/yargs/lib/platform-shims/esm.mjs
1607
- var import_get_caller_file = /* @__PURE__ */ __toESM(require_get_caller_file(), 1);
1608
- const __dirname = fileURLToPath(import.meta.url);
1609
- const mainFilename = __dirname.substring(0, __dirname.lastIndexOf("node_modules"));
1610
- const require = createRequire(import.meta.url);
1611
- var esm_default = {
1612
- assert: {
1613
- notStrictEqual,
1614
- strictEqual
1615
- },
1616
- cliui: ui,
1617
- findUp: sync_default,
1618
- getEnv: (key) => {
1619
- return process.env[key];
1620
- },
1621
- inspect,
1622
- getProcessArgvBin,
1623
- mainFilename: mainFilename || process.cwd(),
1624
- Parser: yargsParser,
1625
- path: {
1626
- basename,
1627
- dirname,
1628
- extname,
1629
- relative,
1630
- resolve,
1631
- join
1632
- },
1633
- process: {
1634
- argv: () => process.argv,
1635
- cwd: process.cwd,
1636
- emitWarning: (warning, type) => process.emitWarning(warning, type),
1637
- execPath: () => process.execPath,
1638
- exit: (code) => {
1639
- process.exit(code);
1640
- },
1641
- nextTick: process.nextTick,
1642
- stdColumns: typeof process.stdout.columns !== "undefined" ? process.stdout.columns : null
1643
- },
1644
- readFileSync: readFileSync$1,
1645
- readdirSync: readdirSync$1,
1646
- require,
1647
- getCallerFile: () => {
1648
- const callerFile = (0, import_get_caller_file.default)(3);
1649
- return callerFile.match(/^file:\/\//) ? fileURLToPath(callerFile) : callerFile;
1650
- },
1651
- stringWidth,
1652
- y18n: y18n({
1653
- directory: resolve(__dirname, "../../../locales"),
1654
- updateFiles: false
1655
- })
1656
- };
1657
-
1658
- //#endregion
1659
- //#region node_modules/yargs/build/lib/typings/common-types.js
1660
- function assertNotStrictEqual(actual, expected, shim, message) {
1661
- shim.assert.notStrictEqual(actual, expected, message);
1662
- }
1663
- function assertSingleKey(actual, shim) {
1664
- shim.assert.strictEqual(typeof actual, "string");
1665
- }
1666
- function objectKeys(object) {
1667
- return Object.keys(object);
1668
- }
1669
-
1670
- //#endregion
1671
- //#region node_modules/yargs/build/lib/utils/is-promise.js
1672
- function isPromise(maybePromise) {
1673
- return !!maybePromise && !!maybePromise.then && typeof maybePromise.then === "function";
1674
- }
1675
-
1676
- //#endregion
1677
- //#region node_modules/yargs/build/lib/yerror.js
1678
- var YError = class YError extends Error {
1679
- constructor(msg) {
1680
- super(msg || "yargs error");
1681
- this.name = "YError";
1682
- if (Error.captureStackTrace) Error.captureStackTrace(this, YError);
1683
- }
1684
- };
1685
-
1686
- //#endregion
1687
- //#region node_modules/yargs/build/lib/parse-command.js
1688
- function parseCommand(cmd) {
1689
- const splitCommand = cmd.replace(/\s{2,}/g, " ").split(/\s+(?![^[]*]|[^<]*>)/);
1690
- const bregex = /\.*[\][<>]/g;
1691
- const firstCommand = splitCommand.shift();
1692
- if (!firstCommand) throw new Error(`No command found in: ${cmd}`);
1693
- const parsedCommand = {
1694
- cmd: firstCommand.replace(bregex, ""),
1695
- demanded: [],
1696
- optional: []
1697
- };
1698
- splitCommand.forEach((cmd, i) => {
1699
- let variadic = false;
1700
- cmd = cmd.replace(/\s/g, "");
1701
- if (/\.+[\]>]/.test(cmd) && i === splitCommand.length - 1) variadic = true;
1702
- if (/^\[/.test(cmd)) parsedCommand.optional.push({
1703
- cmd: cmd.replace(bregex, "").split("|"),
1704
- variadic
1705
- });
1706
- else parsedCommand.demanded.push({
1707
- cmd: cmd.replace(bregex, "").split("|"),
1708
- variadic
1709
- });
1710
- });
1711
- return parsedCommand;
1712
- }
1713
-
1714
- //#endregion
1715
- //#region node_modules/yargs/build/lib/argsert.js
1716
- const positionName = [
1717
- "first",
1718
- "second",
1719
- "third",
1720
- "fourth",
1721
- "fifth",
1722
- "sixth"
1723
- ];
1724
- function argsert(arg1, arg2, arg3) {
1725
- function parseArgs() {
1726
- return typeof arg1 === "object" ? [
1727
- {
1728
- demanded: [],
1729
- optional: []
1730
- },
1731
- arg1,
1732
- arg2
1733
- ] : [
1734
- parseCommand(`cmd ${arg1}`),
1735
- arg2,
1736
- arg3
1737
- ];
1738
- }
1739
- try {
1740
- let position = 0;
1741
- const [parsed, callerArguments, _length] = parseArgs();
1742
- const args = [].slice.call(callerArguments);
1743
- while (args.length && args[args.length - 1] === void 0) args.pop();
1744
- const length = _length || args.length;
1745
- if (length < parsed.demanded.length) throw new YError(`Not enough arguments provided. Expected ${parsed.demanded.length} but received ${args.length}.`);
1746
- const totalCommands = parsed.demanded.length + parsed.optional.length;
1747
- if (length > totalCommands) throw new YError(`Too many arguments provided. Expected max ${totalCommands} but received ${length}.`);
1748
- parsed.demanded.forEach((demanded) => {
1749
- const observedType = guessType(args.shift());
1750
- if (demanded.cmd.filter((type) => type === observedType || type === "*").length === 0) argumentTypeError(observedType, demanded.cmd, position);
1751
- position += 1;
1752
- });
1753
- parsed.optional.forEach((optional) => {
1754
- if (args.length === 0) return;
1755
- const observedType = guessType(args.shift());
1756
- if (optional.cmd.filter((type) => type === observedType || type === "*").length === 0) argumentTypeError(observedType, optional.cmd, position);
1757
- position += 1;
1758
- });
1759
- } catch (err) {
1760
- console.warn(err.stack);
1761
- }
1762
- }
1763
- function guessType(arg) {
1764
- if (Array.isArray(arg)) return "array";
1765
- else if (arg === null) return "null";
1766
- return typeof arg;
1767
- }
1768
- function argumentTypeError(observedType, allowedTypes, position) {
1769
- throw new YError(`Invalid ${positionName[position] || "manyith"} argument. Expected ${allowedTypes.join(" or ")} but received ${observedType}.`);
1770
- }
1771
-
1772
- //#endregion
1773
- //#region node_modules/yargs/build/lib/middleware.js
1774
- var GlobalMiddleware = class {
1775
- constructor(yargs) {
1776
- this.globalMiddleware = [];
1777
- this.frozens = [];
1778
- this.yargs = yargs;
1779
- }
1780
- addMiddleware(callback, applyBeforeValidation, global = true, mutates = false) {
1781
- argsert("<array|function> [boolean] [boolean] [boolean]", [
1782
- callback,
1783
- applyBeforeValidation,
1784
- global
1785
- ], arguments.length);
1786
- if (Array.isArray(callback)) {
1787
- for (let i = 0; i < callback.length; i++) {
1788
- if (typeof callback[i] !== "function") throw Error("middleware must be a function");
1789
- const m = callback[i];
1790
- m.applyBeforeValidation = applyBeforeValidation;
1791
- m.global = global;
1792
- }
1793
- Array.prototype.push.apply(this.globalMiddleware, callback);
1794
- } else if (typeof callback === "function") {
1795
- const m = callback;
1796
- m.applyBeforeValidation = applyBeforeValidation;
1797
- m.global = global;
1798
- m.mutates = mutates;
1799
- this.globalMiddleware.push(callback);
1800
- }
1801
- return this.yargs;
1802
- }
1803
- addCoerceMiddleware(callback, option) {
1804
- const aliases = this.yargs.getAliases();
1805
- this.globalMiddleware = this.globalMiddleware.filter((m) => {
1806
- const toCheck = [...aliases[option] || [], option];
1807
- if (!m.option) return true;
1808
- else return !toCheck.includes(m.option);
1809
- });
1810
- callback.option = option;
1811
- return this.addMiddleware(callback, true, true, true);
1812
- }
1813
- getMiddleware() {
1814
- return this.globalMiddleware;
1815
- }
1816
- freeze() {
1817
- this.frozens.push([...this.globalMiddleware]);
1818
- }
1819
- unfreeze() {
1820
- const frozen = this.frozens.pop();
1821
- if (frozen !== void 0) this.globalMiddleware = frozen;
1822
- }
1823
- reset() {
1824
- this.globalMiddleware = this.globalMiddleware.filter((m) => m.global);
1825
- }
1826
- };
1827
- function commandMiddlewareFactory(commandMiddleware) {
1828
- if (!commandMiddleware) return [];
1829
- return commandMiddleware.map((middleware) => {
1830
- middleware.applyBeforeValidation = false;
1831
- return middleware;
1832
- });
1833
- }
1834
- function applyMiddleware(argv, yargs, middlewares, beforeValidation) {
1835
- return middlewares.reduce((acc, middleware) => {
1836
- if (middleware.applyBeforeValidation !== beforeValidation) return acc;
1837
- if (middleware.mutates) {
1838
- if (middleware.applied) return acc;
1839
- middleware.applied = true;
1840
- }
1841
- if (isPromise(acc)) return acc.then((initialObj) => Promise.all([initialObj, middleware(initialObj, yargs)])).then(([initialObj, middlewareObj]) => Object.assign(initialObj, middlewareObj));
1842
- else {
1843
- const result = middleware(acc, yargs);
1844
- return isPromise(result) ? result.then((middlewareObj) => Object.assign(acc, middlewareObj)) : Object.assign(acc, result);
1845
- }
1846
- }, argv);
1847
- }
1848
-
1849
- //#endregion
1850
- //#region node_modules/yargs/build/lib/utils/maybe-async-result.js
1851
- function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
1852
- throw err;
1853
- }) {
1854
- try {
1855
- const result = isFunction(getResult) ? getResult() : getResult;
1856
- return isPromise(result) ? result.then((result) => resultHandler(result)) : resultHandler(result);
1857
- } catch (err) {
1858
- return errorHandler(err);
1859
- }
1860
- }
1861
- function isFunction(arg) {
1862
- return typeof arg === "function";
1863
- }
1864
-
1865
- //#endregion
1866
- //#region node_modules/yargs/build/lib/command.js
1867
- const DEFAULT_MARKER = /(^\*)|(^\$0)/;
1868
- var CommandInstance = class {
1869
- constructor(usage, validation, globalMiddleware, shim) {
1870
- this.requireCache = /* @__PURE__ */ new Set();
1871
- this.handlers = {};
1872
- this.aliasMap = {};
1873
- this.frozens = [];
1874
- this.shim = shim;
1875
- this.usage = usage;
1876
- this.globalMiddleware = globalMiddleware;
1877
- this.validation = validation;
1878
- }
1879
- addDirectory(dir, req, callerFile, opts) {
1880
- opts = opts || {};
1881
- this.requireCache.add(callerFile);
1882
- const fullDirPath = this.shim.path.resolve(this.shim.path.dirname(callerFile), dir);
1883
- const files = this.shim.readdirSync(fullDirPath, { recursive: opts.recurse ? true : false });
1884
- if (!Array.isArray(opts.extensions)) opts.extensions = ["js"];
1885
- const visit = typeof opts.visit === "function" ? opts.visit : (o) => o;
1886
- for (const fileb of files) {
1887
- const file = fileb.toString();
1888
- if (opts.exclude) {
1889
- let exclude = false;
1890
- if (typeof opts.exclude === "function") exclude = opts.exclude(file);
1891
- else exclude = opts.exclude.test(file);
1892
- if (exclude) continue;
1893
- }
1894
- if (opts.include) {
1895
- let include = false;
1896
- if (typeof opts.include === "function") include = opts.include(file);
1897
- else include = opts.include.test(file);
1898
- if (!include) continue;
1899
- }
1900
- let supportedExtension = false;
1901
- for (const ext of opts.extensions) if (file.endsWith(ext)) supportedExtension = true;
1902
- if (supportedExtension) {
1903
- const joined = this.shim.path.join(fullDirPath, file);
1904
- const module = req(joined);
1905
- const extendableModule = Object.create(null, Object.getOwnPropertyDescriptors({ ...module }));
1906
- if (visit(extendableModule, joined, file)) {
1907
- if (this.requireCache.has(joined)) continue;
1908
- else this.requireCache.add(joined);
1909
- if (!extendableModule.command) extendableModule.command = this.shim.path.basename(joined, this.shim.path.extname(joined));
1910
- this.addHandler(extendableModule);
1911
- }
1912
- }
1913
- }
1914
- }
1915
- addHandler(cmd, description, builder, handler, commandMiddleware, deprecated) {
1916
- let aliases = [];
1917
- const middlewares = commandMiddlewareFactory(commandMiddleware);
1918
- handler = handler || (() => {});
1919
- if (Array.isArray(cmd)) if (isCommandAndAliases(cmd)) [cmd, ...aliases] = cmd;
1920
- else for (const command of cmd) this.addHandler(command);
1921
- else if (isCommandHandlerDefinition(cmd)) {
1922
- let command = Array.isArray(cmd.command) || typeof cmd.command === "string" ? cmd.command : null;
1923
- if (command === null) throw new Error(`No command name given for module: ${this.shim.inspect(cmd)}`);
1924
- if (cmd.aliases) command = [].concat(command).concat(cmd.aliases);
1925
- this.addHandler(command, this.extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
1926
- return;
1927
- } else if (isCommandBuilderDefinition(builder)) {
1928
- this.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares, builder.deprecated);
1929
- return;
1930
- }
1931
- if (typeof cmd === "string") {
1932
- const parsedCommand = parseCommand(cmd);
1933
- aliases = aliases.map((alias) => parseCommand(alias).cmd);
1934
- let isDefault = false;
1935
- const parsedAliases = [parsedCommand.cmd].concat(aliases).filter((c) => {
1936
- if (DEFAULT_MARKER.test(c)) {
1937
- isDefault = true;
1938
- return false;
1939
- }
1940
- return true;
1941
- });
1942
- if (parsedAliases.length === 0 && isDefault) parsedAliases.push("$0");
1943
- if (isDefault) {
1944
- parsedCommand.cmd = parsedAliases[0];
1945
- aliases = parsedAliases.slice(1);
1946
- cmd = cmd.replace(DEFAULT_MARKER, parsedCommand.cmd);
1947
- }
1948
- aliases.forEach((alias) => {
1949
- this.aliasMap[alias] = parsedCommand.cmd;
1950
- });
1951
- if (description !== false) this.usage.command(cmd, description, isDefault, aliases, deprecated);
1952
- this.handlers[parsedCommand.cmd] = {
1953
- original: cmd,
1954
- description,
1955
- handler,
1956
- builder: builder || {},
1957
- middlewares,
1958
- deprecated,
1959
- demanded: parsedCommand.demanded,
1960
- optional: parsedCommand.optional
1961
- };
1962
- if (isDefault) this.defaultCommand = this.handlers[parsedCommand.cmd];
1963
- }
1964
- }
1965
- getCommandHandlers() {
1966
- return this.handlers;
1967
- }
1968
- getCommands() {
1969
- return Object.keys(this.handlers).concat(Object.keys(this.aliasMap));
1970
- }
1971
- hasDefaultCommand() {
1972
- return !!this.defaultCommand;
1973
- }
1974
- runCommand(command, yargs, parsed, commandIndex, helpOnly, helpOrVersionSet) {
1975
- const commandHandler = this.handlers[command] || this.handlers[this.aliasMap[command]] || this.defaultCommand;
1976
- const currentContext = yargs.getInternalMethods().getContext();
1977
- const parentCommands = currentContext.commands.slice();
1978
- const isDefaultCommand = !command;
1979
- if (command) {
1980
- currentContext.commands.push(command);
1981
- currentContext.fullCommands.push(commandHandler.original);
1982
- }
1983
- const builderResult = this.applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, parsed.aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet);
1984
- return isPromise(builderResult) ? builderResult.then((result) => this.applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, result.innerArgv, currentContext, helpOnly, result.aliases, yargs)) : this.applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, builderResult.innerArgv, currentContext, helpOnly, builderResult.aliases, yargs);
1985
- }
1986
- applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet) {
1987
- const builder = commandHandler.builder;
1988
- let innerYargs = yargs;
1989
- if (isCommandBuilderCallback(builder)) {
1990
- yargs.getInternalMethods().getUsageInstance().freeze();
1991
- const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet);
1992
- if (isPromise(builderOutput)) return builderOutput.then((output) => {
1993
- innerYargs = isYargsInstance(output) ? output : yargs;
1994
- return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
1995
- });
1996
- } else if (isCommandBuilderOptionDefinitions(builder)) {
1997
- yargs.getInternalMethods().getUsageInstance().freeze();
1998
- innerYargs = yargs.getInternalMethods().reset(aliases);
1999
- Object.keys(commandHandler.builder).forEach((key) => {
2000
- innerYargs.option(key, builder[key]);
2001
- });
2002
- }
2003
- return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
2004
- }
2005
- parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly) {
2006
- if (isDefaultCommand) innerYargs.getInternalMethods().getUsageInstance().unfreeze(true);
2007
- if (this.shouldUpdateUsage(innerYargs)) innerYargs.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
2008
- const innerArgv = innerYargs.getInternalMethods().runYargsParserAndExecuteCommands(null, void 0, true, commandIndex, helpOnly);
2009
- return isPromise(innerArgv) ? innerArgv.then((argv) => ({
2010
- aliases: innerYargs.parsed.aliases,
2011
- innerArgv: argv
2012
- })) : {
2013
- aliases: innerYargs.parsed.aliases,
2014
- innerArgv
2015
- };
2016
- }
2017
- shouldUpdateUsage(yargs) {
2018
- return !yargs.getInternalMethods().getUsageInstance().getUsageDisabled() && yargs.getInternalMethods().getUsageInstance().getUsage().length === 0;
2019
- }
2020
- usageFromParentCommandsCommandHandler(parentCommands, commandHandler) {
2021
- const c = DEFAULT_MARKER.test(commandHandler.original) ? commandHandler.original.replace(DEFAULT_MARKER, "").trim() : commandHandler.original;
2022
- const pc = parentCommands.filter((c) => {
2023
- return !DEFAULT_MARKER.test(c);
2024
- });
2025
- pc.push(c);
2026
- return `$0 ${pc.join(" ")}`;
2027
- }
2028
- handleValidationAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, aliases, yargs, middlewares, positionalMap) {
2029
- if (!yargs.getInternalMethods().getHasOutput()) {
2030
- const validation = yargs.getInternalMethods().runValidation(aliases, positionalMap, yargs.parsed.error, isDefaultCommand);
2031
- innerArgv = maybeAsyncResult(innerArgv, (result) => {
2032
- validation(result);
2033
- return result;
2034
- });
2035
- }
2036
- if (commandHandler.handler && !yargs.getInternalMethods().getHasOutput()) {
2037
- yargs.getInternalMethods().setHasOutput();
2038
- const populateDoubleDash = !!yargs.getOptions().configuration["populate--"];
2039
- yargs.getInternalMethods().postProcess(innerArgv, populateDoubleDash, false, false);
2040
- innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false);
2041
- innerArgv = maybeAsyncResult(innerArgv, (result) => {
2042
- const handlerResult = commandHandler.handler(result);
2043
- return isPromise(handlerResult) ? handlerResult.then(() => result) : result;
2044
- });
2045
- if (!isDefaultCommand) yargs.getInternalMethods().getUsageInstance().cacheHelpMessage();
2046
- if (isPromise(innerArgv) && !yargs.getInternalMethods().hasParseCallback()) innerArgv.catch((error) => {
2047
- try {
2048
- yargs.getInternalMethods().getUsageInstance().fail(null, error);
2049
- } catch (_err) {}
2050
- });
2051
- }
2052
- if (!isDefaultCommand) {
2053
- currentContext.commands.pop();
2054
- currentContext.fullCommands.pop();
2055
- }
2056
- return innerArgv;
2057
- }
2058
- applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
2059
- let positionalMap = {};
2060
- if (helpOnly) return innerArgv;
2061
- if (!yargs.getInternalMethods().getHasOutput()) positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
2062
- const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
2063
- const maybePromiseArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
2064
- return isPromise(maybePromiseArgv) ? maybePromiseArgv.then((resolvedInnerArgv) => this.handleValidationAndGetResult(isDefaultCommand, commandHandler, resolvedInnerArgv, currentContext, aliases, yargs, middlewares, positionalMap)) : this.handleValidationAndGetResult(isDefaultCommand, commandHandler, maybePromiseArgv, currentContext, aliases, yargs, middlewares, positionalMap);
2065
- }
2066
- populatePositionals(commandHandler, argv, context, yargs) {
2067
- argv._ = argv._.slice(context.commands.length);
2068
- const demanded = commandHandler.demanded.slice(0);
2069
- const optional = commandHandler.optional.slice(0);
2070
- const positionalMap = {};
2071
- this.validation.positionalCount(demanded.length, argv._.length);
2072
- while (demanded.length) {
2073
- const demand = demanded.shift();
2074
- this.populatePositional(demand, argv, positionalMap);
2075
- }
2076
- while (optional.length) {
2077
- const maybe = optional.shift();
2078
- this.populatePositional(maybe, argv, positionalMap);
2079
- }
2080
- argv._ = context.commands.concat(argv._.map((a) => "" + a));
2081
- this.postProcessPositionals(argv, positionalMap, this.cmdToParseOptions(commandHandler.original), yargs);
2082
- return positionalMap;
2083
- }
2084
- populatePositional(positional, argv, positionalMap) {
2085
- const cmd = positional.cmd[0];
2086
- if (positional.variadic) positionalMap[cmd] = argv._.splice(0).map(String);
2087
- else if (argv._.length) positionalMap[cmd] = [String(argv._.shift())];
2088
- }
2089
- cmdToParseOptions(cmdString) {
2090
- const parseOptions = {
2091
- array: [],
2092
- default: {},
2093
- alias: {},
2094
- demand: {}
2095
- };
2096
- const parsed = parseCommand(cmdString);
2097
- parsed.demanded.forEach((d) => {
2098
- const [cmd, ...aliases] = d.cmd;
2099
- if (d.variadic) {
2100
- parseOptions.array.push(cmd);
2101
- parseOptions.default[cmd] = [];
2102
- }
2103
- parseOptions.alias[cmd] = aliases;
2104
- parseOptions.demand[cmd] = true;
2105
- });
2106
- parsed.optional.forEach((o) => {
2107
- const [cmd, ...aliases] = o.cmd;
2108
- if (o.variadic) {
2109
- parseOptions.array.push(cmd);
2110
- parseOptions.default[cmd] = [];
2111
- }
2112
- parseOptions.alias[cmd] = aliases;
2113
- });
2114
- return parseOptions;
2115
- }
2116
- postProcessPositionals(argv, positionalMap, parseOptions, yargs) {
2117
- const options = Object.assign({}, yargs.getOptions());
2118
- options.default = Object.assign(parseOptions.default, options.default);
2119
- for (const key of Object.keys(parseOptions.alias)) options.alias[key] = (options.alias[key] || []).concat(parseOptions.alias[key]);
2120
- options.array = options.array.concat(parseOptions.array);
2121
- options.config = {};
2122
- const unparsed = [];
2123
- Object.keys(positionalMap).forEach((key) => {
2124
- positionalMap[key].map((value) => {
2125
- if (options.configuration["unknown-options-as-args"]) options.key[key] = true;
2126
- unparsed.push(`--${key}`);
2127
- unparsed.push(value);
2128
- });
2129
- });
2130
- if (!unparsed.length) return;
2131
- const config = Object.assign({}, options.configuration, { "populate--": false });
2132
- const parsed = this.shim.Parser.detailed(unparsed, Object.assign({}, options, { configuration: config }));
2133
- if (parsed.error) yargs.getInternalMethods().getUsageInstance().fail(parsed.error.message, parsed.error);
2134
- else {
2135
- const positionalKeys = Object.keys(positionalMap);
2136
- Object.keys(positionalMap).forEach((key) => {
2137
- positionalKeys.push(...parsed.aliases[key]);
2138
- });
2139
- Object.keys(parsed.argv).forEach((key) => {
2140
- if (positionalKeys.includes(key)) {
2141
- if (!positionalMap[key]) positionalMap[key] = parsed.argv[key];
2142
- if (!this.isInConfigs(yargs, key) && !this.isDefaulted(yargs, key) && Object.prototype.hasOwnProperty.call(argv, key) && Object.prototype.hasOwnProperty.call(parsed.argv, key) && (Array.isArray(argv[key]) || Array.isArray(parsed.argv[key]))) argv[key] = [].concat(argv[key], parsed.argv[key]);
2143
- else argv[key] = parsed.argv[key];
2144
- }
2145
- });
2146
- }
2147
- }
2148
- isDefaulted(yargs, key) {
2149
- const { default: defaults } = yargs.getOptions();
2150
- return Object.prototype.hasOwnProperty.call(defaults, key) || Object.prototype.hasOwnProperty.call(defaults, this.shim.Parser.camelCase(key));
2151
- }
2152
- isInConfigs(yargs, key) {
2153
- const { configObjects } = yargs.getOptions();
2154
- return configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, key)) || configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, this.shim.Parser.camelCase(key)));
2155
- }
2156
- runDefaultBuilderOn(yargs) {
2157
- if (!this.defaultCommand) return;
2158
- if (this.shouldUpdateUsage(yargs)) {
2159
- const commandString = DEFAULT_MARKER.test(this.defaultCommand.original) ? this.defaultCommand.original : this.defaultCommand.original.replace(/^[^[\]<>]*/, "$0 ");
2160
- yargs.getInternalMethods().getUsageInstance().usage(commandString, this.defaultCommand.description);
2161
- }
2162
- const builder = this.defaultCommand.builder;
2163
- if (isCommandBuilderCallback(builder)) return builder(yargs, true);
2164
- else if (!isCommandBuilderDefinition(builder)) Object.keys(builder).forEach((key) => {
2165
- yargs.option(key, builder[key]);
2166
- });
2167
- }
2168
- extractDesc({ describe, description, desc }) {
2169
- for (const test of [
2170
- describe,
2171
- description,
2172
- desc
2173
- ]) {
2174
- if (typeof test === "string" || test === false) return test;
2175
- assertNotStrictEqual(test, true, this.shim);
2176
- }
2177
- return false;
2178
- }
2179
- freeze() {
2180
- this.frozens.push({
2181
- handlers: this.handlers,
2182
- aliasMap: this.aliasMap,
2183
- defaultCommand: this.defaultCommand
2184
- });
2185
- }
2186
- unfreeze() {
2187
- const frozen = this.frozens.pop();
2188
- assertNotStrictEqual(frozen, void 0, this.shim);
2189
- ({handlers: this.handlers, aliasMap: this.aliasMap, defaultCommand: this.defaultCommand} = frozen);
2190
- }
2191
- reset() {
2192
- this.handlers = {};
2193
- this.aliasMap = {};
2194
- this.defaultCommand = void 0;
2195
- this.requireCache = /* @__PURE__ */ new Set();
2196
- return this;
2197
- }
2198
- };
2199
- function command(usage, validation, globalMiddleware, shim) {
2200
- return new CommandInstance(usage, validation, globalMiddleware, shim);
2201
- }
2202
- function isCommandBuilderDefinition(builder) {
2203
- return typeof builder === "object" && !!builder.builder && typeof builder.handler === "function";
2204
- }
2205
- function isCommandAndAliases(cmd) {
2206
- return cmd.every((c) => typeof c === "string");
2207
- }
2208
- function isCommandBuilderCallback(builder) {
2209
- return typeof builder === "function";
2210
- }
2211
- function isCommandBuilderOptionDefinitions(builder) {
2212
- return typeof builder === "object";
2213
- }
2214
- function isCommandHandlerDefinition(cmd) {
2215
- return typeof cmd === "object" && !Array.isArray(cmd);
2216
- }
2217
-
2218
- //#endregion
2219
- //#region node_modules/yargs/build/lib/utils/obj-filter.js
2220
- function objFilter(original = {}, filter = () => true) {
2221
- const obj = {};
2222
- objectKeys(original).forEach((key) => {
2223
- if (filter(key, original[key])) obj[key] = original[key];
2224
- });
2225
- return obj;
2226
- }
2227
-
2228
- //#endregion
2229
- //#region node_modules/yargs/build/lib/utils/set-blocking.js
2230
- function setBlocking(blocking) {
2231
- if (typeof process === "undefined") return;
2232
- [process.stdout, process.stderr].forEach((_stream) => {
2233
- const stream = _stream;
2234
- if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === "function") stream._handle.setBlocking(blocking);
2235
- });
2236
- }
2237
-
2238
- //#endregion
2239
- //#region node_modules/yargs/build/lib/usage.js
2240
- function isBoolean(fail) {
2241
- return typeof fail === "boolean";
2242
- }
2243
- function usage(yargs, shim) {
2244
- const __ = shim.y18n.__;
2245
- const self = {};
2246
- const fails = [];
2247
- self.failFn = function failFn(f) {
2248
- fails.push(f);
2249
- };
2250
- let failMessage = null;
2251
- let globalFailMessage = null;
2252
- let showHelpOnFail = true;
2253
- self.showHelpOnFail = function showHelpOnFailFn(arg1 = true, arg2) {
2254
- const [enabled, message] = typeof arg1 === "string" ? [true, arg1] : [arg1, arg2];
2255
- if (yargs.getInternalMethods().isGlobalContext()) globalFailMessage = message;
2256
- failMessage = message;
2257
- showHelpOnFail = enabled;
2258
- return self;
2259
- };
2260
- let failureOutput = false;
2261
- self.fail = function fail(msg, err) {
2262
- const logger = yargs.getInternalMethods().getLoggerInstance();
2263
- if (fails.length) for (let i = fails.length - 1; i >= 0; --i) {
2264
- const fail = fails[i];
2265
- if (isBoolean(fail)) {
2266
- if (err) throw err;
2267
- else if (msg) throw Error(msg);
2268
- } else fail(msg, err, self);
2269
- }
2270
- else {
2271
- if (yargs.getExitProcess()) setBlocking(true);
2272
- if (!failureOutput) {
2273
- failureOutput = true;
2274
- if (showHelpOnFail) {
2275
- yargs.showHelp("error");
2276
- logger.error();
2277
- }
2278
- if (msg || err) logger.error(msg || err);
2279
- const globalOrCommandFailMessage = failMessage || globalFailMessage;
2280
- if (globalOrCommandFailMessage) {
2281
- if (msg || err) logger.error("");
2282
- logger.error(globalOrCommandFailMessage);
2283
- }
2284
- }
2285
- err = err || new YError(msg);
2286
- if (yargs.getExitProcess()) return yargs.exit(1);
2287
- else if (yargs.getInternalMethods().hasParseCallback()) return yargs.exit(1, err);
2288
- else throw err;
2289
- }
2290
- };
2291
- let usages = [];
2292
- let usageDisabled = false;
2293
- self.usage = (msg, description) => {
2294
- if (msg === null) {
2295
- usageDisabled = true;
2296
- usages = [];
2297
- return self;
2298
- }
2299
- usageDisabled = false;
2300
- usages.push([msg, description || ""]);
2301
- return self;
2302
- };
2303
- self.getUsage = () => {
2304
- return usages;
2305
- };
2306
- self.getUsageDisabled = () => {
2307
- return usageDisabled;
2308
- };
2309
- self.getPositionalGroupName = () => {
2310
- return __("Positionals:");
2311
- };
2312
- let examples = [];
2313
- self.example = (cmd, description) => {
2314
- examples.push([cmd, description || ""]);
2315
- };
2316
- let commands = [];
2317
- self.command = function command(cmd, description, isDefault, aliases, deprecated = false) {
2318
- if (isDefault) commands = commands.map((cmdArray) => {
2319
- cmdArray[2] = false;
2320
- return cmdArray;
2321
- });
2322
- commands.push([
2323
- cmd,
2324
- description || "",
2325
- isDefault,
2326
- aliases,
2327
- deprecated
2328
- ]);
2329
- };
2330
- self.getCommands = () => commands;
2331
- let descriptions = {};
2332
- self.describe = function describe(keyOrKeys, desc) {
2333
- if (Array.isArray(keyOrKeys)) keyOrKeys.forEach((k) => {
2334
- self.describe(k, desc);
2335
- });
2336
- else if (typeof keyOrKeys === "object") Object.keys(keyOrKeys).forEach((k) => {
2337
- self.describe(k, keyOrKeys[k]);
2338
- });
2339
- else descriptions[keyOrKeys] = desc;
2340
- };
2341
- self.getDescriptions = () => descriptions;
2342
- let epilogs = [];
2343
- self.epilog = (msg) => {
2344
- epilogs.push(msg);
2345
- };
2346
- let wrapSet = false;
2347
- let wrap;
2348
- self.wrap = (cols) => {
2349
- wrapSet = true;
2350
- wrap = cols;
2351
- };
2352
- self.getWrap = () => {
2353
- if (shim.getEnv("YARGS_DISABLE_WRAP")) return null;
2354
- if (!wrapSet) {
2355
- wrap = windowWidth();
2356
- wrapSet = true;
2357
- }
2358
- return wrap;
2359
- };
2360
- const deferY18nLookupPrefix = "__yargsString__:";
2361
- self.deferY18nLookup = (str) => deferY18nLookupPrefix + str;
2362
- self.help = function help() {
2363
- if (cachedHelpMessage) return cachedHelpMessage;
2364
- normalizeAliases();
2365
- const base$0 = yargs.customScriptName ? yargs.$0 : shim.path.basename(yargs.$0);
2366
- const demandedOptions = yargs.getDemandedOptions();
2367
- const demandedCommands = yargs.getDemandedCommands();
2368
- const deprecatedOptions = yargs.getDeprecatedOptions();
2369
- const groups = yargs.getGroups();
2370
- const options = yargs.getOptions();
2371
- let keys = [];
2372
- keys = keys.concat(Object.keys(descriptions));
2373
- keys = keys.concat(Object.keys(demandedOptions));
2374
- keys = keys.concat(Object.keys(demandedCommands));
2375
- keys = keys.concat(Object.keys(options.default));
2376
- keys = keys.filter(filterHiddenOptions);
2377
- keys = Object.keys(keys.reduce((acc, key) => {
2378
- if (key !== "_") acc[key] = true;
2379
- return acc;
2380
- }, {}));
2381
- const theWrap = self.getWrap();
2382
- const ui = shim.cliui({
2383
- width: theWrap,
2384
- wrap: !!theWrap
2385
- });
2386
- if (!usageDisabled) {
2387
- if (usages.length) {
2388
- usages.forEach((usage) => {
2389
- ui.div({ text: `${usage[0].replace(/\$0/g, base$0)}` });
2390
- if (usage[1]) ui.div({
2391
- text: `${usage[1]}`,
2392
- padding: [
2393
- 1,
2394
- 0,
2395
- 0,
2396
- 0
2397
- ]
2398
- });
2399
- });
2400
- ui.div();
2401
- } else if (commands.length) {
2402
- let u = null;
2403
- if (demandedCommands._) u = `${base$0} <${__("command")}>\n`;
2404
- else u = `${base$0} [${__("command")}]\n`;
2405
- ui.div(`${u}`);
2406
- }
2407
- }
2408
- if (commands.length > 1 || commands.length === 1 && !commands[0][2]) {
2409
- ui.div(__("Commands:"));
2410
- const context = yargs.getInternalMethods().getContext();
2411
- const parentCommands = context.commands.length ? `${context.commands.join(" ")} ` : "";
2412
- if (yargs.getInternalMethods().getParserConfiguration()["sort-commands"] === true) commands = commands.sort((a, b) => a[0].localeCompare(b[0]));
2413
- const prefix = base$0 ? `${base$0} ` : "";
2414
- commands.forEach((command) => {
2415
- const commandString = `${prefix}${parentCommands}${command[0].replace(/^\$0 ?/, "")}`;
2416
- ui.span({
2417
- text: commandString,
2418
- padding: [
2419
- 0,
2420
- 2,
2421
- 0,
2422
- 2
2423
- ],
2424
- width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4
2425
- }, { text: command[1] });
2426
- const hints = [];
2427
- if (command[2]) hints.push(`[${__("default")}]`);
2428
- if (command[3] && command[3].length) hints.push(`[${__("aliases:")} ${command[3].join(", ")}]`);
2429
- if (command[4]) if (typeof command[4] === "string") hints.push(`[${__("deprecated: %s", command[4])}]`);
2430
- else hints.push(`[${__("deprecated")}]`);
2431
- if (hints.length) ui.div({
2432
- text: hints.join(" "),
2433
- padding: [
2434
- 0,
2435
- 0,
2436
- 0,
2437
- 2
2438
- ],
2439
- align: "right"
2440
- });
2441
- else ui.div();
2442
- });
2443
- ui.div();
2444
- }
2445
- const aliasKeys = (Object.keys(options.alias) || []).concat(Object.keys(yargs.parsed.newAliases) || []);
2446
- keys = keys.filter((key) => !yargs.parsed.newAliases[key] && aliasKeys.every((alias) => (options.alias[alias] || []).indexOf(key) === -1));
2447
- const defaultGroup = __("Options:");
2448
- if (!groups[defaultGroup]) groups[defaultGroup] = [];
2449
- addUngroupedKeys(keys, options.alias, groups, defaultGroup);
2450
- const isLongSwitch = (sw) => /^--/.test(getText(sw));
2451
- const displayedGroups = Object.keys(groups).filter((groupName) => groups[groupName].length > 0).map((groupName) => {
2452
- return {
2453
- groupName,
2454
- normalizedKeys: groups[groupName].filter(filterHiddenOptions).map((key) => {
2455
- if (aliasKeys.includes(key)) return key;
2456
- for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== void 0; i++) if ((options.alias[aliasKey] || []).includes(key)) return aliasKey;
2457
- return key;
2458
- })
2459
- };
2460
- }).filter(({ normalizedKeys }) => normalizedKeys.length > 0).map(({ groupName, normalizedKeys }) => {
2461
- return {
2462
- groupName,
2463
- normalizedKeys,
2464
- switches: normalizedKeys.reduce((acc, key) => {
2465
- acc[key] = [key].concat(options.alias[key] || []).map((sw) => {
2466
- if (groupName === self.getPositionalGroupName()) return sw;
2467
- else return (/^[0-9]$/.test(sw) ? options.boolean.includes(key) ? "-" : "--" : sw.length > 1 ? "--" : "-") + sw;
2468
- }).sort((sw1, sw2) => isLongSwitch(sw1) === isLongSwitch(sw2) ? 0 : isLongSwitch(sw1) ? 1 : -1).join(", ");
2469
- return acc;
2470
- }, {})
2471
- };
2472
- });
2473
- if (displayedGroups.filter(({ groupName }) => groupName !== self.getPositionalGroupName()).some(({ normalizedKeys, switches }) => !normalizedKeys.every((key) => isLongSwitch(switches[key])))) displayedGroups.filter(({ groupName }) => groupName !== self.getPositionalGroupName()).forEach(({ normalizedKeys, switches }) => {
2474
- normalizedKeys.forEach((key) => {
2475
- if (isLongSwitch(switches[key])) switches[key] = addIndentation(switches[key], 4);
2476
- });
2477
- });
2478
- displayedGroups.forEach(({ groupName, normalizedKeys, switches }) => {
2479
- ui.div(groupName);
2480
- normalizedKeys.forEach((key) => {
2481
- const kswitch = switches[key];
2482
- let desc = descriptions[key] || "";
2483
- let type = null;
2484
- if (desc.includes(deferY18nLookupPrefix)) desc = __(desc.substring(16));
2485
- if (options.boolean.includes(key)) type = `[${__("boolean")}]`;
2486
- if (options.count.includes(key)) type = `[${__("count")}]`;
2487
- if (options.string.includes(key)) type = `[${__("string")}]`;
2488
- if (options.normalize.includes(key)) type = `[${__("string")}]`;
2489
- if (options.array.includes(key)) type = `[${__("array")}]`;
2490
- if (options.number.includes(key)) type = `[${__("number")}]`;
2491
- const deprecatedExtra = (deprecated) => typeof deprecated === "string" ? `[${__("deprecated: %s", deprecated)}]` : `[${__("deprecated")}]`;
2492
- const extra = [
2493
- key in deprecatedOptions ? deprecatedExtra(deprecatedOptions[key]) : null,
2494
- type,
2495
- key in demandedOptions ? `[${__("required")}]` : null,
2496
- options.choices && options.choices[key] ? `[${__("choices:")} ${self.stringifiedValues(options.choices[key])}]` : null,
2497
- defaultString(options.default[key], options.defaultDescription[key])
2498
- ].filter(Boolean).join(" ");
2499
- ui.span({
2500
- text: getText(kswitch),
2501
- padding: [
2502
- 0,
2503
- 2,
2504
- 0,
2505
- 2 + getIndentation(kswitch)
2506
- ],
2507
- width: maxWidth(switches, theWrap) + 4
2508
- }, desc);
2509
- const shouldHideOptionExtras = yargs.getInternalMethods().getUsageConfiguration()["hide-types"] === true;
2510
- if (extra && !shouldHideOptionExtras) ui.div({
2511
- text: extra,
2512
- padding: [
2513
- 0,
2514
- 0,
2515
- 0,
2516
- 2
2517
- ],
2518
- align: "right"
2519
- });
2520
- else ui.div();
2521
- });
2522
- ui.div();
2523
- });
2524
- if (examples.length) {
2525
- ui.div(__("Examples:"));
2526
- examples.forEach((example) => {
2527
- example[0] = example[0].replace(/\$0/g, base$0);
2528
- });
2529
- examples.forEach((example) => {
2530
- if (example[1] === "") ui.div({
2531
- text: example[0],
2532
- padding: [
2533
- 0,
2534
- 2,
2535
- 0,
2536
- 2
2537
- ]
2538
- });
2539
- else ui.div({
2540
- text: example[0],
2541
- padding: [
2542
- 0,
2543
- 2,
2544
- 0,
2545
- 2
2546
- ],
2547
- width: maxWidth(examples, theWrap) + 4
2548
- }, { text: example[1] });
2549
- });
2550
- ui.div();
2551
- }
2552
- if (epilogs.length > 0) {
2553
- const e = epilogs.map((epilog) => epilog.replace(/\$0/g, base$0)).join("\n");
2554
- ui.div(`${e}\n`);
2555
- }
2556
- return ui.toString().replace(/\s*$/, "");
2557
- };
2558
- function maxWidth(table, theWrap, modifier) {
2559
- let width = 0;
2560
- if (!Array.isArray(table)) table = Object.values(table).map((v) => [v]);
2561
- table.forEach((v) => {
2562
- width = Math.max(shim.stringWidth(modifier ? `${modifier} ${getText(v[0])}` : getText(v[0])) + getIndentation(v[0]), width);
2563
- });
2564
- if (theWrap) width = Math.min(width, parseInt((theWrap * .5).toString(), 10));
2565
- return width;
2566
- }
2567
- function normalizeAliases() {
2568
- const demandedOptions = yargs.getDemandedOptions();
2569
- const options = yargs.getOptions();
2570
- (Object.keys(options.alias) || []).forEach((key) => {
2571
- options.alias[key].forEach((alias) => {
2572
- if (descriptions[alias]) self.describe(key, descriptions[alias]);
2573
- if (alias in demandedOptions) yargs.demandOption(key, demandedOptions[alias]);
2574
- if (options.boolean.includes(alias)) yargs.boolean(key);
2575
- if (options.count.includes(alias)) yargs.count(key);
2576
- if (options.string.includes(alias)) yargs.string(key);
2577
- if (options.normalize.includes(alias)) yargs.normalize(key);
2578
- if (options.array.includes(alias)) yargs.array(key);
2579
- if (options.number.includes(alias)) yargs.number(key);
2580
- });
2581
- });
2582
- }
2583
- let cachedHelpMessage;
2584
- self.cacheHelpMessage = function() {
2585
- cachedHelpMessage = this.help();
2586
- };
2587
- self.clearCachedHelpMessage = function() {
2588
- cachedHelpMessage = void 0;
2589
- };
2590
- self.hasCachedHelpMessage = function() {
2591
- return !!cachedHelpMessage;
2592
- };
2593
- function addUngroupedKeys(keys, aliases, groups, defaultGroup) {
2594
- let groupedKeys = [];
2595
- let toCheck = null;
2596
- Object.keys(groups).forEach((group) => {
2597
- groupedKeys = groupedKeys.concat(groups[group]);
2598
- });
2599
- keys.forEach((key) => {
2600
- toCheck = [key].concat(aliases[key]);
2601
- if (!toCheck.some((k) => groupedKeys.indexOf(k) !== -1)) groups[defaultGroup].push(key);
2602
- });
2603
- return groupedKeys;
2604
- }
2605
- function filterHiddenOptions(key) {
2606
- return yargs.getOptions().hiddenOptions.indexOf(key) < 0 || yargs.parsed.argv[yargs.getOptions().showHiddenOpt];
2607
- }
2608
- self.showHelp = (level) => {
2609
- const logger = yargs.getInternalMethods().getLoggerInstance();
2610
- if (!level) level = "error";
2611
- (typeof level === "function" ? level : logger[level])(self.help());
2612
- };
2613
- self.functionDescription = (fn) => {
2614
- return [
2615
- "(",
2616
- fn.name ? shim.Parser.decamelize(fn.name, "-") : __("generated-value"),
2617
- ")"
2618
- ].join("");
2619
- };
2620
- self.stringifiedValues = function stringifiedValues(values, separator) {
2621
- let string = "";
2622
- const sep = separator || ", ";
2623
- const array = [].concat(values);
2624
- if (!values || !array.length) return string;
2625
- array.forEach((value) => {
2626
- if (string.length) string += sep;
2627
- string += JSON.stringify(value);
2628
- });
2629
- return string;
2630
- };
2631
- function defaultString(value, defaultDescription) {
2632
- let string = `[${__("default:")} `;
2633
- if (value === void 0 && !defaultDescription) return null;
2634
- if (defaultDescription) string += defaultDescription;
2635
- else switch (typeof value) {
2636
- case "string":
2637
- string += `"${value}"`;
2638
- break;
2639
- case "object":
2640
- string += JSON.stringify(value);
2641
- break;
2642
- default: string += value;
2643
- }
2644
- return `${string}]`;
2645
- }
2646
- function windowWidth() {
2647
- const maxWidth = 80;
2648
- if (shim.process.stdColumns) return Math.min(maxWidth, shim.process.stdColumns);
2649
- else return maxWidth;
2650
- }
2651
- let version = null;
2652
- self.version = (ver) => {
2653
- version = ver;
2654
- };
2655
- self.showVersion = (level) => {
2656
- const logger = yargs.getInternalMethods().getLoggerInstance();
2657
- if (!level) level = "error";
2658
- (typeof level === "function" ? level : logger[level])(version);
2659
- };
2660
- self.reset = function reset(localLookup) {
2661
- failMessage = null;
2662
- failureOutput = false;
2663
- usages = [];
2664
- usageDisabled = false;
2665
- epilogs = [];
2666
- examples = [];
2667
- commands = [];
2668
- descriptions = objFilter(descriptions, (k) => !localLookup[k]);
2669
- return self;
2670
- };
2671
- const frozens = [];
2672
- self.freeze = function freeze() {
2673
- frozens.push({
2674
- failMessage,
2675
- failureOutput,
2676
- usages,
2677
- usageDisabled,
2678
- epilogs,
2679
- examples,
2680
- commands,
2681
- descriptions
2682
- });
2683
- };
2684
- self.unfreeze = function unfreeze(defaultCommand = false) {
2685
- const frozen = frozens.pop();
2686
- if (!frozen) return;
2687
- if (defaultCommand) {
2688
- descriptions = {
2689
- ...frozen.descriptions,
2690
- ...descriptions
2691
- };
2692
- commands = [...frozen.commands, ...commands];
2693
- usages = [...frozen.usages, ...usages];
2694
- examples = [...frozen.examples, ...examples];
2695
- epilogs = [...frozen.epilogs, ...epilogs];
2696
- } else ({failMessage, failureOutput, usages, usageDisabled, epilogs, examples, commands, descriptions} = frozen);
2697
- };
2698
- return self;
2699
- }
2700
- function isIndentedText(text) {
2701
- return typeof text === "object";
2702
- }
2703
- function addIndentation(text, indent) {
2704
- return isIndentedText(text) ? {
2705
- text: text.text,
2706
- indentation: text.indentation + indent
2707
- } : {
2708
- text,
2709
- indentation: indent
2710
- };
2711
- }
2712
- function getIndentation(text) {
2713
- return isIndentedText(text) ? text.indentation : 0;
2714
- }
2715
- function getText(text) {
2716
- return isIndentedText(text) ? text.text : text;
2717
- }
2718
-
2719
- //#endregion
2720
- //#region node_modules/yargs/build/lib/completion-templates.js
2721
- const completionShTemplate = `###-begin-{{app_name}}-completions-###
2722
- #
2723
- # yargs command completion script
2724
- #
2725
- # Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
2726
- # or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
2727
- #
2728
- _{{app_name}}_yargs_completions()
2729
- {
2730
- local cur_word args type_list
2731
-
2732
- cur_word="\${COMP_WORDS[COMP_CWORD]}"
2733
- args=("\${COMP_WORDS[@]}")
2734
-
2735
- # ask yargs to generate completions.
2736
- # see https://stackoverflow.com/a/40944195/7080036 for the spaces-handling awk
2737
- mapfile -t type_list < <({{app_path}} --get-yargs-completions "\${args[@]}")
2738
- mapfile -t COMPREPLY < <(compgen -W "$( printf '%q ' "\${type_list[@]}" )" -- "\${cur_word}" |
2739
- awk '/ / { print "\\""$0"\\"" } /^[^ ]+$/ { print $0 }')
2740
-
2741
- # if no match was found, fall back to filename completion
2742
- if [ \${#COMPREPLY[@]} -eq 0 ]; then
2743
- COMPREPLY=()
2744
- fi
2745
-
2746
- return 0
2747
- }
2748
- complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
2749
- ###-end-{{app_name}}-completions-###
2750
- `;
2751
- const completionZshTemplate = `#compdef {{app_name}}
2752
- ###-begin-{{app_name}}-completions-###
2753
- #
2754
- # yargs command completion script
2755
- #
2756
- # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
2757
- # or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
2758
- #
2759
- _{{app_name}}_yargs_completions()
2760
- {
2761
- local reply
2762
- local si=$IFS
2763
- IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
2764
- IFS=$si
2765
- if [[ \${#reply} -gt 0 ]]; then
2766
- _describe 'values' reply
2767
- else
2768
- _default
2769
- fi
2770
- }
2771
- if [[ "'\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
2772
- _{{app_name}}_yargs_completions "$@"
2773
- else
2774
- compdef _{{app_name}}_yargs_completions {{app_name}}
2775
- fi
2776
- ###-end-{{app_name}}-completions-###
2777
- `;
2778
-
2779
- //#endregion
2780
- //#region node_modules/yargs/build/lib/completion.js
2781
- var Completion = class {
2782
- constructor(yargs, usage, command, shim) {
2783
- var _a, _b, _c;
2784
- this.yargs = yargs;
2785
- this.usage = usage;
2786
- this.command = command;
2787
- this.shim = shim;
2788
- this.completionKey = "get-yargs-completions";
2789
- this.aliases = null;
2790
- this.customCompletionFunction = null;
2791
- this.indexAfterLastReset = 0;
2792
- this.zshShell = (_c = ((_a = this.shim.getEnv("SHELL")) === null || _a === void 0 ? void 0 : _a.includes("zsh")) || ((_b = this.shim.getEnv("ZSH_NAME")) === null || _b === void 0 ? void 0 : _b.includes("zsh"))) !== null && _c !== void 0 ? _c : false;
2793
- }
2794
- defaultCompletion(args, argv, current, done) {
2795
- const handlers = this.command.getCommandHandlers();
2796
- for (let i = 0, ii = args.length; i < ii; ++i) if (handlers[args[i]] && handlers[args[i]].builder) {
2797
- const builder = handlers[args[i]].builder;
2798
- if (isCommandBuilderCallback(builder)) {
2799
- this.indexAfterLastReset = i + 1;
2800
- const y = this.yargs.getInternalMethods().reset();
2801
- builder(y, true);
2802
- return y.argv;
2803
- }
2804
- }
2805
- const completions = [];
2806
- this.commandCompletions(completions, args, current);
2807
- this.optionCompletions(completions, args, argv, current);
2808
- this.choicesFromOptionsCompletions(completions, args, argv, current);
2809
- this.choicesFromPositionalsCompletions(completions, args, argv, current);
2810
- done(null, completions);
2811
- }
2812
- commandCompletions(completions, args, current) {
2813
- const parentCommands = this.yargs.getInternalMethods().getContext().commands;
2814
- if (!current.match(/^-/) && parentCommands[parentCommands.length - 1] !== current && !this.previousArgHasChoices(args)) this.usage.getCommands().forEach((usageCommand) => {
2815
- const commandName = parseCommand(usageCommand[0]).cmd;
2816
- if (args.indexOf(commandName) === -1) if (!this.zshShell) completions.push(commandName);
2817
- else {
2818
- const desc = usageCommand[1] || "";
2819
- completions.push(commandName.replace(/:/g, "\\:") + ":" + desc);
2820
- }
2821
- });
2822
- }
2823
- optionCompletions(completions, args, argv, current) {
2824
- if ((current.match(/^-/) || current === "" && completions.length === 0) && !this.previousArgHasChoices(args)) {
2825
- const options = this.yargs.getOptions();
2826
- const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
2827
- Object.keys(options.key).forEach((key) => {
2828
- const negable = !!options.configuration["boolean-negation"] && options.boolean.includes(key);
2829
- if (!positionalKeys.includes(key) && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, key, negable)) this.completeOptionKey(key, completions, current, negable && !!options.default[key]);
2830
- });
2831
- }
2832
- }
2833
- choicesFromOptionsCompletions(completions, args, argv, current) {
2834
- if (this.previousArgHasChoices(args)) {
2835
- const choices = this.getPreviousArgChoices(args);
2836
- if (choices && choices.length > 0) completions.push(...choices.map((c) => c.replace(/:/g, "\\:")));
2837
- }
2838
- }
2839
- choicesFromPositionalsCompletions(completions, args, argv, current) {
2840
- if (current === "" && completions.length > 0 && this.previousArgHasChoices(args)) return;
2841
- const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
2842
- const offset = Math.max(this.indexAfterLastReset, this.yargs.getInternalMethods().getContext().commands.length + 1);
2843
- const positionalKey = positionalKeys[argv._.length - offset - 1];
2844
- if (!positionalKey) return;
2845
- const choices = this.yargs.getOptions().choices[positionalKey] || [];
2846
- for (const choice of choices) if (choice.startsWith(current)) completions.push(choice.replace(/:/g, "\\:"));
2847
- }
2848
- getPreviousArgChoices(args) {
2849
- if (args.length < 1) return;
2850
- let previousArg = args[args.length - 1];
2851
- let filter = "";
2852
- if (!previousArg.startsWith("-") && args.length > 1) {
2853
- filter = previousArg;
2854
- previousArg = args[args.length - 2];
2855
- }
2856
- if (!previousArg.startsWith("-")) return;
2857
- const previousArgKey = previousArg.replace(/^-+/, "");
2858
- const options = this.yargs.getOptions();
2859
- const possibleAliases = [previousArgKey, ...this.yargs.getAliases()[previousArgKey] || []];
2860
- let choices;
2861
- for (const possibleAlias of possibleAliases) if (Object.prototype.hasOwnProperty.call(options.key, possibleAlias) && Array.isArray(options.choices[possibleAlias])) {
2862
- choices = options.choices[possibleAlias];
2863
- break;
2864
- }
2865
- if (choices) return choices.filter((choice) => !filter || choice.startsWith(filter));
2866
- }
2867
- previousArgHasChoices(args) {
2868
- const choices = this.getPreviousArgChoices(args);
2869
- return choices !== void 0 && choices.length > 0;
2870
- }
2871
- argsContainKey(args, key, negable) {
2872
- const argsContains = (s) => args.indexOf((/^[^0-9]$/.test(s) ? "-" : "--") + s) !== -1;
2873
- if (argsContains(key)) return true;
2874
- if (negable && argsContains(`no-${key}`)) return true;
2875
- if (this.aliases) {
2876
- for (const alias of this.aliases[key]) if (argsContains(alias)) return true;
2877
- }
2878
- return false;
2879
- }
2880
- completeOptionKey(key, completions, current, negable) {
2881
- var _a, _b, _c, _d;
2882
- let keyWithDesc = key;
2883
- if (this.zshShell) {
2884
- const descs = this.usage.getDescriptions();
2885
- const aliasKey = (_b = (_a = this === null || this === void 0 ? void 0 : this.aliases) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.find((alias) => {
2886
- const desc = descs[alias];
2887
- return typeof desc === "string" && desc.length > 0;
2888
- });
2889
- const descFromAlias = aliasKey ? descs[aliasKey] : void 0;
2890
- const desc = (_d = (_c = descs[key]) !== null && _c !== void 0 ? _c : descFromAlias) !== null && _d !== void 0 ? _d : "";
2891
- keyWithDesc = `${key.replace(/:/g, "\\:")}:${desc.replace("__yargsString__:", "").replace(/(\r\n|\n|\r)/gm, " ")}`;
2892
- }
2893
- const startsByTwoDashes = (s) => /^--/.test(s);
2894
- const isShortOption = (s) => /^[^0-9]$/.test(s);
2895
- const dashes = !startsByTwoDashes(current) && isShortOption(key) ? "-" : "--";
2896
- completions.push(dashes + keyWithDesc);
2897
- if (negable) completions.push(dashes + "no-" + keyWithDesc);
2898
- }
2899
- customCompletion(args, argv, current, done) {
2900
- assertNotStrictEqual(this.customCompletionFunction, null, this.shim);
2901
- if (isSyncCompletionFunction(this.customCompletionFunction)) {
2902
- const result = this.customCompletionFunction(current, argv);
2903
- if (isPromise(result)) return result.then((list) => {
2904
- this.shim.process.nextTick(() => {
2905
- done(null, list);
2906
- });
2907
- }).catch((err) => {
2908
- this.shim.process.nextTick(() => {
2909
- done(err, void 0);
2910
- });
2911
- });
2912
- return done(null, result);
2913
- } else if (isFallbackCompletionFunction(this.customCompletionFunction)) return this.customCompletionFunction(current, argv, (onCompleted = done) => this.defaultCompletion(args, argv, current, onCompleted), (completions) => {
2914
- done(null, completions);
2915
- });
2916
- else return this.customCompletionFunction(current, argv, (completions) => {
2917
- done(null, completions);
2918
- });
2919
- }
2920
- getCompletion(args, done) {
2921
- const current = args.length ? args[args.length - 1] : "";
2922
- const argv = this.yargs.parse(args, true);
2923
- const completionFunction = this.customCompletionFunction ? (argv) => this.customCompletion(args, argv, current, done) : (argv) => this.defaultCompletion(args, argv, current, done);
2924
- return isPromise(argv) ? argv.then(completionFunction) : completionFunction(argv);
2925
- }
2926
- generateCompletionScript($0, cmd) {
2927
- let script = this.zshShell ? completionZshTemplate : completionShTemplate;
2928
- const name = this.shim.path.basename($0);
2929
- if ($0.match(/\.js$/)) $0 = `./${$0}`;
2930
- script = script.replace(/{{app_name}}/g, name);
2931
- script = script.replace(/{{completion_command}}/g, cmd);
2932
- return script.replace(/{{app_path}}/g, $0);
2933
- }
2934
- registerFunction(fn) {
2935
- this.customCompletionFunction = fn;
2936
- }
2937
- setParsed(parsed) {
2938
- this.aliases = parsed.aliases;
2939
- }
2940
- };
2941
- function completion(yargs, usage, command, shim) {
2942
- return new Completion(yargs, usage, command, shim);
2943
- }
2944
- function isSyncCompletionFunction(completionFunction) {
2945
- return completionFunction.length < 3;
2946
- }
2947
- function isFallbackCompletionFunction(completionFunction) {
2948
- return completionFunction.length > 3;
2949
- }
2950
-
2951
- //#endregion
2952
- //#region node_modules/yargs/build/lib/utils/levenshtein.js
2953
- function levenshtein(a, b) {
2954
- if (a.length === 0) return b.length;
2955
- if (b.length === 0) return a.length;
2956
- const matrix = [];
2957
- let i;
2958
- for (i = 0; i <= b.length; i++) matrix[i] = [i];
2959
- let j;
2960
- for (j = 0; j <= a.length; j++) matrix[0][j] = j;
2961
- for (i = 1; i <= b.length; i++) for (j = 1; j <= a.length; j++) if (b.charAt(i - 1) === a.charAt(j - 1)) matrix[i][j] = matrix[i - 1][j - 1];
2962
- else if (i > 1 && j > 1 && b.charAt(i - 2) === a.charAt(j - 1) && b.charAt(i - 1) === a.charAt(j - 2)) matrix[i][j] = matrix[i - 2][j - 2] + 1;
2963
- else matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
2964
- return matrix[b.length][a.length];
2965
- }
2966
-
2967
- //#endregion
2968
- //#region node_modules/yargs/build/lib/validation.js
2969
- const specialKeys = [
2970
- "$0",
2971
- "--",
2972
- "_"
2973
- ];
2974
- function validation(yargs, usage, shim) {
2975
- const __ = shim.y18n.__;
2976
- const __n = shim.y18n.__n;
2977
- const self = {};
2978
- self.nonOptionCount = function nonOptionCount(argv) {
2979
- const demandedCommands = yargs.getDemandedCommands();
2980
- const _s = argv._.length + (argv["--"] ? argv["--"].length : 0) - yargs.getInternalMethods().getContext().commands.length;
2981
- if (demandedCommands._ && (_s < demandedCommands._.min || _s > demandedCommands._.max)) {
2982
- if (_s < demandedCommands._.min) if (demandedCommands._.minMsg !== void 0) usage.fail(demandedCommands._.minMsg ? demandedCommands._.minMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.min.toString()) : null);
2983
- else usage.fail(__n("Not enough non-option arguments: got %s, need at least %s", "Not enough non-option arguments: got %s, need at least %s", _s, _s.toString(), demandedCommands._.min.toString()));
2984
- else if (_s > demandedCommands._.max) if (demandedCommands._.maxMsg !== void 0) usage.fail(demandedCommands._.maxMsg ? demandedCommands._.maxMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.max.toString()) : null);
2985
- else usage.fail(__n("Too many non-option arguments: got %s, maximum of %s", "Too many non-option arguments: got %s, maximum of %s", _s, _s.toString(), demandedCommands._.max.toString()));
2986
- }
2987
- };
2988
- self.positionalCount = function positionalCount(required, observed) {
2989
- if (observed < required) usage.fail(__n("Not enough non-option arguments: got %s, need at least %s", "Not enough non-option arguments: got %s, need at least %s", observed, observed + "", required + ""));
2990
- };
2991
- self.requiredArguments = function requiredArguments(argv, demandedOptions) {
2992
- let missing = null;
2993
- for (const key of Object.keys(demandedOptions)) if (!Object.prototype.hasOwnProperty.call(argv, key) || typeof argv[key] === "undefined") {
2994
- missing = missing || {};
2995
- missing[key] = demandedOptions[key];
2996
- }
2997
- if (missing) {
2998
- const customMsgs = [];
2999
- for (const key of Object.keys(missing)) {
3000
- const msg = missing[key];
3001
- if (msg && customMsgs.indexOf(msg) < 0) customMsgs.push(msg);
3002
- }
3003
- const customMsg = customMsgs.length ? `\n${customMsgs.join("\n")}` : "";
3004
- usage.fail(__n("Missing required argument: %s", "Missing required arguments: %s", Object.keys(missing).length, Object.keys(missing).join(", ") + customMsg));
3005
- }
3006
- };
3007
- self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
3008
- var _a;
3009
- const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
3010
- const unknown = [];
3011
- const currentContext = yargs.getInternalMethods().getContext();
3012
- Object.keys(argv).forEach((key) => {
3013
- if (!specialKeys.includes(key) && !Object.prototype.hasOwnProperty.call(positionalMap, key) && !Object.prototype.hasOwnProperty.call(yargs.getInternalMethods().getParseContext(), key) && !self.isValidAndSomeAliasIsNotNew(key, aliases)) unknown.push(key);
3014
- });
3015
- if (checkPositionals && (currentContext.commands.length > 0 || commandKeys.length > 0 || isDefaultCommand)) argv._.slice(currentContext.commands.length).forEach((key) => {
3016
- if (!commandKeys.includes("" + key)) unknown.push("" + key);
3017
- });
3018
- if (checkPositionals) {
3019
- const maxNonOptDemanded = ((_a = yargs.getDemandedCommands()._) === null || _a === void 0 ? void 0 : _a.max) || 0;
3020
- const expected = currentContext.commands.length + maxNonOptDemanded;
3021
- if (expected < argv._.length) argv._.slice(expected).forEach((key) => {
3022
- key = String(key);
3023
- if (!currentContext.commands.includes(key) && !unknown.includes(key)) unknown.push(key);
3024
- });
3025
- }
3026
- if (unknown.length) usage.fail(__n("Unknown argument: %s", "Unknown arguments: %s", unknown.length, unknown.map((s) => s.trim() ? s : `"${s}"`).join(", ")));
3027
- };
3028
- self.unknownCommands = function unknownCommands(argv) {
3029
- const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
3030
- const unknown = [];
3031
- const currentContext = yargs.getInternalMethods().getContext();
3032
- if (currentContext.commands.length > 0 || commandKeys.length > 0) argv._.slice(currentContext.commands.length).forEach((key) => {
3033
- if (!commandKeys.includes("" + key)) unknown.push("" + key);
3034
- });
3035
- if (unknown.length > 0) {
3036
- usage.fail(__n("Unknown command: %s", "Unknown commands: %s", unknown.length, unknown.join(", ")));
3037
- return true;
3038
- } else return false;
3039
- };
3040
- self.isValidAndSomeAliasIsNotNew = function isValidAndSomeAliasIsNotNew(key, aliases) {
3041
- if (!Object.prototype.hasOwnProperty.call(aliases, key)) return false;
3042
- const newAliases = yargs.parsed.newAliases;
3043
- return [key, ...aliases[key]].some((a) => !Object.prototype.hasOwnProperty.call(newAliases, a) || !newAliases[key]);
3044
- };
3045
- self.limitedChoices = function limitedChoices(argv) {
3046
- const options = yargs.getOptions();
3047
- const invalid = {};
3048
- if (!Object.keys(options.choices).length) return;
3049
- Object.keys(argv).forEach((key) => {
3050
- if (specialKeys.indexOf(key) === -1 && Object.prototype.hasOwnProperty.call(options.choices, key)) [].concat(argv[key]).forEach((value) => {
3051
- if (options.choices[key].indexOf(value) === -1 && value !== void 0) invalid[key] = (invalid[key] || []).concat(value);
3052
- });
3053
- });
3054
- const invalidKeys = Object.keys(invalid);
3055
- if (!invalidKeys.length) return;
3056
- let msg = __("Invalid values:");
3057
- invalidKeys.forEach((key) => {
3058
- msg += `\n ${__("Argument: %s, Given: %s, Choices: %s", key, usage.stringifiedValues(invalid[key]), usage.stringifiedValues(options.choices[key]))}`;
3059
- });
3060
- usage.fail(msg);
3061
- };
3062
- let implied = {};
3063
- self.implies = function implies(key, value) {
3064
- argsert("<string|object> [array|number|string]", [key, value], arguments.length);
3065
- if (typeof key === "object") Object.keys(key).forEach((k) => {
3066
- self.implies(k, key[k]);
3067
- });
3068
- else {
3069
- yargs.global(key);
3070
- if (!implied[key]) implied[key] = [];
3071
- if (Array.isArray(value)) value.forEach((i) => self.implies(key, i));
3072
- else {
3073
- assertNotStrictEqual(value, void 0, shim);
3074
- implied[key].push(value);
3075
- }
3076
- }
3077
- };
3078
- self.getImplied = function getImplied() {
3079
- return implied;
3080
- };
3081
- function keyExists(argv, val) {
3082
- const num = Number(val);
3083
- val = isNaN(num) ? val : num;
3084
- if (typeof val === "number") val = argv._.length >= val;
3085
- else if (val.match(/^--no-.+/)) {
3086
- val = val.match(/^--no-(.+)/)[1];
3087
- val = !Object.prototype.hasOwnProperty.call(argv, val);
3088
- } else val = Object.prototype.hasOwnProperty.call(argv, val);
3089
- return val;
3090
- }
3091
- self.implications = function implications(argv) {
3092
- const implyFail = [];
3093
- Object.keys(implied).forEach((key) => {
3094
- const origKey = key;
3095
- (implied[key] || []).forEach((value) => {
3096
- let key = origKey;
3097
- const origValue = value;
3098
- key = keyExists(argv, key);
3099
- value = keyExists(argv, value);
3100
- if (key && !value) implyFail.push(` ${origKey} -> ${origValue}`);
3101
- });
3102
- });
3103
- if (implyFail.length) {
3104
- let msg = `${__("Implications failed:")}\n`;
3105
- implyFail.forEach((value) => {
3106
- msg += value;
3107
- });
3108
- usage.fail(msg);
3109
- }
3110
- };
3111
- let conflicting = {};
3112
- self.conflicts = function conflicts(key, value) {
3113
- argsert("<string|object> [array|string]", [key, value], arguments.length);
3114
- if (typeof key === "object") Object.keys(key).forEach((k) => {
3115
- self.conflicts(k, key[k]);
3116
- });
3117
- else {
3118
- yargs.global(key);
3119
- if (!conflicting[key]) conflicting[key] = [];
3120
- if (Array.isArray(value)) value.forEach((i) => self.conflicts(key, i));
3121
- else conflicting[key].push(value);
3122
- }
3123
- };
3124
- self.getConflicting = () => conflicting;
3125
- self.conflicting = function conflictingFn(argv) {
3126
- Object.keys(argv).forEach((key) => {
3127
- if (conflicting[key]) conflicting[key].forEach((value) => {
3128
- if (value && argv[key] !== void 0 && argv[value] !== void 0) usage.fail(__("Arguments %s and %s are mutually exclusive", key, value));
3129
- });
3130
- });
3131
- if (yargs.getInternalMethods().getParserConfiguration()["strip-dashed"]) Object.keys(conflicting).forEach((key) => {
3132
- conflicting[key].forEach((value) => {
3133
- if (value && argv[shim.Parser.camelCase(key)] !== void 0 && argv[shim.Parser.camelCase(value)] !== void 0) usage.fail(__("Arguments %s and %s are mutually exclusive", key, value));
3134
- });
3135
- });
3136
- };
3137
- self.recommendCommands = function recommendCommands(cmd, potentialCommands) {
3138
- const threshold = 3;
3139
- potentialCommands = potentialCommands.sort((a, b) => b.length - a.length);
3140
- let recommended = null;
3141
- let bestDistance = Infinity;
3142
- for (let i = 0, candidate; (candidate = potentialCommands[i]) !== void 0; i++) {
3143
- const d = levenshtein(cmd, candidate);
3144
- if (d <= threshold && d < bestDistance) {
3145
- bestDistance = d;
3146
- recommended = candidate;
3147
- }
3148
- }
3149
- if (recommended) usage.fail(__("Did you mean %s?", recommended));
3150
- };
3151
- self.reset = function reset(localLookup) {
3152
- implied = objFilter(implied, (k) => !localLookup[k]);
3153
- conflicting = objFilter(conflicting, (k) => !localLookup[k]);
3154
- return self;
3155
- };
3156
- const frozens = [];
3157
- self.freeze = function freeze() {
3158
- frozens.push({
3159
- implied,
3160
- conflicting
3161
- });
3162
- };
3163
- self.unfreeze = function unfreeze() {
3164
- const frozen = frozens.pop();
3165
- assertNotStrictEqual(frozen, void 0, shim);
3166
- ({implied, conflicting} = frozen);
3167
- };
3168
- return self;
3169
- }
3170
-
3171
- //#endregion
3172
- //#region node_modules/yargs/build/lib/utils/apply-extends.js
3173
- let previouslyVisitedConfigs = [];
3174
- let shim;
3175
- function applyExtends(config, cwd, mergeExtends, _shim) {
3176
- shim = _shim;
3177
- let defaultConfig = {};
3178
- if (Object.prototype.hasOwnProperty.call(config, "extends")) {
3179
- if (typeof config.extends !== "string") return defaultConfig;
3180
- const isPath = /\.json|\..*rc$/.test(config.extends);
3181
- let pathToDefault = null;
3182
- if (!isPath) try {
3183
- pathToDefault = import.meta.resolve(config.extends);
3184
- } catch (_err) {
3185
- return config;
3186
- }
3187
- else pathToDefault = getPathToDefaultConfig(cwd, config.extends);
3188
- checkForCircularExtends(pathToDefault);
3189
- previouslyVisitedConfigs.push(pathToDefault);
3190
- defaultConfig = isPath ? JSON.parse(shim.readFileSync(pathToDefault, "utf8")) : _shim.require(config.extends);
3191
- delete config.extends;
3192
- defaultConfig = applyExtends(defaultConfig, shim.path.dirname(pathToDefault), mergeExtends, shim);
3193
- }
3194
- previouslyVisitedConfigs = [];
3195
- return mergeExtends ? mergeDeep(defaultConfig, config) : Object.assign({}, defaultConfig, config);
3196
- }
3197
- function checkForCircularExtends(cfgPath) {
3198
- if (previouslyVisitedConfigs.indexOf(cfgPath) > -1) throw new YError(`Circular extended configurations: '${cfgPath}'.`);
3199
- }
3200
- function getPathToDefaultConfig(cwd, pathToExtend) {
3201
- return shim.path.resolve(cwd, pathToExtend);
3202
- }
3203
- function mergeDeep(config1, config2) {
3204
- const target = {};
3205
- function isObject(obj) {
3206
- return obj && typeof obj === "object" && !Array.isArray(obj);
3207
- }
3208
- Object.assign(target, config1);
3209
- for (const key of Object.keys(config2)) if (isObject(config2[key]) && isObject(target[key])) target[key] = mergeDeep(config1[key], config2[key]);
3210
- else target[key] = config2[key];
3211
- return target;
3212
- }
3213
-
3214
- //#endregion
3215
- //#region node_modules/yargs/build/lib/yargs-factory.js
3216
- var __classPrivateFieldSet = void 0 && (void 0).__classPrivateFieldSet || function(receiver, state, value, kind, f) {
3217
- if (kind === "m") throw new TypeError("Private method is not writable");
3218
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3219
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3220
- return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3221
- };
3222
- var __classPrivateFieldGet = void 0 && (void 0).__classPrivateFieldGet || function(receiver, state, kind, f) {
3223
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3224
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3225
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3226
- };
3227
- var _YargsInstance_command, _YargsInstance_cwd, _YargsInstance_context, _YargsInstance_completion, _YargsInstance_completionCommand, _YargsInstance_defaultShowHiddenOpt, _YargsInstance_exitError, _YargsInstance_detectLocale, _YargsInstance_emittedWarnings, _YargsInstance_exitProcess, _YargsInstance_frozens, _YargsInstance_globalMiddleware, _YargsInstance_groups, _YargsInstance_hasOutput, _YargsInstance_helpOpt, _YargsInstance_isGlobalContext, _YargsInstance_logger, _YargsInstance_output, _YargsInstance_options, _YargsInstance_parentRequire, _YargsInstance_parserConfig, _YargsInstance_parseFn, _YargsInstance_parseContext, _YargsInstance_pkgs, _YargsInstance_preservedGroups, _YargsInstance_processArgs, _YargsInstance_recommendCommands, _YargsInstance_shim, _YargsInstance_strict, _YargsInstance_strictCommands, _YargsInstance_strictOptions, _YargsInstance_usage, _YargsInstance_usageConfig, _YargsInstance_versionOpt, _YargsInstance_validation;
3228
- function YargsFactory(_shim) {
3229
- return (processArgs = [], cwd = _shim.process.cwd(), parentRequire) => {
3230
- const yargs = new YargsInstance(processArgs, cwd, parentRequire, _shim);
3231
- Object.defineProperty(yargs, "argv", {
3232
- get: () => {
3233
- return yargs.parse();
3234
- },
3235
- enumerable: true
3236
- });
3237
- yargs.help();
3238
- yargs.version();
3239
- return yargs;
3240
- };
3241
- }
3242
- const kCopyDoubleDash = Symbol("copyDoubleDash");
3243
- const kCreateLogger = Symbol("copyDoubleDash");
3244
- const kDeleteFromParserHintObject = Symbol("deleteFromParserHintObject");
3245
- const kEmitWarning = Symbol("emitWarning");
3246
- const kFreeze = Symbol("freeze");
3247
- const kGetDollarZero = Symbol("getDollarZero");
3248
- const kGetParserConfiguration = Symbol("getParserConfiguration");
3249
- const kGetUsageConfiguration = Symbol("getUsageConfiguration");
3250
- const kGuessLocale = Symbol("guessLocale");
3251
- const kGuessVersion = Symbol("guessVersion");
3252
- const kParsePositionalNumbers = Symbol("parsePositionalNumbers");
3253
- const kPkgUp = Symbol("pkgUp");
3254
- const kPopulateParserHintArray = Symbol("populateParserHintArray");
3255
- const kPopulateParserHintSingleValueDictionary = Symbol("populateParserHintSingleValueDictionary");
3256
- const kPopulateParserHintArrayDictionary = Symbol("populateParserHintArrayDictionary");
3257
- const kPopulateParserHintDictionary = Symbol("populateParserHintDictionary");
3258
- const kSanitizeKey = Symbol("sanitizeKey");
3259
- const kSetKey = Symbol("setKey");
3260
- const kUnfreeze = Symbol("unfreeze");
3261
- const kValidateAsync = Symbol("validateAsync");
3262
- const kGetCommandInstance = Symbol("getCommandInstance");
3263
- const kGetContext = Symbol("getContext");
3264
- const kGetHasOutput = Symbol("getHasOutput");
3265
- const kGetLoggerInstance = Symbol("getLoggerInstance");
3266
- const kGetParseContext = Symbol("getParseContext");
3267
- const kGetUsageInstance = Symbol("getUsageInstance");
3268
- const kGetValidationInstance = Symbol("getValidationInstance");
3269
- const kHasParseCallback = Symbol("hasParseCallback");
3270
- const kIsGlobalContext = Symbol("isGlobalContext");
3271
- const kPostProcess = Symbol("postProcess");
3272
- const kRebase = Symbol("rebase");
3273
- const kReset = Symbol("reset");
3274
- const kRunYargsParserAndExecuteCommands = Symbol("runYargsParserAndExecuteCommands");
3275
- const kRunValidation = Symbol("runValidation");
3276
- const kSetHasOutput = Symbol("setHasOutput");
3277
- const kTrackManuallySetKeys = Symbol("kTrackManuallySetKeys");
3278
- const DEFAULT_LOCALE = "en_US";
3279
- var YargsInstance = class {
3280
- constructor(processArgs = [], cwd, parentRequire, shim) {
3281
- this.customScriptName = false;
3282
- this.parsed = false;
3283
- _YargsInstance_command.set(this, void 0);
3284
- _YargsInstance_cwd.set(this, void 0);
3285
- _YargsInstance_context.set(this, {
3286
- commands: [],
3287
- fullCommands: []
3288
- });
3289
- _YargsInstance_completion.set(this, null);
3290
- _YargsInstance_completionCommand.set(this, null);
3291
- _YargsInstance_defaultShowHiddenOpt.set(this, "show-hidden");
3292
- _YargsInstance_exitError.set(this, null);
3293
- _YargsInstance_detectLocale.set(this, true);
3294
- _YargsInstance_emittedWarnings.set(this, {});
3295
- _YargsInstance_exitProcess.set(this, true);
3296
- _YargsInstance_frozens.set(this, []);
3297
- _YargsInstance_globalMiddleware.set(this, void 0);
3298
- _YargsInstance_groups.set(this, {});
3299
- _YargsInstance_hasOutput.set(this, false);
3300
- _YargsInstance_helpOpt.set(this, null);
3301
- _YargsInstance_isGlobalContext.set(this, true);
3302
- _YargsInstance_logger.set(this, void 0);
3303
- _YargsInstance_output.set(this, "");
3304
- _YargsInstance_options.set(this, void 0);
3305
- _YargsInstance_parentRequire.set(this, void 0);
3306
- _YargsInstance_parserConfig.set(this, {});
3307
- _YargsInstance_parseFn.set(this, null);
3308
- _YargsInstance_parseContext.set(this, null);
3309
- _YargsInstance_pkgs.set(this, {});
3310
- _YargsInstance_preservedGroups.set(this, {});
3311
- _YargsInstance_processArgs.set(this, void 0);
3312
- _YargsInstance_recommendCommands.set(this, false);
3313
- _YargsInstance_shim.set(this, void 0);
3314
- _YargsInstance_strict.set(this, false);
3315
- _YargsInstance_strictCommands.set(this, false);
3316
- _YargsInstance_strictOptions.set(this, false);
3317
- _YargsInstance_usage.set(this, void 0);
3318
- _YargsInstance_usageConfig.set(this, {});
3319
- _YargsInstance_versionOpt.set(this, null);
3320
- _YargsInstance_validation.set(this, void 0);
3321
- __classPrivateFieldSet(this, _YargsInstance_shim, shim, "f");
3322
- __classPrivateFieldSet(this, _YargsInstance_processArgs, processArgs, "f");
3323
- __classPrivateFieldSet(this, _YargsInstance_cwd, cwd, "f");
3324
- __classPrivateFieldSet(this, _YargsInstance_parentRequire, parentRequire, "f");
3325
- __classPrivateFieldSet(this, _YargsInstance_globalMiddleware, new GlobalMiddleware(this), "f");
3326
- this.$0 = this[kGetDollarZero]();
3327
- this[kReset]();
3328
- __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f"), "f");
3329
- __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), "f");
3330
- __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f"), "f");
3331
- __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f"), "f");
3332
- __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
3333
- __classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger](), "f");
3334
- __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(DEFAULT_LOCALE);
3335
- }
3336
- addHelpOpt(opt, msg) {
3337
- const defaultHelpOpt = "help";
3338
- argsert("[string|boolean] [string]", [opt, msg], arguments.length);
3339
- if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
3340
- this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
3341
- __classPrivateFieldSet(this, _YargsInstance_helpOpt, null, "f");
3342
- }
3343
- if (opt === false && msg === void 0) return this;
3344
- __classPrivateFieldSet(this, _YargsInstance_helpOpt, typeof opt === "string" ? opt : defaultHelpOpt, "f");
3345
- this.boolean(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
3346
- this.describe(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"), msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show help"));
3347
- return this;
3348
- }
3349
- help(opt, msg) {
3350
- return this.addHelpOpt(opt, msg);
3351
- }
3352
- addShowHiddenOpt(opt, msg) {
3353
- argsert("[string|boolean] [string]", [opt, msg], arguments.length);
3354
- if (opt === false && msg === void 0) return this;
3355
- const showHiddenOpt = typeof opt === "string" ? opt : __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
3356
- this.boolean(showHiddenOpt);
3357
- this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show hidden options"));
3358
- __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = showHiddenOpt;
3359
- return this;
3360
- }
3361
- showHidden(opt, msg) {
3362
- return this.addShowHiddenOpt(opt, msg);
3363
- }
3364
- alias(key, value) {
3365
- argsert("<object|string|array> [string|array]", [key, value], arguments.length);
3366
- this[kPopulateParserHintArrayDictionary](this.alias.bind(this), "alias", key, value);
3367
- return this;
3368
- }
3369
- array(keys) {
3370
- argsert("<array|string>", [keys], arguments.length);
3371
- this[kPopulateParserHintArray]("array", keys);
3372
- this[kTrackManuallySetKeys](keys);
3373
- return this;
3374
- }
3375
- boolean(keys) {
3376
- argsert("<array|string>", [keys], arguments.length);
3377
- this[kPopulateParserHintArray]("boolean", keys);
3378
- this[kTrackManuallySetKeys](keys);
3379
- return this;
3380
- }
3381
- check(f, global) {
3382
- argsert("<function> [boolean]", [f, global], arguments.length);
3383
- this.middleware((argv, _yargs) => {
3384
- return maybeAsyncResult(() => {
3385
- return f(argv, _yargs.getOptions());
3386
- }, (result) => {
3387
- if (!result) __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__("Argument check failed: %s", f.toString()));
3388
- else if (typeof result === "string" || result instanceof Error) __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(result.toString(), result);
3389
- return argv;
3390
- }, (err) => {
3391
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message ? err.message : err.toString(), err);
3392
- return argv;
3393
- });
3394
- }, false, global);
3395
- return this;
3396
- }
3397
- choices(key, value) {
3398
- argsert("<object|string|array> [string|array]", [key, value], arguments.length);
3399
- this[kPopulateParserHintArrayDictionary](this.choices.bind(this), "choices", key, value);
3400
- return this;
3401
- }
3402
- coerce(keys, value) {
3403
- argsert("<object|string|array> [function]", [keys, value], arguments.length);
3404
- if (Array.isArray(keys)) {
3405
- if (!value) throw new YError("coerce callback must be provided");
3406
- for (const key of keys) this.coerce(key, value);
3407
- return this;
3408
- } else if (typeof keys === "object") {
3409
- for (const key of Object.keys(keys)) this.coerce(key, keys[key]);
3410
- return this;
3411
- }
3412
- if (!value) throw new YError("coerce callback must be provided");
3413
- const coerceKey = keys;
3414
- __classPrivateFieldGet(this, _YargsInstance_options, "f").key[coerceKey] = true;
3415
- __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
3416
- var _a;
3417
- const argvKeys = [coerceKey, ...(_a = yargs.getAliases()[coerceKey]) !== null && _a !== void 0 ? _a : []].filter((key) => Object.prototype.hasOwnProperty.call(argv, key));
3418
- if (argvKeys.length === 0) return argv;
3419
- return maybeAsyncResult(() => {
3420
- return value(argv[argvKeys[0]]);
3421
- }, (result) => {
3422
- argvKeys.forEach((key) => {
3423
- argv[key] = result;
3424
- });
3425
- return argv;
3426
- }, (err) => {
3427
- throw new YError(err.message);
3428
- });
3429
- }, coerceKey);
3430
- return this;
3431
- }
3432
- conflicts(key1, key2) {
3433
- argsert("<string|object> [string|array]", [key1, key2], arguments.length);
3434
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicts(key1, key2);
3435
- return this;
3436
- }
3437
- config(key = "config", msg, parseFn) {
3438
- argsert("[object|string] [string|function] [function]", [
3439
- key,
3440
- msg,
3441
- parseFn
3442
- ], arguments.length);
3443
- if (typeof key === "object" && !Array.isArray(key)) {
3444
- key = applyExtends(key, __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3445
- __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(key);
3446
- return this;
3447
- }
3448
- if (typeof msg === "function") {
3449
- parseFn = msg;
3450
- msg = void 0;
3451
- }
3452
- this.describe(key, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Path to JSON config file"));
3453
- (Array.isArray(key) ? key : [key]).forEach((k) => {
3454
- __classPrivateFieldGet(this, _YargsInstance_options, "f").config[k] = parseFn || true;
3455
- });
3456
- return this;
3457
- }
3458
- completion(cmd, desc, fn) {
3459
- argsert("[string] [string|boolean|function] [function]", [
3460
- cmd,
3461
- desc,
3462
- fn
3463
- ], arguments.length);
3464
- if (typeof desc === "function") {
3465
- fn = desc;
3466
- desc = void 0;
3467
- }
3468
- __classPrivateFieldSet(this, _YargsInstance_completionCommand, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion", "f");
3469
- if (!desc && desc !== false) desc = "generate completion script";
3470
- this.command(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), desc);
3471
- if (fn) __classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn);
3472
- return this;
3473
- }
3474
- command(cmd, description, builder, handler, middlewares, deprecated) {
3475
- argsert("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]", [
3476
- cmd,
3477
- description,
3478
- builder,
3479
- handler,
3480
- middlewares,
3481
- deprecated
3482
- ], arguments.length);
3483
- __classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description, builder, handler, middlewares, deprecated);
3484
- return this;
3485
- }
3486
- commands(cmd, description, builder, handler, middlewares, deprecated) {
3487
- return this.command(cmd, description, builder, handler, middlewares, deprecated);
3488
- }
3489
- commandDir(dir, opts) {
3490
- argsert("<string> [object]", [dir, opts], arguments.length);
3491
- const req = __classPrivateFieldGet(this, _YargsInstance_parentRequire, "f") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").require;
3492
- __classPrivateFieldGet(this, _YargsInstance_command, "f").addDirectory(dir, req, __classPrivateFieldGet(this, _YargsInstance_shim, "f").getCallerFile(), opts);
3493
- return this;
3494
- }
3495
- count(keys) {
3496
- argsert("<array|string>", [keys], arguments.length);
3497
- this[kPopulateParserHintArray]("count", keys);
3498
- this[kTrackManuallySetKeys](keys);
3499
- return this;
3500
- }
3501
- default(key, value, defaultDescription) {
3502
- argsert("<object|string|array> [*] [string]", [
3503
- key,
3504
- value,
3505
- defaultDescription
3506
- ], arguments.length);
3507
- if (defaultDescription) {
3508
- assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3509
- __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = defaultDescription;
3510
- }
3511
- if (typeof value === "function") {
3512
- assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3513
- if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key]) __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = __classPrivateFieldGet(this, _YargsInstance_usage, "f").functionDescription(value);
3514
- value = value.call();
3515
- }
3516
- this[kPopulateParserHintSingleValueDictionary](this.default.bind(this), "default", key, value);
3517
- return this;
3518
- }
3519
- defaults(key, value, defaultDescription) {
3520
- return this.default(key, value, defaultDescription);
3521
- }
3522
- demandCommand(min = 1, max, minMsg, maxMsg) {
3523
- argsert("[number] [number|string] [string|null|undefined] [string|null|undefined]", [
3524
- min,
3525
- max,
3526
- minMsg,
3527
- maxMsg
3528
- ], arguments.length);
3529
- if (typeof max !== "number") {
3530
- minMsg = max;
3531
- max = Infinity;
3532
- }
3533
- this.global("_", false);
3534
- __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands._ = {
3535
- min,
3536
- max,
3537
- minMsg,
3538
- maxMsg
3539
- };
3540
- return this;
3541
- }
3542
- demand(keys, max, msg) {
3543
- if (Array.isArray(max)) {
3544
- max.forEach((key) => {
3545
- assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3546
- this.demandOption(key, msg);
3547
- });
3548
- max = Infinity;
3549
- } else if (typeof max !== "number") {
3550
- msg = max;
3551
- max = Infinity;
3552
- }
3553
- if (typeof keys === "number") {
3554
- assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3555
- this.demandCommand(keys, max, msg, msg);
3556
- } else if (Array.isArray(keys)) keys.forEach((key) => {
3557
- assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3558
- this.demandOption(key, msg);
3559
- });
3560
- else if (typeof msg === "string") this.demandOption(keys, msg);
3561
- else if (msg === true || typeof msg === "undefined") this.demandOption(keys);
3562
- return this;
3563
- }
3564
- demandOption(keys, msg) {
3565
- argsert("<object|string|array> [string]", [keys, msg], arguments.length);
3566
- this[kPopulateParserHintSingleValueDictionary](this.demandOption.bind(this), "demandedOptions", keys, msg);
3567
- return this;
3568
- }
3569
- deprecateOption(option, message) {
3570
- argsert("<string> [string|boolean]", [option, message], arguments.length);
3571
- __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message;
3572
- return this;
3573
- }
3574
- describe(keys, description) {
3575
- argsert("<object|string|array> [string]", [keys, description], arguments.length);
3576
- this[kSetKey](keys, true);
3577
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description);
3578
- return this;
3579
- }
3580
- detectLocale(detect) {
3581
- argsert("<boolean>", [detect], arguments.length);
3582
- __classPrivateFieldSet(this, _YargsInstance_detectLocale, detect, "f");
3583
- return this;
3584
- }
3585
- env(prefix) {
3586
- argsert("[string|boolean]", [prefix], arguments.length);
3587
- if (prefix === false) delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
3588
- else __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix || "";
3589
- return this;
3590
- }
3591
- epilogue(msg) {
3592
- argsert("<string>", [msg], arguments.length);
3593
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").epilog(msg);
3594
- return this;
3595
- }
3596
- epilog(msg) {
3597
- return this.epilogue(msg);
3598
- }
3599
- example(cmd, description) {
3600
- argsert("<string|array> [string]", [cmd, description], arguments.length);
3601
- if (Array.isArray(cmd)) cmd.forEach((exampleParams) => this.example(...exampleParams));
3602
- else __classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description);
3603
- return this;
3604
- }
3605
- exit(code, err) {
3606
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3607
- __classPrivateFieldSet(this, _YargsInstance_exitError, err, "f");
3608
- if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.exit(code);
3609
- }
3610
- exitProcess(enabled = true) {
3611
- argsert("[boolean]", [enabled], arguments.length);
3612
- __classPrivateFieldSet(this, _YargsInstance_exitProcess, enabled, "f");
3613
- return this;
3614
- }
3615
- fail(f) {
3616
- argsert("<function|boolean>", [f], arguments.length);
3617
- if (typeof f === "boolean" && f !== false) throw new YError("Invalid first argument. Expected function or boolean 'false'");
3618
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").failFn(f);
3619
- return this;
3620
- }
3621
- getAliases() {
3622
- return this.parsed ? this.parsed.aliases : {};
3623
- }
3624
- async getCompletion(args, done) {
3625
- argsert("<array> [function]", [args, done], arguments.length);
3626
- if (!done) return new Promise((resolve, reject) => {
3627
- __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
3628
- if (err) reject(err);
3629
- else resolve(completions);
3630
- });
3631
- });
3632
- else return __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, done);
3633
- }
3634
- getDemandedOptions() {
3635
- argsert([], 0);
3636
- return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedOptions;
3637
- }
3638
- getDemandedCommands() {
3639
- argsert([], 0);
3640
- return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands;
3641
- }
3642
- getDeprecatedOptions() {
3643
- argsert([], 0);
3644
- return __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions;
3645
- }
3646
- getDetectLocale() {
3647
- return __classPrivateFieldGet(this, _YargsInstance_detectLocale, "f");
3648
- }
3649
- getExitProcess() {
3650
- return __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f");
3651
- }
3652
- getGroups() {
3653
- return Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_groups, "f"), __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"));
3654
- }
3655
- getHelp() {
3656
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3657
- if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
3658
- if (!this.parsed) {
3659
- const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true);
3660
- if (isPromise(parse)) return parse.then(() => {
3661
- return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
3662
- });
3663
- }
3664
- const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
3665
- if (isPromise(builderResponse)) return builderResponse.then(() => {
3666
- return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
3667
- });
3668
- }
3669
- return Promise.resolve(__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
3670
- }
3671
- getOptions() {
3672
- return __classPrivateFieldGet(this, _YargsInstance_options, "f");
3673
- }
3674
- getStrict() {
3675
- return __classPrivateFieldGet(this, _YargsInstance_strict, "f");
3676
- }
3677
- getStrictCommands() {
3678
- return __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f");
3679
- }
3680
- getStrictOptions() {
3681
- return __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f");
3682
- }
3683
- global(globals, global) {
3684
- argsert("<string|array> [boolean]", [globals, global], arguments.length);
3685
- globals = [].concat(globals);
3686
- if (global !== false) __classPrivateFieldGet(this, _YargsInstance_options, "f").local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local.filter((l) => globals.indexOf(l) === -1);
3687
- else globals.forEach((g) => {
3688
- if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").local.includes(g)) __classPrivateFieldGet(this, _YargsInstance_options, "f").local.push(g);
3689
- });
3690
- return this;
3691
- }
3692
- group(opts, groupName) {
3693
- argsert("<string|array> <string>", [opts, groupName], arguments.length);
3694
- const existing = __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName] || __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName];
3695
- if (__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]) delete __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName];
3696
- const seen = {};
3697
- __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName] = (existing || []).concat(opts).filter((key) => {
3698
- if (seen[key]) return false;
3699
- return seen[key] = true;
3700
- });
3701
- return this;
3702
- }
3703
- hide(key) {
3704
- argsert("<string>", [key], arguments.length);
3705
- __classPrivateFieldGet(this, _YargsInstance_options, "f").hiddenOptions.push(key);
3706
- return this;
3707
- }
3708
- implies(key, value) {
3709
- argsert("<string|object> [number|string|array]", [key, value], arguments.length);
3710
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").implies(key, value);
3711
- return this;
3712
- }
3713
- locale(locale) {
3714
- argsert("[string]", [locale], arguments.length);
3715
- if (locale === void 0) {
3716
- this[kGuessLocale]();
3717
- return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
3718
- }
3719
- __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
3720
- __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(locale);
3721
- return this;
3722
- }
3723
- middleware(callback, applyBeforeValidation, global) {
3724
- return __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addMiddleware(callback, !!applyBeforeValidation, global);
3725
- }
3726
- nargs(key, value) {
3727
- argsert("<string|object|array> [number]", [key, value], arguments.length);
3728
- this[kPopulateParserHintSingleValueDictionary](this.nargs.bind(this), "narg", key, value);
3729
- return this;
3730
- }
3731
- normalize(keys) {
3732
- argsert("<array|string>", [keys], arguments.length);
3733
- this[kPopulateParserHintArray]("normalize", keys);
3734
- return this;
3735
- }
3736
- number(keys) {
3737
- argsert("<array|string>", [keys], arguments.length);
3738
- this[kPopulateParserHintArray]("number", keys);
3739
- this[kTrackManuallySetKeys](keys);
3740
- return this;
3741
- }
3742
- option(key, opt) {
3743
- argsert("<string|object> [object]", [key, opt], arguments.length);
3744
- if (typeof key === "object") Object.keys(key).forEach((k) => {
3745
- this.options(k, key[k]);
3746
- });
3747
- else {
3748
- if (typeof opt !== "object") opt = {};
3749
- this[kTrackManuallySetKeys](key);
3750
- if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && (key === "version" || (opt === null || opt === void 0 ? void 0 : opt.alias) === "version")) this[kEmitWarning]([
3751
- "\"version\" is a reserved word.",
3752
- "Please do one of the following:",
3753
- "- Disable version with `yargs.version(false)` if using \"version\" as an option",
3754
- "- Use the built-in `yargs.version` method instead (if applicable)",
3755
- "- Use a different option key",
3756
- "https://yargs.js.org/docs/#api-reference-version"
3757
- ].join("\n"), void 0, "versionWarning");
3758
- __classPrivateFieldGet(this, _YargsInstance_options, "f").key[key] = true;
3759
- if (opt.alias) this.alias(key, opt.alias);
3760
- const deprecate = opt.deprecate || opt.deprecated;
3761
- if (deprecate) this.deprecateOption(key, deprecate);
3762
- const demand = opt.demand || opt.required || opt.require;
3763
- if (demand) this.demand(key, demand);
3764
- if (opt.demandOption) this.demandOption(key, typeof opt.demandOption === "string" ? opt.demandOption : void 0);
3765
- if (opt.conflicts) this.conflicts(key, opt.conflicts);
3766
- if ("default" in opt) this.default(key, opt.default);
3767
- if (opt.implies !== void 0) this.implies(key, opt.implies);
3768
- if (opt.nargs !== void 0) this.nargs(key, opt.nargs);
3769
- if (opt.config) this.config(key, opt.configParser);
3770
- if (opt.normalize) this.normalize(key);
3771
- if (opt.choices) this.choices(key, opt.choices);
3772
- if (opt.coerce) this.coerce(key, opt.coerce);
3773
- if (opt.group) this.group(key, opt.group);
3774
- if (opt.boolean || opt.type === "boolean") {
3775
- this.boolean(key);
3776
- if (opt.alias) this.boolean(opt.alias);
3777
- }
3778
- if (opt.array || opt.type === "array") {
3779
- this.array(key);
3780
- if (opt.alias) this.array(opt.alias);
3781
- }
3782
- if (opt.number || opt.type === "number") {
3783
- this.number(key);
3784
- if (opt.alias) this.number(opt.alias);
3785
- }
3786
- if (opt.string || opt.type === "string") {
3787
- this.string(key);
3788
- if (opt.alias) this.string(opt.alias);
3789
- }
3790
- if (opt.count || opt.type === "count") this.count(key);
3791
- if (typeof opt.global === "boolean") this.global(key, opt.global);
3792
- if (opt.defaultDescription) __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = opt.defaultDescription;
3793
- if (opt.skipValidation) this.skipValidation(key);
3794
- const desc = opt.describe || opt.description || opt.desc;
3795
- const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions();
3796
- if (!Object.prototype.hasOwnProperty.call(descriptions, key) || typeof desc === "string") this.describe(key, desc);
3797
- if (opt.hidden) this.hide(key);
3798
- if (opt.requiresArg) this.requiresArg(key);
3799
- }
3800
- return this;
3801
- }
3802
- options(key, opt) {
3803
- return this.option(key, opt);
3804
- }
3805
- parse(args, shortCircuit, _parseFn) {
3806
- argsert("[string|array] [function|boolean|object] [function]", [
3807
- args,
3808
- shortCircuit,
3809
- _parseFn
3810
- ], arguments.length);
3811
- this[kFreeze]();
3812
- if (typeof args === "undefined") args = __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
3813
- if (typeof shortCircuit === "object") {
3814
- __classPrivateFieldSet(this, _YargsInstance_parseContext, shortCircuit, "f");
3815
- shortCircuit = _parseFn;
3816
- }
3817
- if (typeof shortCircuit === "function") {
3818
- __classPrivateFieldSet(this, _YargsInstance_parseFn, shortCircuit, "f");
3819
- shortCircuit = false;
3820
- }
3821
- if (!shortCircuit) __classPrivateFieldSet(this, _YargsInstance_processArgs, args, "f");
3822
- if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldSet(this, _YargsInstance_exitProcess, false, "f");
3823
- const parsed = this[kRunYargsParserAndExecuteCommands](args, !!shortCircuit);
3824
- const tmpParsed = this.parsed;
3825
- __classPrivateFieldGet(this, _YargsInstance_completion, "f").setParsed(this.parsed);
3826
- if (isPromise(parsed)) return parsed.then((argv) => {
3827
- if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
3828
- return argv;
3829
- }).catch((err) => {
3830
- if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldGet(this, _YargsInstance_parseFn, "f")(err, this.parsed.argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
3831
- throw err;
3832
- }).finally(() => {
3833
- this[kUnfreeze]();
3834
- this.parsed = tmpParsed;
3835
- });
3836
- else {
3837
- if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), parsed, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
3838
- this[kUnfreeze]();
3839
- this.parsed = tmpParsed;
3840
- }
3841
- return parsed;
3842
- }
3843
- parseAsync(args, shortCircuit, _parseFn) {
3844
- const maybePromise = this.parse(args, shortCircuit, _parseFn);
3845
- return !isPromise(maybePromise) ? Promise.resolve(maybePromise) : maybePromise;
3846
- }
3847
- parseSync(args, shortCircuit, _parseFn) {
3848
- const maybePromise = this.parse(args, shortCircuit, _parseFn);
3849
- if (isPromise(maybePromise)) throw new YError(".parseSync() must not be used with asynchronous builders, handlers, or middleware");
3850
- return maybePromise;
3851
- }
3852
- parserConfiguration(config) {
3853
- argsert("<object>", [config], arguments.length);
3854
- __classPrivateFieldSet(this, _YargsInstance_parserConfig, config, "f");
3855
- return this;
3856
- }
3857
- pkgConf(key, rootPath) {
3858
- argsert("<string> [string]", [key, rootPath], arguments.length);
3859
- let conf = null;
3860
- const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"));
3861
- if (obj[key] && typeof obj[key] === "object") {
3862
- conf = applyExtends(obj[key], rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3863
- __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(conf);
3864
- }
3865
- return this;
3866
- }
3867
- positional(key, opts) {
3868
- argsert("<string> <object>", [key, opts], arguments.length);
3869
- const supportedOpts = [
3870
- "default",
3871
- "defaultDescription",
3872
- "implies",
3873
- "normalize",
3874
- "choices",
3875
- "conflicts",
3876
- "coerce",
3877
- "type",
3878
- "describe",
3879
- "desc",
3880
- "description",
3881
- "alias"
3882
- ];
3883
- opts = objFilter(opts, (k, v) => {
3884
- if (k === "type" && ![
3885
- "string",
3886
- "number",
3887
- "boolean"
3888
- ].includes(v)) return false;
3889
- return supportedOpts.includes(k);
3890
- });
3891
- const fullCommand = __classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands[__classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands.length - 1];
3892
- const parseOptions = fullCommand ? __classPrivateFieldGet(this, _YargsInstance_command, "f").cmdToParseOptions(fullCommand) : {
3893
- array: [],
3894
- alias: {},
3895
- default: {},
3896
- demand: {}
3897
- };
3898
- objectKeys(parseOptions).forEach((pk) => {
3899
- const parseOption = parseOptions[pk];
3900
- if (Array.isArray(parseOption)) {
3901
- if (parseOption.indexOf(key) !== -1) opts[pk] = true;
3902
- } else if (parseOption[key] && !(pk in opts)) opts[pk] = parseOption[key];
3903
- });
3904
- this.group(key, __classPrivateFieldGet(this, _YargsInstance_usage, "f").getPositionalGroupName());
3905
- return this.option(key, opts);
3906
- }
3907
- recommendCommands(recommend = true) {
3908
- argsert("[boolean]", [recommend], arguments.length);
3909
- __classPrivateFieldSet(this, _YargsInstance_recommendCommands, recommend, "f");
3910
- return this;
3911
- }
3912
- required(keys, max, msg) {
3913
- return this.demand(keys, max, msg);
3914
- }
3915
- require(keys, max, msg) {
3916
- return this.demand(keys, max, msg);
3917
- }
3918
- requiresArg(keys) {
3919
- argsert("<array|string|object> [number]", [keys], arguments.length);
3920
- if (typeof keys === "string" && __classPrivateFieldGet(this, _YargsInstance_options, "f").narg[keys]) return this;
3921
- else this[kPopulateParserHintSingleValueDictionary](this.requiresArg.bind(this), "narg", keys, NaN);
3922
- return this;
3923
- }
3924
- showCompletionScript($0, cmd) {
3925
- argsert("[string] [string]", [$0, cmd], arguments.length);
3926
- $0 = $0 || this.$0;
3927
- __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(__classPrivateFieldGet(this, _YargsInstance_completion, "f").generateCompletionScript($0, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion"));
3928
- return this;
3929
- }
3930
- showHelp(level) {
3931
- argsert("[string|function]", [level], arguments.length);
3932
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3933
- if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
3934
- if (!this.parsed) {
3935
- const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true);
3936
- if (isPromise(parse)) {
3937
- parse.then(() => {
3938
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
3939
- });
3940
- return this;
3941
- }
3942
- }
3943
- const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
3944
- if (isPromise(builderResponse)) {
3945
- builderResponse.then(() => {
3946
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
3947
- });
3948
- return this;
3949
- }
3950
- }
3951
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
3952
- return this;
3953
- }
3954
- scriptName(scriptName) {
3955
- this.customScriptName = true;
3956
- this.$0 = scriptName;
3957
- return this;
3958
- }
3959
- showHelpOnFail(enabled, message) {
3960
- argsert("[boolean|string] [string]", [enabled, message], arguments.length);
3961
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelpOnFail(enabled, message);
3962
- return this;
3963
- }
3964
- showVersion(level) {
3965
- argsert("[string|function]", [level], arguments.length);
3966
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion(level);
3967
- return this;
3968
- }
3969
- skipValidation(keys) {
3970
- argsert("<array|string>", [keys], arguments.length);
3971
- this[kPopulateParserHintArray]("skipValidation", keys);
3972
- return this;
3973
- }
3974
- strict(enabled) {
3975
- argsert("[boolean]", [enabled], arguments.length);
3976
- __classPrivateFieldSet(this, _YargsInstance_strict, enabled !== false, "f");
3977
- return this;
3978
- }
3979
- strictCommands(enabled) {
3980
- argsert("[boolean]", [enabled], arguments.length);
3981
- __classPrivateFieldSet(this, _YargsInstance_strictCommands, enabled !== false, "f");
3982
- return this;
3983
- }
3984
- strictOptions(enabled) {
3985
- argsert("[boolean]", [enabled], arguments.length);
3986
- __classPrivateFieldSet(this, _YargsInstance_strictOptions, enabled !== false, "f");
3987
- return this;
3988
- }
3989
- string(keys) {
3990
- argsert("<array|string>", [keys], arguments.length);
3991
- this[kPopulateParserHintArray]("string", keys);
3992
- this[kTrackManuallySetKeys](keys);
3993
- return this;
3994
- }
3995
- terminalWidth() {
3996
- argsert([], 0);
3997
- return __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.stdColumns;
3998
- }
3999
- updateLocale(obj) {
4000
- return this.updateStrings(obj);
4001
- }
4002
- updateStrings(obj) {
4003
- argsert("<object>", [obj], arguments.length);
4004
- __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
4005
- __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj);
4006
- return this;
4007
- }
4008
- usage(msg, description, builder, handler) {
4009
- argsert("<string|null|undefined> [string|boolean] [function|object] [function]", [
4010
- msg,
4011
- description,
4012
- builder,
4013
- handler
4014
- ], arguments.length);
4015
- if (description !== void 0) {
4016
- assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4017
- if ((msg || "").match(/^\$0( |$)/)) return this.command(msg, description, builder, handler);
4018
- else throw new YError(".usage() description must start with $0 if being used as alias for .command()");
4019
- } else {
4020
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").usage(msg);
4021
- return this;
4022
- }
4023
- }
4024
- usageConfiguration(config) {
4025
- argsert("<object>", [config], arguments.length);
4026
- __classPrivateFieldSet(this, _YargsInstance_usageConfig, config, "f");
4027
- return this;
4028
- }
4029
- version(opt, msg, ver) {
4030
- const defaultVersionOpt = "version";
4031
- argsert("[boolean|string] [string] [string]", [
4032
- opt,
4033
- msg,
4034
- ver
4035
- ], arguments.length);
4036
- if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")) {
4037
- this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
4038
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(void 0);
4039
- __classPrivateFieldSet(this, _YargsInstance_versionOpt, null, "f");
4040
- }
4041
- if (arguments.length === 0) {
4042
- ver = this[kGuessVersion]();
4043
- opt = defaultVersionOpt;
4044
- } else if (arguments.length === 1) {
4045
- if (opt === false) return this;
4046
- ver = opt;
4047
- opt = defaultVersionOpt;
4048
- } else if (arguments.length === 2) {
4049
- ver = msg;
4050
- msg = void 0;
4051
- }
4052
- __classPrivateFieldSet(this, _YargsInstance_versionOpt, typeof opt === "string" ? opt : defaultVersionOpt, "f");
4053
- msg = msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show version number");
4054
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(ver || void 0);
4055
- this.boolean(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
4056
- this.describe(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"), msg);
4057
- return this;
4058
- }
4059
- wrap(cols) {
4060
- argsert("<number|null|undefined>", [cols], arguments.length);
4061
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
4062
- return this;
4063
- }
4064
- [(_YargsInstance_command = /* @__PURE__ */ new WeakMap(), _YargsInstance_cwd = /* @__PURE__ */ new WeakMap(), _YargsInstance_context = /* @__PURE__ */ new WeakMap(), _YargsInstance_completion = /* @__PURE__ */ new WeakMap(), _YargsInstance_completionCommand = /* @__PURE__ */ new WeakMap(), _YargsInstance_defaultShowHiddenOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitError = /* @__PURE__ */ new WeakMap(), _YargsInstance_detectLocale = /* @__PURE__ */ new WeakMap(), _YargsInstance_emittedWarnings = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitProcess = /* @__PURE__ */ new WeakMap(), _YargsInstance_frozens = /* @__PURE__ */ new WeakMap(), _YargsInstance_globalMiddleware = /* @__PURE__ */ new WeakMap(), _YargsInstance_groups = /* @__PURE__ */ new WeakMap(), _YargsInstance_hasOutput = /* @__PURE__ */ new WeakMap(), _YargsInstance_helpOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_isGlobalContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_logger = /* @__PURE__ */ new WeakMap(), _YargsInstance_output = /* @__PURE__ */ new WeakMap(), _YargsInstance_options = /* @__PURE__ */ new WeakMap(), _YargsInstance_parentRequire = /* @__PURE__ */ new WeakMap(), _YargsInstance_parserConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseFn = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_pkgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_preservedGroups = /* @__PURE__ */ new WeakMap(), _YargsInstance_processArgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_recommendCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_shim = /* @__PURE__ */ new WeakMap(), _YargsInstance_strict = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictOptions = /* @__PURE__ */ new WeakMap(), _YargsInstance_usage = /* @__PURE__ */ new WeakMap(), _YargsInstance_usageConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_versionOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_validation = /* @__PURE__ */ new WeakMap(), kCopyDoubleDash)](argv) {
4065
- if (!argv._ || !argv["--"]) return argv;
4066
- argv._.push.apply(argv._, argv["--"]);
4067
- try {
4068
- delete argv["--"];
4069
- } catch (_err) {}
4070
- return argv;
4071
- }
4072
- [kCreateLogger]() {
4073
- return {
4074
- log: (...args) => {
4075
- if (!this[kHasParseCallback]()) console.log(...args);
4076
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4077
- if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length) __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + "\n", "f");
4078
- __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
4079
- },
4080
- error: (...args) => {
4081
- if (!this[kHasParseCallback]()) console.error(...args);
4082
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4083
- if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length) __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + "\n", "f");
4084
- __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
4085
- }
4086
- };
4087
- }
4088
- [kDeleteFromParserHintObject](optionKey) {
4089
- objectKeys(__classPrivateFieldGet(this, _YargsInstance_options, "f")).forEach((hintKey) => {
4090
- if (((key) => key === "configObjects")(hintKey)) return;
4091
- const hint = __classPrivateFieldGet(this, _YargsInstance_options, "f")[hintKey];
4092
- if (Array.isArray(hint)) {
4093
- if (hint.includes(optionKey)) hint.splice(hint.indexOf(optionKey), 1);
4094
- } else if (typeof hint === "object") delete hint[optionKey];
4095
- });
4096
- delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
4097
- }
4098
- [kEmitWarning](warning, type, deduplicationId) {
4099
- if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) {
4100
- __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type);
4101
- __classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true;
4102
- }
4103
- }
4104
- [kFreeze]() {
4105
- __classPrivateFieldGet(this, _YargsInstance_frozens, "f").push({
4106
- options: __classPrivateFieldGet(this, _YargsInstance_options, "f"),
4107
- configObjects: __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects.slice(0),
4108
- exitProcess: __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"),
4109
- groups: __classPrivateFieldGet(this, _YargsInstance_groups, "f"),
4110
- strict: __classPrivateFieldGet(this, _YargsInstance_strict, "f"),
4111
- strictCommands: __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"),
4112
- strictOptions: __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"),
4113
- completionCommand: __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"),
4114
- output: __classPrivateFieldGet(this, _YargsInstance_output, "f"),
4115
- exitError: __classPrivateFieldGet(this, _YargsInstance_exitError, "f"),
4116
- hasOutput: __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"),
4117
- parsed: this.parsed,
4118
- parseFn: __classPrivateFieldGet(this, _YargsInstance_parseFn, "f"),
4119
- parseContext: __classPrivateFieldGet(this, _YargsInstance_parseContext, "f")
4120
- });
4121
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").freeze();
4122
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").freeze();
4123
- __classPrivateFieldGet(this, _YargsInstance_command, "f").freeze();
4124
- __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").freeze();
4125
- }
4126
- [kGetDollarZero]() {
4127
- let $0 = "";
4128
- let default$0;
4129
- if (/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv()[0])) default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(1, 2);
4130
- else default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(0, 1);
4131
- $0 = default$0.map((x) => {
4132
- const b = this[kRebase](__classPrivateFieldGet(this, _YargsInstance_cwd, "f"), x);
4133
- return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x;
4134
- }).join(" ").trim();
4135
- if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_") && __classPrivateFieldGet(this, _YargsInstance_shim, "f").getProcessArgvBin() === __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_")) $0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_").replace(`${__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.execPath())}/`, "");
4136
- return $0;
4137
- }
4138
- [kGetParserConfiguration]() {
4139
- return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
4140
- }
4141
- [kGetUsageConfiguration]() {
4142
- return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f");
4143
- }
4144
- [kGuessLocale]() {
4145
- if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f")) return;
4146
- const locale = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_ALL") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_MESSAGES") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANG") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANGUAGE") || "en_US";
4147
- this.locale(locale.replace(/[.:].*/, ""));
4148
- }
4149
- [kGuessVersion]() {
4150
- return this[kPkgUp]().version || "unknown";
4151
- }
4152
- [kParsePositionalNumbers](argv) {
4153
- const args = argv["--"] ? argv["--"] : argv._;
4154
- for (let i = 0, arg; (arg = args[i]) !== void 0; i++) if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.looksLikeNumber(arg) && Number.isSafeInteger(Math.floor(parseFloat(`${arg}`)))) args[i] = Number(arg);
4155
- return argv;
4156
- }
4157
- [kPkgUp](rootPath) {
4158
- const npath = rootPath || "*";
4159
- if (__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath]) return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
4160
- let obj = {};
4161
- try {
4162
- let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename;
4163
- if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir);
4164
- const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names) => {
4165
- if (names.includes("package.json")) return "package.json";
4166
- else return;
4167
- });
4168
- assertNotStrictEqual(pkgJsonPath, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4169
- obj = JSON.parse(__classPrivateFieldGet(this, _YargsInstance_shim, "f").readFileSync(pkgJsonPath, "utf8"));
4170
- } catch (_noop) {}
4171
- __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
4172
- return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
4173
- }
4174
- [kPopulateParserHintArray](type, keys) {
4175
- keys = [].concat(keys);
4176
- keys.forEach((key) => {
4177
- key = this[kSanitizeKey](key);
4178
- __classPrivateFieldGet(this, _YargsInstance_options, "f")[type].push(key);
4179
- });
4180
- }
4181
- [kPopulateParserHintSingleValueDictionary](builder, type, key, value) {
4182
- this[kPopulateParserHintDictionary](builder, type, key, value, (type, key, value) => {
4183
- __classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] = value;
4184
- });
4185
- }
4186
- [kPopulateParserHintArrayDictionary](builder, type, key, value) {
4187
- this[kPopulateParserHintDictionary](builder, type, key, value, (type, key, value) => {
4188
- __classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] || []).concat(value);
4189
- });
4190
- }
4191
- [kPopulateParserHintDictionary](builder, type, key, value, singleKeyHandler) {
4192
- if (Array.isArray(key)) key.forEach((k) => {
4193
- builder(k, value);
4194
- });
4195
- else if (((key) => typeof key === "object")(key)) for (const k of objectKeys(key)) builder(k, key[k]);
4196
- else singleKeyHandler(type, this[kSanitizeKey](key), value);
4197
- }
4198
- [kSanitizeKey](key) {
4199
- if (key === "__proto__") return "___proto___";
4200
- return key;
4201
- }
4202
- [kSetKey](key, set) {
4203
- this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), "key", key, set);
4204
- return this;
4205
- }
4206
- [kUnfreeze]() {
4207
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4208
- const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
4209
- assertNotStrictEqual(frozen, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4210
- let configObjects;
4211
- _a = this, _b = this, _c = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {options: { set value(_o) {
4212
- __classPrivateFieldSet(_a, _YargsInstance_options, _o, "f");
4213
- } }.value, configObjects, exitProcess: { set value(_o) {
4214
- __classPrivateFieldSet(_b, _YargsInstance_exitProcess, _o, "f");
4215
- } }.value, groups: { set value(_o) {
4216
- __classPrivateFieldSet(_c, _YargsInstance_groups, _o, "f");
4217
- } }.value, output: { set value(_o) {
4218
- __classPrivateFieldSet(_d, _YargsInstance_output, _o, "f");
4219
- } }.value, exitError: { set value(_o) {
4220
- __classPrivateFieldSet(_e, _YargsInstance_exitError, _o, "f");
4221
- } }.value, hasOutput: { set value(_o) {
4222
- __classPrivateFieldSet(_f, _YargsInstance_hasOutput, _o, "f");
4223
- } }.value, parsed: this.parsed, strict: { set value(_o) {
4224
- __classPrivateFieldSet(_g, _YargsInstance_strict, _o, "f");
4225
- } }.value, strictCommands: { set value(_o) {
4226
- __classPrivateFieldSet(_h, _YargsInstance_strictCommands, _o, "f");
4227
- } }.value, strictOptions: { set value(_o) {
4228
- __classPrivateFieldSet(_j, _YargsInstance_strictOptions, _o, "f");
4229
- } }.value, completionCommand: { set value(_o) {
4230
- __classPrivateFieldSet(_k, _YargsInstance_completionCommand, _o, "f");
4231
- } }.value, parseFn: { set value(_o) {
4232
- __classPrivateFieldSet(_l, _YargsInstance_parseFn, _o, "f");
4233
- } }.value, parseContext: { set value(_o) {
4234
- __classPrivateFieldSet(_m, _YargsInstance_parseContext, _o, "f");
4235
- } }.value} = frozen;
4236
- __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = configObjects;
4237
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").unfreeze();
4238
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").unfreeze();
4239
- __classPrivateFieldGet(this, _YargsInstance_command, "f").unfreeze();
4240
- __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").unfreeze();
4241
- }
4242
- [kValidateAsync](validation, argv) {
4243
- return maybeAsyncResult(argv, (result) => {
4244
- validation(result);
4245
- return result;
4246
- });
4247
- }
4248
- getInternalMethods() {
4249
- return {
4250
- getCommandInstance: this[kGetCommandInstance].bind(this),
4251
- getContext: this[kGetContext].bind(this),
4252
- getHasOutput: this[kGetHasOutput].bind(this),
4253
- getLoggerInstance: this[kGetLoggerInstance].bind(this),
4254
- getParseContext: this[kGetParseContext].bind(this),
4255
- getParserConfiguration: this[kGetParserConfiguration].bind(this),
4256
- getUsageConfiguration: this[kGetUsageConfiguration].bind(this),
4257
- getUsageInstance: this[kGetUsageInstance].bind(this),
4258
- getValidationInstance: this[kGetValidationInstance].bind(this),
4259
- hasParseCallback: this[kHasParseCallback].bind(this),
4260
- isGlobalContext: this[kIsGlobalContext].bind(this),
4261
- postProcess: this[kPostProcess].bind(this),
4262
- reset: this[kReset].bind(this),
4263
- runValidation: this[kRunValidation].bind(this),
4264
- runYargsParserAndExecuteCommands: this[kRunYargsParserAndExecuteCommands].bind(this),
4265
- setHasOutput: this[kSetHasOutput].bind(this)
4266
- };
4267
- }
4268
- [kGetCommandInstance]() {
4269
- return __classPrivateFieldGet(this, _YargsInstance_command, "f");
4270
- }
4271
- [kGetContext]() {
4272
- return __classPrivateFieldGet(this, _YargsInstance_context, "f");
4273
- }
4274
- [kGetHasOutput]() {
4275
- return __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f");
4276
- }
4277
- [kGetLoggerInstance]() {
4278
- return __classPrivateFieldGet(this, _YargsInstance_logger, "f");
4279
- }
4280
- [kGetParseContext]() {
4281
- return __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") || {};
4282
- }
4283
- [kGetUsageInstance]() {
4284
- return __classPrivateFieldGet(this, _YargsInstance_usage, "f");
4285
- }
4286
- [kGetValidationInstance]() {
4287
- return __classPrivateFieldGet(this, _YargsInstance_validation, "f");
4288
- }
4289
- [kHasParseCallback]() {
4290
- return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f");
4291
- }
4292
- [kIsGlobalContext]() {
4293
- return __classPrivateFieldGet(this, _YargsInstance_isGlobalContext, "f");
4294
- }
4295
- [kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) {
4296
- if (calledFromCommand) return argv;
4297
- if (isPromise(argv)) return argv;
4298
- if (!populateDoubleDash) argv = this[kCopyDoubleDash](argv);
4299
- if (this[kGetParserConfiguration]()["parse-positional-numbers"] || this[kGetParserConfiguration]()["parse-positional-numbers"] === void 0) argv = this[kParsePositionalNumbers](argv);
4300
- if (runGlobalMiddleware) argv = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
4301
- return argv;
4302
- }
4303
- [kReset](aliases = {}) {
4304
- __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f") || {}, "f");
4305
- const tmpOptions = {};
4306
- tmpOptions.local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local || [];
4307
- tmpOptions.configObjects = __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || [];
4308
- const localLookup = {};
4309
- tmpOptions.local.forEach((l) => {
4310
- localLookup[l] = true;
4311
- (aliases[l] || []).forEach((a) => {
4312
- localLookup[a] = true;
4313
- });
4314
- });
4315
- Object.assign(__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"), Object.keys(__classPrivateFieldGet(this, _YargsInstance_groups, "f")).reduce((acc, groupName) => {
4316
- const keys = __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName].filter((key) => !(key in localLookup));
4317
- if (keys.length > 0) acc[groupName] = keys;
4318
- return acc;
4319
- }, {}));
4320
- __classPrivateFieldSet(this, _YargsInstance_groups, {}, "f");
4321
- const arrayOptions = [
4322
- "array",
4323
- "boolean",
4324
- "string",
4325
- "skipValidation",
4326
- "count",
4327
- "normalize",
4328
- "number",
4329
- "hiddenOptions"
4330
- ];
4331
- const objectOptions = [
4332
- "narg",
4333
- "key",
4334
- "alias",
4335
- "default",
4336
- "defaultDescription",
4337
- "config",
4338
- "choices",
4339
- "demandedOptions",
4340
- "demandedCommands",
4341
- "deprecatedOptions"
4342
- ];
4343
- arrayOptions.forEach((k) => {
4344
- tmpOptions[k] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[k] || []).filter((k) => !localLookup[k]);
4345
- });
4346
- objectOptions.forEach((k) => {
4347
- tmpOptions[k] = objFilter(__classPrivateFieldGet(this, _YargsInstance_options, "f")[k], (k) => !localLookup[k]);
4348
- });
4349
- tmpOptions.envPrefix = __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
4350
- __classPrivateFieldSet(this, _YargsInstance_options, tmpOptions, "f");
4351
- __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f") ? __classPrivateFieldGet(this, _YargsInstance_usage, "f").reset(localLookup) : usage(this, __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4352
- __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f") ? __classPrivateFieldGet(this, _YargsInstance_validation, "f").reset(localLookup) : validation(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4353
- __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f") ? __classPrivateFieldGet(this, _YargsInstance_command, "f").reset() : command(__classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_validation, "f"), __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4354
- if (!__classPrivateFieldGet(this, _YargsInstance_completion, "f")) __classPrivateFieldSet(this, _YargsInstance_completion, completion(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_command, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4355
- __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").reset();
4356
- __classPrivateFieldSet(this, _YargsInstance_completionCommand, null, "f");
4357
- __classPrivateFieldSet(this, _YargsInstance_output, "", "f");
4358
- __classPrivateFieldSet(this, _YargsInstance_exitError, null, "f");
4359
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, false, "f");
4360
- this.parsed = false;
4361
- return this;
4362
- }
4363
- [kRebase](base, dir) {
4364
- return __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.relative(base, dir);
4365
- }
4366
- [kRunYargsParserAndExecuteCommands](args, shortCircuit, calledFromCommand, commandIndex = 0, helpOnly = false) {
4367
- var _a, _b, _c, _d;
4368
- let skipValidation = !!calledFromCommand || helpOnly;
4369
- args = args || __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
4370
- __classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__;
4371
- __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration]();
4372
- const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration["populate--"];
4373
- const config = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, { "populate--": true });
4374
- const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), { configuration: {
4375
- "parse-positional-numbers": false,
4376
- ...config
4377
- } }));
4378
- const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"));
4379
- let argvPromise = void 0;
4380
- const aliases = parsed.aliases;
4381
- let helpOptSet = false;
4382
- let versionOptSet = false;
4383
- Object.keys(argv).forEach((key) => {
4384
- if (key === __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f") && argv[key]) helpOptSet = true;
4385
- else if (key === __classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && argv[key]) versionOptSet = true;
4386
- });
4387
- argv.$0 = this.$0;
4388
- this.parsed = parsed;
4389
- if (commandIndex === 0) __classPrivateFieldGet(this, _YargsInstance_usage, "f").clearCachedHelpMessage();
4390
- try {
4391
- this[kGuessLocale]();
4392
- if (shortCircuit) return this[kPostProcess](argv, populateDoubleDash, !!calledFromCommand, false);
4393
- if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
4394
- if ([__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")].concat(aliases[__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")] || []).filter((k) => k.length > 1).includes("" + argv._[argv._.length - 1])) {
4395
- argv._.pop();
4396
- helpOptSet = true;
4397
- }
4398
- }
4399
- __classPrivateFieldSet(this, _YargsInstance_isGlobalContext, false, "f");
4400
- const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands();
4401
- const requestCompletions = ((_a = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _a === void 0 ? void 0 : _a.completionKey) ? [(_b = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _b === void 0 ? void 0 : _b.completionKey, ...(_d = this.getAliases()[(_c = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _c === void 0 ? void 0 : _c.completionKey]) !== null && _d !== void 0 ? _d : []].some((key) => Object.prototype.hasOwnProperty.call(argv, key)) : false;
4402
- const skipRecommendation = helpOptSet || requestCompletions || helpOnly;
4403
- if (argv._.length) {
4404
- if (handlerKeys.length) {
4405
- let firstUnknownCommand;
4406
- for (let i = commandIndex || 0, cmd; argv._[i] !== void 0; i++) {
4407
- cmd = String(argv._[i]);
4408
- if (handlerKeys.includes(cmd) && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
4409
- const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(cmd, this, parsed, i + 1, helpOnly, helpOptSet || versionOptSet || helpOnly);
4410
- return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
4411
- } else if (!firstUnknownCommand && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
4412
- firstUnknownCommand = cmd;
4413
- break;
4414
- }
4415
- }
4416
- if (!__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && __classPrivateFieldGet(this, _YargsInstance_recommendCommands, "f") && firstUnknownCommand && !skipRecommendation) __classPrivateFieldGet(this, _YargsInstance_validation, "f").recommendCommands(firstUnknownCommand, handlerKeys);
4417
- }
4418
- if (__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") && argv._.includes(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) && !requestCompletions) {
4419
- if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
4420
- this.showCompletionScript();
4421
- this.exit(0);
4422
- }
4423
- }
4424
- if (__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && !skipRecommendation) {
4425
- const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(null, this, parsed, 0, helpOnly, helpOptSet || versionOptSet || helpOnly);
4426
- return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
4427
- }
4428
- if (requestCompletions) {
4429
- if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
4430
- args = [].concat(args);
4431
- const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey}`) + 1);
4432
- __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(completionArgs, (err, completions) => {
4433
- if (err) throw new YError(err.message);
4434
- (completions || []).forEach((completion) => {
4435
- __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(completion);
4436
- });
4437
- this.exit(0);
4438
- });
4439
- return this[kPostProcess](argv, !populateDoubleDash, !!calledFromCommand, false);
4440
- }
4441
- if (!__classPrivateFieldGet(this, _YargsInstance_hasOutput, "f")) {
4442
- if (helpOptSet) {
4443
- if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
4444
- skipValidation = true;
4445
- this.showHelp((message) => {
4446
- __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(message);
4447
- this.exit(0);
4448
- });
4449
- } else if (versionOptSet) {
4450
- if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
4451
- skipValidation = true;
4452
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion("log");
4453
- this.exit(0);
4454
- }
4455
- }
4456
- if (!skipValidation && __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.length > 0) skipValidation = Object.keys(argv).some((key) => __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.indexOf(key) >= 0 && argv[key] === true);
4457
- if (!skipValidation) {
4458
- if (parsed.error) throw new YError(parsed.error.message);
4459
- if (!requestCompletions) {
4460
- const validation = this[kRunValidation](aliases, {}, parsed.error);
4461
- if (!calledFromCommand) argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), true);
4462
- argvPromise = this[kValidateAsync](validation, argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv);
4463
- if (isPromise(argvPromise) && !calledFromCommand) argvPromise = argvPromise.then(() => {
4464
- return applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
4465
- });
4466
- }
4467
- }
4468
- } catch (err) {
4469
- if (err instanceof YError) __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message, err);
4470
- else throw err;
4471
- }
4472
- return this[kPostProcess](argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv, populateDoubleDash, !!calledFromCommand, true);
4473
- }
4474
- [kRunValidation](aliases, positionalMap, parseErrors, isDefaultCommand) {
4475
- const demandedOptions = { ...this.getDemandedOptions() };
4476
- return (argv) => {
4477
- if (parseErrors) throw new YError(parseErrors.message);
4478
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").nonOptionCount(argv);
4479
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").requiredArguments(argv, demandedOptions);
4480
- let failedStrictCommands = false;
4481
- if (__classPrivateFieldGet(this, _YargsInstance_strictCommands, "f")) failedStrictCommands = __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownCommands(argv);
4482
- if (__classPrivateFieldGet(this, _YargsInstance_strict, "f") && !failedStrictCommands) __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, positionalMap, !!isDefaultCommand);
4483
- else if (__classPrivateFieldGet(this, _YargsInstance_strictOptions, "f")) __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, {}, false, false);
4484
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").limitedChoices(argv);
4485
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").implications(argv);
4486
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicting(argv);
4487
- };
4488
- }
4489
- [kSetHasOutput]() {
4490
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4491
- }
4492
- [kTrackManuallySetKeys](keys) {
4493
- if (typeof keys === "string") __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
4494
- else for (const k of keys) __classPrivateFieldGet(this, _YargsInstance_options, "f").key[k] = true;
4495
- }
4496
- };
4497
- function isYargsInstance(y) {
4498
- return !!y && typeof y.getInternalMethods === "function";
4499
- }
4500
-
4501
- //#endregion
4502
- //#region node_modules/yargs/index.mjs
4503
- const Yargs = YargsFactory(esm_default);
4504
-
4505
- //#endregion
4506
14
  //#region ts/parseCliArgs.ts
4507
15
  /**
4508
16
  * Parse CLI arguments the same way cli.ts does
@@ -4515,7 +23,7 @@ function parseCliArgs(argv) {
4515
23
  const raw = scriptBaseName.replace(/^(cli|agent)(-yes)?$/, "").replace(/^ay$/, "").replace(/-yes$/, "") || void 0;
4516
24
  return raw && CLI_ALIASES[raw] || raw;
4517
25
  })();
4518
- const parsedArgv = Yargs(hideBin(argv)).usage("Usage: $0 [cli] [agent-yes args] [agent-cli args] [--] [prompts...]").example("$0 claude --timeout=30s -- solve all todos in my codebase, commit one by one", "Run Claude with a 30 seconds idle timeout (will type /exit when timeout), everything after `--` will be treated as the prompt").example("$0 claude --stdpush", "Run Claude with external stdin input enabled via --append-prompt").option("robust", {
26
+ const parsedArgv = yargs(hideBin(argv)).usage("Usage: $0 [cli] [agent-yes args] [agent-cli args] [--] [prompts...]").example("$0 claude --timeout=30s -- solve all todos in my codebase, commit one by one", "Run Claude with a 30 seconds idle timeout (will type /exit when timeout), everything after `--` will be treated as the prompt").example("$0 claude --stdpush", "Run Claude with external stdin input enabled via --append-prompt").option("robust", {
4519
27
  type: "boolean",
4520
28
  default: true,
4521
29
  description: "re-spawn Claude with --continue if it crashes, only works for claude yet",
@@ -4665,7 +173,7 @@ function parseCliArgs(argv) {
4665
173
  cliArgs: cliArgsForSpawn,
4666
174
  prompt: [parsedArgv.prompt, dashPrompt].filter(Boolean).join(" ") || void 0,
4667
175
  install: parsedArgv.install,
4668
- exitOnIdle: Number((parsedArgv.timeout || parsedArgv.idle || parsedArgv.exitOnIdle)?.replace(/.*/, (e) => String((0, import_ms.default)(e))) || 0),
176
+ exitOnIdle: Number((parsedArgv.timeout || parsedArgv.idle || parsedArgv.exitOnIdle)?.replace(/.*/, (e) => String(ms(e))) || 0),
4669
177
  queue: parsedArgv.queue,
4670
178
  robust: parsedArgv.robust,
4671
179
  logFile: parsedArgv.logFile,