@manot40/genql-cli 1.0.0 → 1.0.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.mjs CHANGED
@@ -1,9 +1,4249 @@
1
1
  #!/usr/bin/env node
2
- import { t as generate } from "./main-BVWRj669.mjs";
3
- import kleur from "kleur";
4
- import yargs from "yargs";
5
- import { existsSync, readFileSync } from "fs";
2
+ import { n as __toESM, t as __commonJSMin } from "./chunk-BBnsswwY.mjs";
3
+ import { t as generate } from "./main-DnxPgNLv.mjs";
4
+ import { n as stringWidth, t as wrapAnsi } from "./wrap-ansi-BLh1Umdy.mjs";
5
+ import { createRequire } from "node:module";
6
+ import { format, inspect } from "util";
7
+ import { basename, dirname, extname, join, normalize, relative, resolve } from "path";
8
+ import { notStrictEqual, strictEqual } from "assert";
9
+ import { existsSync, readFileSync, readdirSync, statSync, writeFile } from "fs";
10
+ import { fileURLToPath } from "url";
11
+ import { readFileSync as readFileSync$1, readdirSync as readdirSync$1 } from "node:fs";
6
12
 
13
+ //#region node_modules/kleur/index.mjs
14
+ let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY = true;
15
+ if (typeof process !== "undefined") {
16
+ ({FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM} = process.env || {});
17
+ isTTY = process.stdout && process.stdout.isTTY;
18
+ }
19
+ const $ = {
20
+ enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY),
21
+ reset: init(0, 0),
22
+ bold: init(1, 22),
23
+ dim: init(2, 22),
24
+ italic: init(3, 23),
25
+ underline: init(4, 24),
26
+ inverse: init(7, 27),
27
+ hidden: init(8, 28),
28
+ strikethrough: init(9, 29),
29
+ black: init(30, 39),
30
+ red: init(31, 39),
31
+ green: init(32, 39),
32
+ yellow: init(33, 39),
33
+ blue: init(34, 39),
34
+ magenta: init(35, 39),
35
+ cyan: init(36, 39),
36
+ white: init(37, 39),
37
+ gray: init(90, 39),
38
+ grey: init(90, 39),
39
+ bgBlack: init(40, 49),
40
+ bgRed: init(41, 49),
41
+ bgGreen: init(42, 49),
42
+ bgYellow: init(43, 49),
43
+ bgBlue: init(44, 49),
44
+ bgMagenta: init(45, 49),
45
+ bgCyan: init(46, 49),
46
+ bgWhite: init(47, 49)
47
+ };
48
+ function run(arr, str) {
49
+ let i = 0, tmp, beg = "", end = "";
50
+ for (; i < arr.length; i++) {
51
+ tmp = arr[i];
52
+ beg += tmp.open;
53
+ end += tmp.close;
54
+ if (!!~str.indexOf(tmp.close)) str = str.replace(tmp.rgx, tmp.close + tmp.open);
55
+ }
56
+ return beg + str + end;
57
+ }
58
+ function chain(has, keys) {
59
+ let ctx = {
60
+ has,
61
+ keys
62
+ };
63
+ ctx.reset = $.reset.bind(ctx);
64
+ ctx.bold = $.bold.bind(ctx);
65
+ ctx.dim = $.dim.bind(ctx);
66
+ ctx.italic = $.italic.bind(ctx);
67
+ ctx.underline = $.underline.bind(ctx);
68
+ ctx.inverse = $.inverse.bind(ctx);
69
+ ctx.hidden = $.hidden.bind(ctx);
70
+ ctx.strikethrough = $.strikethrough.bind(ctx);
71
+ ctx.black = $.black.bind(ctx);
72
+ ctx.red = $.red.bind(ctx);
73
+ ctx.green = $.green.bind(ctx);
74
+ ctx.yellow = $.yellow.bind(ctx);
75
+ ctx.blue = $.blue.bind(ctx);
76
+ ctx.magenta = $.magenta.bind(ctx);
77
+ ctx.cyan = $.cyan.bind(ctx);
78
+ ctx.white = $.white.bind(ctx);
79
+ ctx.gray = $.gray.bind(ctx);
80
+ ctx.grey = $.grey.bind(ctx);
81
+ ctx.bgBlack = $.bgBlack.bind(ctx);
82
+ ctx.bgRed = $.bgRed.bind(ctx);
83
+ ctx.bgGreen = $.bgGreen.bind(ctx);
84
+ ctx.bgYellow = $.bgYellow.bind(ctx);
85
+ ctx.bgBlue = $.bgBlue.bind(ctx);
86
+ ctx.bgMagenta = $.bgMagenta.bind(ctx);
87
+ ctx.bgCyan = $.bgCyan.bind(ctx);
88
+ ctx.bgWhite = $.bgWhite.bind(ctx);
89
+ return ctx;
90
+ }
91
+ function init(open, close) {
92
+ let blk = {
93
+ open: `\x1b[${open}m`,
94
+ close: `\x1b[${close}m`,
95
+ rgx: new RegExp(`\\x1b\\[${close}m`, "g")
96
+ };
97
+ return function(txt) {
98
+ if (this !== void 0 && this.has !== void 0) {
99
+ ~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
100
+ return txt === void 0 ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
101
+ }
102
+ return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
103
+ };
104
+ }
105
+ var kleur_default = $;
106
+
107
+ //#endregion
108
+ //#region node_modules/cliui/build/lib/index.js
109
+ const align = {
110
+ right: alignRight,
111
+ center: alignCenter
112
+ };
113
+ const top = 0;
114
+ const right = 1;
115
+ const bottom = 2;
116
+ const left = 3;
117
+ var UI = class {
118
+ constructor(opts) {
119
+ var _a$1;
120
+ this.width = opts.width;
121
+ this.wrap = (_a$1 = opts.wrap) !== null && _a$1 !== void 0 ? _a$1 : true;
122
+ this.rows = [];
123
+ }
124
+ span(...args) {
125
+ const cols = this.div(...args);
126
+ cols.span = true;
127
+ }
128
+ resetOutput() {
129
+ this.rows = [];
130
+ }
131
+ div(...args) {
132
+ if (args.length === 0) this.div("");
133
+ if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === "string") return this.applyLayoutDSL(args[0]);
134
+ const cols = args.map((arg) => {
135
+ if (typeof arg === "string") return this.colFromString(arg);
136
+ return arg;
137
+ });
138
+ this.rows.push(cols);
139
+ return cols;
140
+ }
141
+ shouldApplyLayoutDSL(...args) {
142
+ return args.length === 1 && typeof args[0] === "string" && /[\t\n]/.test(args[0]);
143
+ }
144
+ applyLayoutDSL(str) {
145
+ const rows = str.split("\n").map((row) => row.split(" "));
146
+ let leftColumnWidth = 0;
147
+ rows.forEach((columns) => {
148
+ if (columns.length > 1 && mixin$1.stringWidth(columns[0]) > leftColumnWidth) leftColumnWidth = Math.min(Math.floor(this.width * .5), mixin$1.stringWidth(columns[0]));
149
+ });
150
+ rows.forEach((columns) => {
151
+ this.div(...columns.map((r, i) => {
152
+ return {
153
+ text: r.trim(),
154
+ padding: this.measurePadding(r),
155
+ width: i === 0 && columns.length > 1 ? leftColumnWidth : void 0
156
+ };
157
+ }));
158
+ });
159
+ return this.rows[this.rows.length - 1];
160
+ }
161
+ colFromString(text) {
162
+ return {
163
+ text,
164
+ padding: this.measurePadding(text)
165
+ };
166
+ }
167
+ measurePadding(str) {
168
+ const noAnsi = mixin$1.stripAnsi(str);
169
+ return [
170
+ 0,
171
+ noAnsi.match(/\s*$/)[0].length,
172
+ 0,
173
+ noAnsi.match(/^\s*/)[0].length
174
+ ];
175
+ }
176
+ toString() {
177
+ const lines = [];
178
+ this.rows.forEach((row) => {
179
+ this.rowToString(row, lines);
180
+ });
181
+ return lines.filter((line) => !line.hidden).map((line) => line.text).join("\n");
182
+ }
183
+ rowToString(row, lines) {
184
+ this.rasterize(row).forEach((rrow, r) => {
185
+ let str = "";
186
+ rrow.forEach((col, c) => {
187
+ const { width } = row[c];
188
+ const wrapWidth = this.negatePadding(row[c]);
189
+ let ts = col;
190
+ if (wrapWidth > mixin$1.stringWidth(col)) ts += " ".repeat(wrapWidth - mixin$1.stringWidth(col));
191
+ if (row[c].align && row[c].align !== "left" && this.wrap) {
192
+ const fn = align[row[c].align];
193
+ ts = fn(ts, wrapWidth);
194
+ if (mixin$1.stringWidth(ts) < wrapWidth) ts += " ".repeat((width || 0) - mixin$1.stringWidth(ts) - 1);
195
+ }
196
+ const padding = row[c].padding || [
197
+ 0,
198
+ 0,
199
+ 0,
200
+ 0
201
+ ];
202
+ if (padding[left]) str += " ".repeat(padding[left]);
203
+ str += addBorder(row[c], ts, "| ");
204
+ str += ts;
205
+ str += addBorder(row[c], ts, " |");
206
+ if (padding[right]) str += " ".repeat(padding[right]);
207
+ if (r === 0 && lines.length > 0) str = this.renderInline(str, lines[lines.length - 1]);
208
+ });
209
+ lines.push({
210
+ text: str.replace(/ +$/, ""),
211
+ span: row.span
212
+ });
213
+ });
214
+ return lines;
215
+ }
216
+ renderInline(source, previousLine) {
217
+ const match = source.match(/^ */);
218
+ const leadingWhitespace = match ? match[0].length : 0;
219
+ const target = previousLine.text;
220
+ const targetTextWidth = mixin$1.stringWidth(target.trimRight());
221
+ if (!previousLine.span) return source;
222
+ if (!this.wrap) {
223
+ previousLine.hidden = true;
224
+ return target + source;
225
+ }
226
+ if (leadingWhitespace < targetTextWidth) return source;
227
+ previousLine.hidden = true;
228
+ return target.trimRight() + " ".repeat(leadingWhitespace - targetTextWidth) + source.trimLeft();
229
+ }
230
+ rasterize(row) {
231
+ const rrows = [];
232
+ const widths = this.columnWidths(row);
233
+ let wrapped;
234
+ row.forEach((col, c) => {
235
+ col.width = widths[c];
236
+ if (this.wrap) wrapped = mixin$1.wrap(col.text, this.negatePadding(col), { hard: true }).split("\n");
237
+ else wrapped = col.text.split("\n");
238
+ if (col.border) {
239
+ wrapped.unshift("." + "-".repeat(this.negatePadding(col) + 2) + ".");
240
+ wrapped.push("'" + "-".repeat(this.negatePadding(col) + 2) + "'");
241
+ }
242
+ if (col.padding) {
243
+ wrapped.unshift(...new Array(col.padding[top] || 0).fill(""));
244
+ wrapped.push(...new Array(col.padding[bottom] || 0).fill(""));
245
+ }
246
+ wrapped.forEach((str, r) => {
247
+ if (!rrows[r]) rrows.push([]);
248
+ const rrow = rrows[r];
249
+ for (let i = 0; i < c; i++) if (rrow[i] === void 0) rrow.push("");
250
+ rrow.push(str);
251
+ });
252
+ });
253
+ return rrows;
254
+ }
255
+ negatePadding(col) {
256
+ let wrapWidth = col.width || 0;
257
+ if (col.padding) wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
258
+ if (col.border) wrapWidth -= 4;
259
+ return wrapWidth;
260
+ }
261
+ columnWidths(row) {
262
+ if (!this.wrap) return row.map((col) => {
263
+ return col.width || mixin$1.stringWidth(col.text);
264
+ });
265
+ let unset = row.length;
266
+ let remainingWidth = this.width;
267
+ const widths = row.map((col) => {
268
+ if (col.width) {
269
+ unset--;
270
+ remainingWidth -= col.width;
271
+ return col.width;
272
+ }
273
+ });
274
+ const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
275
+ return widths.map((w, i) => {
276
+ if (w === void 0) return Math.max(unsetWidth, _minWidth(row[i]));
277
+ return w;
278
+ });
279
+ }
280
+ };
281
+ function addBorder(col, ts, style) {
282
+ if (col.border) {
283
+ if (/[.']-+[.']/.test(ts)) return "";
284
+ if (ts.trim().length !== 0) return style;
285
+ return " ";
286
+ }
287
+ return "";
288
+ }
289
+ function _minWidth(col) {
290
+ const padding = col.padding || [];
291
+ const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
292
+ if (col.border) return minWidth + 4;
293
+ return minWidth;
294
+ }
295
+ function getWindowWidth() {
296
+ /* c8 ignore next 5: depends on terminal */
297
+ if (typeof process === "object" && process.stdout && process.stdout.columns) return process.stdout.columns;
298
+ return 80;
299
+ }
300
+ function alignRight(str, width) {
301
+ str = str.trim();
302
+ const strWidth = mixin$1.stringWidth(str);
303
+ if (strWidth < width) return " ".repeat(width - strWidth) + str;
304
+ return str;
305
+ }
306
+ function alignCenter(str, width) {
307
+ str = str.trim();
308
+ const strWidth = mixin$1.stringWidth(str);
309
+ /* c8 ignore next 3 */
310
+ if (strWidth >= width) return str;
311
+ return " ".repeat(width - strWidth >> 1) + str;
312
+ }
313
+ let mixin$1;
314
+ function cliui(opts, _mixin) {
315
+ mixin$1 = _mixin;
316
+ return new UI({
317
+ width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
318
+ wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
319
+ });
320
+ }
321
+
322
+ //#endregion
323
+ //#region node_modules/cliui/node_modules/strip-ansi/node_modules/ansi-regex/index.js
324
+ function ansiRegex({ onlyFirst = false } = {}) {
325
+ return new RegExp(`(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`, onlyFirst ? void 0 : "g");
326
+ }
327
+
328
+ //#endregion
329
+ //#region node_modules/cliui/node_modules/strip-ansi/index.js
330
+ const regex = ansiRegex();
331
+ function stripAnsi(string) {
332
+ if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
333
+ return string.replace(regex, "");
334
+ }
335
+
336
+ //#endregion
337
+ //#region node_modules/cliui/index.mjs
338
+ function ui(opts) {
339
+ return cliui(opts, {
340
+ stringWidth,
341
+ stripAnsi,
342
+ wrap: wrapAnsi
343
+ });
344
+ }
345
+
346
+ //#endregion
347
+ //#region node_modules/escalade/sync/index.mjs
348
+ function sync_default(start, callback) {
349
+ let dir = resolve(".", start);
350
+ let tmp;
351
+ if (!statSync(dir).isDirectory()) dir = dirname(dir);
352
+ while (true) {
353
+ tmp = callback(dir, readdirSync(dir));
354
+ if (tmp) return resolve(dir, tmp);
355
+ dir = dirname(tmp = dir);
356
+ if (tmp === dir) break;
357
+ }
358
+ }
359
+
360
+ //#endregion
361
+ //#region node_modules/yargs/node_modules/yargs-parser/build/lib/string-utils.js
362
+ /**
363
+ * @license
364
+ * Copyright (c) 2016, Contributors
365
+ * SPDX-License-Identifier: ISC
366
+ */
367
+ function camelCase(str) {
368
+ if (!(str !== str.toLowerCase() && str !== str.toUpperCase())) str = str.toLowerCase();
369
+ if (str.indexOf("-") === -1 && str.indexOf("_") === -1) return str;
370
+ else {
371
+ let camelcase = "";
372
+ let nextChrUpper = false;
373
+ const leadingHyphens = str.match(/^-+/);
374
+ for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
375
+ let chr = str.charAt(i);
376
+ if (nextChrUpper) {
377
+ nextChrUpper = false;
378
+ chr = chr.toUpperCase();
379
+ }
380
+ if (i !== 0 && (chr === "-" || chr === "_")) nextChrUpper = true;
381
+ else if (chr !== "-" && chr !== "_") camelcase += chr;
382
+ }
383
+ return camelcase;
384
+ }
385
+ }
386
+ function decamelize(str, joinString) {
387
+ const lowercase = str.toLowerCase();
388
+ joinString = joinString || "-";
389
+ let notCamelcase = "";
390
+ for (let i = 0; i < str.length; i++) {
391
+ const chrLower = lowercase.charAt(i);
392
+ const chrString = str.charAt(i);
393
+ if (chrLower !== chrString && i > 0) notCamelcase += `${joinString}${lowercase.charAt(i)}`;
394
+ else notCamelcase += chrString;
395
+ }
396
+ return notCamelcase;
397
+ }
398
+ function looksLikeNumber(x) {
399
+ if (x === null || x === void 0) return false;
400
+ if (typeof x === "number") return true;
401
+ if (/^0x[0-9a-f]+$/i.test(x)) return true;
402
+ if (/^0[^.]/.test(x)) return false;
403
+ return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
404
+ }
405
+
406
+ //#endregion
407
+ //#region node_modules/yargs/node_modules/yargs-parser/build/lib/tokenize-arg-string.js
408
+ /**
409
+ * @license
410
+ * Copyright (c) 2016, Contributors
411
+ * SPDX-License-Identifier: ISC
412
+ */
413
+ function tokenizeArgString(argString) {
414
+ if (Array.isArray(argString)) return argString.map((e) => typeof e !== "string" ? e + "" : e);
415
+ argString = argString.trim();
416
+ let i = 0;
417
+ let prevC = null;
418
+ let c = null;
419
+ let opening = null;
420
+ const args = [];
421
+ for (let ii = 0; ii < argString.length; ii++) {
422
+ prevC = c;
423
+ c = argString.charAt(ii);
424
+ if (c === " " && !opening) {
425
+ if (!(prevC === " ")) i++;
426
+ continue;
427
+ }
428
+ if (c === opening) opening = null;
429
+ else if ((c === "'" || c === "\"") && !opening) opening = c;
430
+ if (!args[i]) args[i] = "";
431
+ args[i] += c;
432
+ }
433
+ return args;
434
+ }
435
+
436
+ //#endregion
437
+ //#region node_modules/yargs/node_modules/yargs-parser/build/lib/yargs-parser-types.js
438
+ /**
439
+ * @license
440
+ * Copyright (c) 2016, Contributors
441
+ * SPDX-License-Identifier: ISC
442
+ */
443
+ var DefaultValuesForTypeKey;
444
+ (function(DefaultValuesForTypeKey$1) {
445
+ DefaultValuesForTypeKey$1["BOOLEAN"] = "boolean";
446
+ DefaultValuesForTypeKey$1["STRING"] = "string";
447
+ DefaultValuesForTypeKey$1["NUMBER"] = "number";
448
+ DefaultValuesForTypeKey$1["ARRAY"] = "array";
449
+ })(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
450
+
451
+ //#endregion
452
+ //#region node_modules/yargs/node_modules/yargs-parser/build/lib/yargs-parser.js
453
+ /**
454
+ * @license
455
+ * Copyright (c) 2016, Contributors
456
+ * SPDX-License-Identifier: ISC
457
+ */
458
+ let mixin;
459
+ var YargsParser = class {
460
+ constructor(_mixin) {
461
+ mixin = _mixin;
462
+ }
463
+ parse(argsInput, options) {
464
+ const opts = Object.assign({
465
+ alias: void 0,
466
+ array: void 0,
467
+ boolean: void 0,
468
+ config: void 0,
469
+ configObjects: void 0,
470
+ configuration: void 0,
471
+ coerce: void 0,
472
+ count: void 0,
473
+ default: void 0,
474
+ envPrefix: void 0,
475
+ narg: void 0,
476
+ normalize: void 0,
477
+ string: void 0,
478
+ number: void 0,
479
+ __: void 0,
480
+ key: void 0
481
+ }, options);
482
+ const args = tokenizeArgString(argsInput);
483
+ const inputIsString = typeof argsInput === "string";
484
+ const aliases = combineAliases(Object.assign(Object.create(null), opts.alias));
485
+ const configuration = Object.assign({
486
+ "boolean-negation": true,
487
+ "camel-case-expansion": true,
488
+ "combine-arrays": false,
489
+ "dot-notation": true,
490
+ "duplicate-arguments-array": true,
491
+ "flatten-duplicate-arrays": true,
492
+ "greedy-arrays": true,
493
+ "halt-at-non-option": false,
494
+ "nargs-eats-options": false,
495
+ "negation-prefix": "no-",
496
+ "parse-numbers": true,
497
+ "parse-positional-numbers": true,
498
+ "populate--": false,
499
+ "set-placeholder-key": false,
500
+ "short-option-groups": true,
501
+ "strip-aliased": false,
502
+ "strip-dashed": false,
503
+ "unknown-options-as-args": false
504
+ }, opts.configuration);
505
+ const defaults = Object.assign(Object.create(null), opts.default);
506
+ const configObjects = opts.configObjects || [];
507
+ const envPrefix = opts.envPrefix;
508
+ const notFlagsOption = configuration["populate--"];
509
+ const notFlagsArgv = notFlagsOption ? "--" : "_";
510
+ const newAliases = Object.create(null);
511
+ const defaulted = Object.create(null);
512
+ const __ = opts.__ || mixin.format;
513
+ const flags = {
514
+ aliases: Object.create(null),
515
+ arrays: Object.create(null),
516
+ bools: Object.create(null),
517
+ strings: Object.create(null),
518
+ numbers: Object.create(null),
519
+ counts: Object.create(null),
520
+ normalize: Object.create(null),
521
+ configs: Object.create(null),
522
+ nargs: Object.create(null),
523
+ coercions: Object.create(null),
524
+ keys: []
525
+ };
526
+ const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
527
+ const negatedBoolean = /* @__PURE__ */ new RegExp("^--" + configuration["negation-prefix"] + "(.+)");
528
+ [].concat(opts.array || []).filter(Boolean).forEach(function(opt) {
529
+ const key = typeof opt === "object" ? opt.key : opt;
530
+ const assignment = Object.keys(opt).map(function(key$1) {
531
+ return {
532
+ boolean: "bools",
533
+ string: "strings",
534
+ number: "numbers"
535
+ }[key$1];
536
+ }).filter(Boolean).pop();
537
+ if (assignment) flags[assignment][key] = true;
538
+ flags.arrays[key] = true;
539
+ flags.keys.push(key);
540
+ });
541
+ [].concat(opts.boolean || []).filter(Boolean).forEach(function(key) {
542
+ flags.bools[key] = true;
543
+ flags.keys.push(key);
544
+ });
545
+ [].concat(opts.string || []).filter(Boolean).forEach(function(key) {
546
+ flags.strings[key] = true;
547
+ flags.keys.push(key);
548
+ });
549
+ [].concat(opts.number || []).filter(Boolean).forEach(function(key) {
550
+ flags.numbers[key] = true;
551
+ flags.keys.push(key);
552
+ });
553
+ [].concat(opts.count || []).filter(Boolean).forEach(function(key) {
554
+ flags.counts[key] = true;
555
+ flags.keys.push(key);
556
+ });
557
+ [].concat(opts.normalize || []).filter(Boolean).forEach(function(key) {
558
+ flags.normalize[key] = true;
559
+ flags.keys.push(key);
560
+ });
561
+ if (typeof opts.narg === "object") Object.entries(opts.narg).forEach(([key, value]) => {
562
+ if (typeof value === "number") {
563
+ flags.nargs[key] = value;
564
+ flags.keys.push(key);
565
+ }
566
+ });
567
+ if (typeof opts.coerce === "object") Object.entries(opts.coerce).forEach(([key, value]) => {
568
+ if (typeof value === "function") {
569
+ flags.coercions[key] = value;
570
+ flags.keys.push(key);
571
+ }
572
+ });
573
+ if (typeof opts.config !== "undefined") {
574
+ if (Array.isArray(opts.config) || typeof opts.config === "string") [].concat(opts.config).filter(Boolean).forEach(function(key) {
575
+ flags.configs[key] = true;
576
+ });
577
+ else if (typeof opts.config === "object") Object.entries(opts.config).forEach(([key, value]) => {
578
+ if (typeof value === "boolean" || typeof value === "function") flags.configs[key] = value;
579
+ });
580
+ }
581
+ extendAliases(opts.key, aliases, opts.default, flags.arrays);
582
+ Object.keys(defaults).forEach(function(key) {
583
+ (flags.aliases[key] || []).forEach(function(alias) {
584
+ defaults[alias] = defaults[key];
585
+ });
586
+ });
587
+ let error = null;
588
+ checkConfiguration();
589
+ let notFlags = [];
590
+ const argv = Object.assign(Object.create(null), { _: [] });
591
+ const argvReturn = {};
592
+ for (let i = 0; i < args.length; i++) {
593
+ const arg = args[i];
594
+ const truncatedArg = arg.replace(/^-{3,}/, "---");
595
+ let broken;
596
+ let key;
597
+ let letters;
598
+ let m;
599
+ let next;
600
+ let value;
601
+ if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) pushPositional(arg);
602
+ else if (truncatedArg.match(/^---+(=|$)/)) {
603
+ pushPositional(arg);
604
+ continue;
605
+ } else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
606
+ m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
607
+ if (m !== null && Array.isArray(m) && m.length >= 3) if (checkAllAliases(m[1], flags.arrays)) i = eatArray(i, m[1], args, m[2]);
608
+ else if (checkAllAliases(m[1], flags.nargs) !== false) i = eatNargs(i, m[1], args, m[2]);
609
+ else setArg(m[1], m[2], true);
610
+ } else if (arg.match(negatedBoolean) && configuration["boolean-negation"]) {
611
+ m = arg.match(negatedBoolean);
612
+ if (m !== null && Array.isArray(m) && m.length >= 2) {
613
+ key = m[1];
614
+ setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false);
615
+ }
616
+ } else if (arg.match(/^--.+/) || !configuration["short-option-groups"] && arg.match(/^-[^-]+/)) {
617
+ m = arg.match(/^--?(.+)/);
618
+ if (m !== null && Array.isArray(m) && m.length >= 2) {
619
+ key = m[1];
620
+ if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args);
621
+ else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args);
622
+ else {
623
+ next = args[i + 1];
624
+ if (next !== void 0 && (!next.match(/^-/) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
625
+ setArg(key, next);
626
+ i++;
627
+ } else if (/^(true|false)$/.test(next)) {
628
+ setArg(key, next);
629
+ i++;
630
+ } else setArg(key, defaultValue(key));
631
+ }
632
+ }
633
+ } else if (arg.match(/^-.\..+=/)) {
634
+ m = arg.match(/^-([^=]+)=([\s\S]*)$/);
635
+ if (m !== null && Array.isArray(m) && m.length >= 3) setArg(m[1], m[2]);
636
+ } else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
637
+ next = args[i + 1];
638
+ m = arg.match(/^-(.\..+)/);
639
+ if (m !== null && Array.isArray(m) && m.length >= 2) {
640
+ key = m[1];
641
+ if (next !== void 0 && !next.match(/^-/) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
642
+ setArg(key, next);
643
+ i++;
644
+ } else setArg(key, defaultValue(key));
645
+ }
646
+ } else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
647
+ letters = arg.slice(1, -1).split("");
648
+ broken = false;
649
+ for (let j = 0; j < letters.length; j++) {
650
+ next = arg.slice(j + 2);
651
+ if (letters[j + 1] && letters[j + 1] === "=") {
652
+ value = arg.slice(j + 3);
653
+ key = letters[j];
654
+ if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args, value);
655
+ else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args, value);
656
+ else setArg(key, value);
657
+ broken = true;
658
+ break;
659
+ }
660
+ if (next === "-") {
661
+ setArg(letters[j], next);
662
+ continue;
663
+ }
664
+ if (/[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) && checkAllAliases(next, flags.bools) === false) {
665
+ setArg(letters[j], next);
666
+ broken = true;
667
+ break;
668
+ }
669
+ if (letters[j + 1] && letters[j + 1].match(/\W/)) {
670
+ setArg(letters[j], next);
671
+ broken = true;
672
+ break;
673
+ } else setArg(letters[j], defaultValue(letters[j]));
674
+ }
675
+ key = arg.slice(-1)[0];
676
+ if (!broken && key !== "-") if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args);
677
+ else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args);
678
+ else {
679
+ next = args[i + 1];
680
+ if (next !== void 0 && (!/^(-|--)[^-]/.test(next) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
681
+ setArg(key, next);
682
+ i++;
683
+ } else if (/^(true|false)$/.test(next)) {
684
+ setArg(key, next);
685
+ i++;
686
+ } else setArg(key, defaultValue(key));
687
+ }
688
+ } else if (arg.match(/^-[0-9]$/) && arg.match(negative) && checkAllAliases(arg.slice(1), flags.bools)) {
689
+ key = arg.slice(1);
690
+ setArg(key, defaultValue(key));
691
+ } else if (arg === "--") {
692
+ notFlags = args.slice(i + 1);
693
+ break;
694
+ } else if (configuration["halt-at-non-option"]) {
695
+ notFlags = args.slice(i);
696
+ break;
697
+ } else pushPositional(arg);
698
+ }
699
+ applyEnvVars(argv, true);
700
+ applyEnvVars(argv, false);
701
+ setConfig(argv);
702
+ setConfigObjects();
703
+ applyDefaultsAndAliases(argv, flags.aliases, defaults, true);
704
+ applyCoercions(argv);
705
+ if (configuration["set-placeholder-key"]) setPlaceholderKeys(argv);
706
+ Object.keys(flags.counts).forEach(function(key) {
707
+ if (!hasKey(argv, key.split("."))) setArg(key, 0);
708
+ });
709
+ if (notFlagsOption && notFlags.length) argv[notFlagsArgv] = [];
710
+ notFlags.forEach(function(key) {
711
+ argv[notFlagsArgv].push(key);
712
+ });
713
+ if (configuration["camel-case-expansion"] && configuration["strip-dashed"]) Object.keys(argv).filter((key) => key !== "--" && key.includes("-")).forEach((key) => {
714
+ delete argv[key];
715
+ });
716
+ if (configuration["strip-aliased"]) [].concat(...Object.keys(aliases).map((k) => aliases[k])).forEach((alias) => {
717
+ if (configuration["camel-case-expansion"] && alias.includes("-")) delete argv[alias.split(".").map((prop) => camelCase(prop)).join(".")];
718
+ delete argv[alias];
719
+ });
720
+ function pushPositional(arg) {
721
+ const maybeCoercedNumber = maybeCoerceNumber("_", arg);
722
+ if (typeof maybeCoercedNumber === "string" || typeof maybeCoercedNumber === "number") argv._.push(maybeCoercedNumber);
723
+ }
724
+ function eatNargs(i, key, args$1, argAfterEqualSign) {
725
+ let ii;
726
+ let toEat = checkAllAliases(key, flags.nargs);
727
+ toEat = typeof toEat !== "number" || isNaN(toEat) ? 1 : toEat;
728
+ if (toEat === 0) {
729
+ if (!isUndefined(argAfterEqualSign)) error = Error(__("Argument unexpected for: %s", key));
730
+ setArg(key, defaultValue(key));
731
+ return i;
732
+ }
733
+ let available = isUndefined(argAfterEqualSign) ? 0 : 1;
734
+ if (configuration["nargs-eats-options"]) {
735
+ if (args$1.length - (i + 1) + available < toEat) error = Error(__("Not enough arguments following: %s", key));
736
+ available = toEat;
737
+ } else {
738
+ for (ii = i + 1; ii < args$1.length; ii++) if (!args$1[ii].match(/^-[^0-9]/) || args$1[ii].match(negative) || isUnknownOptionAsArg(args$1[ii])) available++;
739
+ else break;
740
+ if (available < toEat) error = Error(__("Not enough arguments following: %s", key));
741
+ }
742
+ let consumed = Math.min(available, toEat);
743
+ if (!isUndefined(argAfterEqualSign) && consumed > 0) {
744
+ setArg(key, argAfterEqualSign);
745
+ consumed--;
746
+ }
747
+ for (ii = i + 1; ii < consumed + i + 1; ii++) setArg(key, args$1[ii]);
748
+ return i + consumed;
749
+ }
750
+ function eatArray(i, key, args$1, argAfterEqualSign) {
751
+ let argsToSet = [];
752
+ let next = argAfterEqualSign || args$1[i + 1];
753
+ const nargsCount = checkAllAliases(key, flags.nargs);
754
+ if (checkAllAliases(key, flags.bools) && !/^(true|false)$/.test(next)) argsToSet.push(true);
755
+ else if (isUndefined(next) || isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) {
756
+ if (defaults[key] !== void 0) {
757
+ const defVal = defaults[key];
758
+ argsToSet = Array.isArray(defVal) ? defVal : [defVal];
759
+ }
760
+ } else {
761
+ if (!isUndefined(argAfterEqualSign)) argsToSet.push(processValue(key, argAfterEqualSign, true));
762
+ for (let ii = i + 1; ii < args$1.length; ii++) {
763
+ if (!configuration["greedy-arrays"] && argsToSet.length > 0 || nargsCount && typeof nargsCount === "number" && argsToSet.length >= nargsCount) break;
764
+ next = args$1[ii];
765
+ if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) break;
766
+ i = ii;
767
+ argsToSet.push(processValue(key, next, inputIsString));
768
+ }
769
+ }
770
+ if (typeof nargsCount === "number" && (nargsCount && argsToSet.length < nargsCount || isNaN(nargsCount) && argsToSet.length === 0)) error = Error(__("Not enough arguments following: %s", key));
771
+ setArg(key, argsToSet);
772
+ return i;
773
+ }
774
+ function setArg(key, val, shouldStripQuotes = inputIsString) {
775
+ if (/-/.test(key) && configuration["camel-case-expansion"]) addNewAlias(key, key.split(".").map(function(prop) {
776
+ return camelCase(prop);
777
+ }).join("."));
778
+ const value = processValue(key, val, shouldStripQuotes);
779
+ const splitKey = key.split(".");
780
+ setKey(argv, splitKey, value);
781
+ if (flags.aliases[key]) flags.aliases[key].forEach(function(x) {
782
+ setKey(argv, x.split("."), value);
783
+ });
784
+ if (splitKey.length > 1 && configuration["dot-notation"]) (flags.aliases[splitKey[0]] || []).forEach(function(x) {
785
+ let keyProperties = x.split(".");
786
+ const a = [].concat(splitKey);
787
+ a.shift();
788
+ keyProperties = keyProperties.concat(a);
789
+ if (!(flags.aliases[key] || []).includes(keyProperties.join("."))) setKey(argv, keyProperties, value);
790
+ });
791
+ if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) [key].concat(flags.aliases[key] || []).forEach(function(key$1) {
792
+ Object.defineProperty(argvReturn, key$1, {
793
+ enumerable: true,
794
+ get() {
795
+ return val;
796
+ },
797
+ set(value$1) {
798
+ val = typeof value$1 === "string" ? mixin.normalize(value$1) : value$1;
799
+ }
800
+ });
801
+ });
802
+ }
803
+ function addNewAlias(key, alias) {
804
+ if (!(flags.aliases[key] && flags.aliases[key].length)) {
805
+ flags.aliases[key] = [alias];
806
+ newAliases[alias] = true;
807
+ }
808
+ if (!(flags.aliases[alias] && flags.aliases[alias].length)) addNewAlias(alias, key);
809
+ }
810
+ function processValue(key, val, shouldStripQuotes) {
811
+ if (shouldStripQuotes) val = stripQuotes(val);
812
+ if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
813
+ if (typeof val === "string") val = val === "true";
814
+ }
815
+ let value = Array.isArray(val) ? val.map(function(v) {
816
+ return maybeCoerceNumber(key, v);
817
+ }) : maybeCoerceNumber(key, val);
818
+ if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === "boolean")) value = increment();
819
+ if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) if (Array.isArray(val)) value = val.map((val$1) => {
820
+ return mixin.normalize(val$1);
821
+ });
822
+ else value = mixin.normalize(val);
823
+ return value;
824
+ }
825
+ function maybeCoerceNumber(key, value) {
826
+ if (!configuration["parse-positional-numbers"] && key === "_") return value;
827
+ if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) {
828
+ if (looksLikeNumber(value) && configuration["parse-numbers"] && Number.isSafeInteger(Math.floor(parseFloat(`${value}`))) || !isUndefined(value) && checkAllAliases(key, flags.numbers)) value = Number(value);
829
+ }
830
+ return value;
831
+ }
832
+ function setConfig(argv$1) {
833
+ const configLookup = Object.create(null);
834
+ applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
835
+ Object.keys(flags.configs).forEach(function(configKey) {
836
+ const configPath = argv$1[configKey] || configLookup[configKey];
837
+ if (configPath) try {
838
+ let config$1 = null;
839
+ const resolvedConfigPath = mixin.resolve(mixin.cwd(), configPath);
840
+ const resolveConfig = flags.configs[configKey];
841
+ if (typeof resolveConfig === "function") {
842
+ try {
843
+ config$1 = resolveConfig(resolvedConfigPath);
844
+ } catch (e) {
845
+ config$1 = e;
846
+ }
847
+ if (config$1 instanceof Error) {
848
+ error = config$1;
849
+ return;
850
+ }
851
+ } else config$1 = mixin.require(resolvedConfigPath);
852
+ setConfigObject(config$1);
853
+ } catch (ex) {
854
+ if (ex.name === "PermissionDenied") error = ex;
855
+ else if (argv$1[configKey]) error = Error(__("Invalid JSON config file: %s", configPath));
856
+ }
857
+ });
858
+ }
859
+ function setConfigObject(config$1, prev) {
860
+ Object.keys(config$1).forEach(function(key) {
861
+ const value = config$1[key];
862
+ const fullKey = prev ? prev + "." + key : key;
863
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && configuration["dot-notation"]) setConfigObject(value, fullKey);
864
+ else if (!hasKey(argv, fullKey.split(".")) || checkAllAliases(fullKey, flags.arrays) && configuration["combine-arrays"]) setArg(fullKey, value);
865
+ });
866
+ }
867
+ function setConfigObjects() {
868
+ if (typeof configObjects !== "undefined") configObjects.forEach(function(configObject) {
869
+ setConfigObject(configObject);
870
+ });
871
+ }
872
+ function applyEnvVars(argv$1, configOnly) {
873
+ if (typeof envPrefix === "undefined") return;
874
+ const prefix = typeof envPrefix === "string" ? envPrefix : "";
875
+ const env$1 = mixin.env();
876
+ Object.keys(env$1).forEach(function(envVar) {
877
+ if (prefix === "" || envVar.lastIndexOf(prefix, 0) === 0) {
878
+ const keys = envVar.split("__").map(function(key, i) {
879
+ if (i === 0) key = key.substring(prefix.length);
880
+ return camelCase(key);
881
+ });
882
+ if ((configOnly && flags.configs[keys.join(".")] || !configOnly) && !hasKey(argv$1, keys)) setArg(keys.join("."), env$1[envVar]);
883
+ }
884
+ });
885
+ }
886
+ function applyCoercions(argv$1) {
887
+ let coerce;
888
+ const applied = /* @__PURE__ */ new Set();
889
+ Object.keys(argv$1).forEach(function(key) {
890
+ if (!applied.has(key)) {
891
+ coerce = checkAllAliases(key, flags.coercions);
892
+ if (typeof coerce === "function") try {
893
+ const value = maybeCoerceNumber(key, coerce(argv$1[key]));
894
+ [].concat(flags.aliases[key] || [], key).forEach((ali) => {
895
+ applied.add(ali);
896
+ argv$1[ali] = value;
897
+ });
898
+ } catch (err) {
899
+ error = err;
900
+ }
901
+ }
902
+ });
903
+ }
904
+ function setPlaceholderKeys(argv$1) {
905
+ flags.keys.forEach((key) => {
906
+ if (~key.indexOf(".")) return;
907
+ if (typeof argv$1[key] === "undefined") argv$1[key] = void 0;
908
+ });
909
+ return argv$1;
910
+ }
911
+ function applyDefaultsAndAliases(obj, aliases$1, defaults$1, canLog = false) {
912
+ Object.keys(defaults$1).forEach(function(key) {
913
+ if (!hasKey(obj, key.split("."))) {
914
+ setKey(obj, key.split("."), defaults$1[key]);
915
+ if (canLog) defaulted[key] = true;
916
+ (aliases$1[key] || []).forEach(function(x) {
917
+ if (hasKey(obj, x.split("."))) return;
918
+ setKey(obj, x.split("."), defaults$1[key]);
919
+ });
920
+ }
921
+ });
922
+ }
923
+ function hasKey(obj, keys) {
924
+ let o = obj;
925
+ if (!configuration["dot-notation"]) keys = [keys.join(".")];
926
+ keys.slice(0, -1).forEach(function(key$1) {
927
+ o = o[key$1] || {};
928
+ });
929
+ const key = keys[keys.length - 1];
930
+ if (typeof o !== "object") return false;
931
+ else return key in o;
932
+ }
933
+ function setKey(obj, keys, value) {
934
+ let o = obj;
935
+ if (!configuration["dot-notation"]) keys = [keys.join(".")];
936
+ keys.slice(0, -1).forEach(function(key$1) {
937
+ key$1 = sanitizeKey(key$1);
938
+ if (typeof o === "object" && o[key$1] === void 0) o[key$1] = {};
939
+ if (typeof o[key$1] !== "object" || Array.isArray(o[key$1])) {
940
+ if (Array.isArray(o[key$1])) o[key$1].push({});
941
+ else o[key$1] = [o[key$1], {}];
942
+ o = o[key$1][o[key$1].length - 1];
943
+ } else o = o[key$1];
944
+ });
945
+ const key = sanitizeKey(keys[keys.length - 1]);
946
+ const isTypeArray = checkAllAliases(keys.join("."), flags.arrays);
947
+ const isValueArray = Array.isArray(value);
948
+ let duplicate = configuration["duplicate-arguments-array"];
949
+ if (!duplicate && checkAllAliases(key, flags.nargs)) {
950
+ duplicate = true;
951
+ if (!isUndefined(o[key]) && flags.nargs[key] === 1 || Array.isArray(o[key]) && o[key].length === flags.nargs[key]) o[key] = void 0;
952
+ }
953
+ if (value === increment()) o[key] = increment(o[key]);
954
+ 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]);
955
+ else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) o[key] = value;
956
+ else o[key] = o[key].concat([value]);
957
+ else if (o[key] === void 0 && isTypeArray) o[key] = isValueArray ? value : [value];
958
+ else if (duplicate && !(o[key] === void 0 || checkAllAliases(key, flags.counts) || checkAllAliases(key, flags.bools))) o[key] = [o[key], value];
959
+ else o[key] = value;
960
+ }
961
+ function extendAliases(...args$1) {
962
+ args$1.forEach(function(obj) {
963
+ Object.keys(obj || {}).forEach(function(key) {
964
+ if (flags.aliases[key]) return;
965
+ flags.aliases[key] = [].concat(aliases[key] || []);
966
+ flags.aliases[key].concat(key).forEach(function(x) {
967
+ if (/-/.test(x) && configuration["camel-case-expansion"]) {
968
+ const c = camelCase(x);
969
+ if (c !== key && flags.aliases[key].indexOf(c) === -1) {
970
+ flags.aliases[key].push(c);
971
+ newAliases[c] = true;
972
+ }
973
+ }
974
+ });
975
+ flags.aliases[key].concat(key).forEach(function(x) {
976
+ if (x.length > 1 && /[A-Z]/.test(x) && configuration["camel-case-expansion"]) {
977
+ const c = decamelize(x, "-");
978
+ if (c !== key && flags.aliases[key].indexOf(c) === -1) {
979
+ flags.aliases[key].push(c);
980
+ newAliases[c] = true;
981
+ }
982
+ }
983
+ });
984
+ flags.aliases[key].forEach(function(x) {
985
+ flags.aliases[x] = [key].concat(flags.aliases[key].filter(function(y) {
986
+ return x !== y;
987
+ }));
988
+ });
989
+ });
990
+ });
991
+ }
992
+ function checkAllAliases(key, flag) {
993
+ const toCheck = [].concat(flags.aliases[key] || [], key);
994
+ const keys = Object.keys(flag);
995
+ const setAlias = toCheck.find((key$1) => keys.includes(key$1));
996
+ return setAlias ? flag[setAlias] : false;
997
+ }
998
+ function hasAnyFlag(key) {
999
+ const flagsKeys = Object.keys(flags);
1000
+ return [].concat(flagsKeys.map((k) => flags[k])).some(function(flag) {
1001
+ return Array.isArray(flag) ? flag.includes(key) : flag[key];
1002
+ });
1003
+ }
1004
+ function hasFlagsMatching(arg, ...patterns) {
1005
+ return [].concat(...patterns).some(function(pattern) {
1006
+ const match = arg.match(pattern);
1007
+ return match && hasAnyFlag(match[1]);
1008
+ });
1009
+ }
1010
+ function hasAllShortFlags(arg) {
1011
+ if (arg.match(negative) || !arg.match(/^-[^-]+/)) return false;
1012
+ let hasAllFlags = true;
1013
+ let next;
1014
+ const letters = arg.slice(1).split("");
1015
+ for (let j = 0; j < letters.length; j++) {
1016
+ next = arg.slice(j + 2);
1017
+ if (!hasAnyFlag(letters[j])) {
1018
+ hasAllFlags = false;
1019
+ break;
1020
+ }
1021
+ 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;
1022
+ }
1023
+ return hasAllFlags;
1024
+ }
1025
+ function isUnknownOptionAsArg(arg) {
1026
+ return configuration["unknown-options-as-args"] && isUnknownOption(arg);
1027
+ }
1028
+ function isUnknownOption(arg) {
1029
+ arg = arg.replace(/^-{3,}/, "--");
1030
+ if (arg.match(negative)) return false;
1031
+ if (hasAllShortFlags(arg)) return false;
1032
+ return !hasFlagsMatching(arg, /^-+([^=]+?)=[\s\S]*$/, negatedBoolean, /^-+([^=]+?)$/, /^-+([^=]+?)-$/, /^-+([^=]+?\d+)$/, /^-+([^=]+?)\W+.*$/);
1033
+ }
1034
+ function defaultValue(key) {
1035
+ if (!checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts) && `${key}` in defaults) return defaults[key];
1036
+ else return defaultForType(guessType$1(key));
1037
+ }
1038
+ function defaultForType(type) {
1039
+ return {
1040
+ [DefaultValuesForTypeKey.BOOLEAN]: true,
1041
+ [DefaultValuesForTypeKey.STRING]: "",
1042
+ [DefaultValuesForTypeKey.NUMBER]: void 0,
1043
+ [DefaultValuesForTypeKey.ARRAY]: []
1044
+ }[type];
1045
+ }
1046
+ function guessType$1(key) {
1047
+ let type = DefaultValuesForTypeKey.BOOLEAN;
1048
+ if (checkAllAliases(key, flags.strings)) type = DefaultValuesForTypeKey.STRING;
1049
+ else if (checkAllAliases(key, flags.numbers)) type = DefaultValuesForTypeKey.NUMBER;
1050
+ else if (checkAllAliases(key, flags.bools)) type = DefaultValuesForTypeKey.BOOLEAN;
1051
+ else if (checkAllAliases(key, flags.arrays)) type = DefaultValuesForTypeKey.ARRAY;
1052
+ return type;
1053
+ }
1054
+ function isUndefined(num) {
1055
+ return num === void 0;
1056
+ }
1057
+ function checkConfiguration() {
1058
+ Object.keys(flags.counts).find((key) => {
1059
+ if (checkAllAliases(key, flags.arrays)) {
1060
+ error = Error(__("Invalid configuration: %s, opts.count excludes opts.array.", key));
1061
+ return true;
1062
+ } else if (checkAllAliases(key, flags.nargs)) {
1063
+ error = Error(__("Invalid configuration: %s, opts.count excludes opts.narg.", key));
1064
+ return true;
1065
+ }
1066
+ return false;
1067
+ });
1068
+ }
1069
+ return {
1070
+ aliases: Object.assign({}, flags.aliases),
1071
+ argv: Object.assign(argvReturn, argv),
1072
+ configuration,
1073
+ defaulted: Object.assign({}, defaulted),
1074
+ error,
1075
+ newAliases: Object.assign({}, newAliases)
1076
+ };
1077
+ }
1078
+ };
1079
+ function combineAliases(aliases) {
1080
+ const aliasArrays = [];
1081
+ const combined = Object.create(null);
1082
+ let change = true;
1083
+ Object.keys(aliases).forEach(function(key) {
1084
+ aliasArrays.push([].concat(aliases[key], key));
1085
+ });
1086
+ while (change) {
1087
+ change = false;
1088
+ for (let i = 0; i < aliasArrays.length; i++) for (let ii = i + 1; ii < aliasArrays.length; ii++) if (aliasArrays[i].filter(function(v) {
1089
+ return aliasArrays[ii].indexOf(v) !== -1;
1090
+ }).length) {
1091
+ aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii]);
1092
+ aliasArrays.splice(ii, 1);
1093
+ change = true;
1094
+ break;
1095
+ }
1096
+ }
1097
+ aliasArrays.forEach(function(aliasArray) {
1098
+ aliasArray = aliasArray.filter(function(v, i, self) {
1099
+ return self.indexOf(v) === i;
1100
+ });
1101
+ const lastAlias = aliasArray.pop();
1102
+ if (lastAlias !== void 0 && typeof lastAlias === "string") combined[lastAlias] = aliasArray;
1103
+ });
1104
+ return combined;
1105
+ }
1106
+ function increment(orig) {
1107
+ return orig !== void 0 ? orig + 1 : 1;
1108
+ }
1109
+ function sanitizeKey(key) {
1110
+ if (key === "__proto__") return "___proto___";
1111
+ return key;
1112
+ }
1113
+ function stripQuotes(val) {
1114
+ return typeof val === "string" && (val[0] === "'" || val[0] === "\"") && val[val.length - 1] === val[0] ? val.substring(1, val.length - 1) : val;
1115
+ }
1116
+
1117
+ //#endregion
1118
+ //#region node_modules/yargs/node_modules/yargs-parser/build/lib/index.js
1119
+ /**
1120
+ * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
1121
+ *
1122
+ * @license
1123
+ * Copyright (c) 2016, Contributors
1124
+ * SPDX-License-Identifier: ISC
1125
+ */
1126
+ var _a, _b, _c;
1127
+ const minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 20;
1128
+ 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);
1129
+ if (nodeVersion) {
1130
+ 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`);
1131
+ }
1132
+ const env = process ? process.env : {};
1133
+ const require$1 = createRequire ? createRequire(import.meta.url) : void 0;
1134
+ const parser = new YargsParser({
1135
+ cwd: process.cwd,
1136
+ env: () => {
1137
+ return env;
1138
+ },
1139
+ format,
1140
+ normalize,
1141
+ resolve,
1142
+ require: (path$1) => {
1143
+ if (typeof require$1 !== "undefined") return require$1(path$1);
1144
+ else if (path$1.match(/\.json$/)) return JSON.parse(readFileSync(path$1, "utf8"));
1145
+ else throw Error("only .json config files are supported in ESM");
1146
+ }
1147
+ });
1148
+ const yargsParser = function Parser(args, opts) {
1149
+ return parser.parse(args.slice(), opts).argv;
1150
+ };
1151
+ yargsParser.detailed = function(args, opts) {
1152
+ return parser.parse(args.slice(), opts);
1153
+ };
1154
+ yargsParser.camelCase = camelCase;
1155
+ yargsParser.decamelize = decamelize;
1156
+ yargsParser.looksLikeNumber = looksLikeNumber;
1157
+ var lib_default = yargsParser;
1158
+
1159
+ //#endregion
1160
+ //#region node_modules/yargs/build/lib/utils/process-argv.js
1161
+ function getProcessArgvBinIndex() {
1162
+ if (isBundledElectronApp()) return 0;
1163
+ return 1;
1164
+ }
1165
+ function isBundledElectronApp() {
1166
+ return isElectronApp() && !process.defaultApp;
1167
+ }
1168
+ function isElectronApp() {
1169
+ return !!process.versions.electron;
1170
+ }
1171
+ function getProcessArgvBin() {
1172
+ return process.argv[getProcessArgvBinIndex()];
1173
+ }
1174
+
1175
+ //#endregion
1176
+ //#region node_modules/y18n/build/lib/platform-shims/node.js
1177
+ var node_default = {
1178
+ fs: {
1179
+ readFileSync,
1180
+ writeFile
1181
+ },
1182
+ format,
1183
+ resolve,
1184
+ exists: (file) => {
1185
+ try {
1186
+ return statSync(file).isFile();
1187
+ } catch (err) {
1188
+ return false;
1189
+ }
1190
+ }
1191
+ };
1192
+
1193
+ //#endregion
1194
+ //#region node_modules/y18n/build/lib/index.js
1195
+ let shim$1;
1196
+ var Y18N = class {
1197
+ constructor(opts) {
1198
+ opts = opts || {};
1199
+ this.directory = opts.directory || "./locales";
1200
+ this.updateFiles = typeof opts.updateFiles === "boolean" ? opts.updateFiles : true;
1201
+ this.locale = opts.locale || "en";
1202
+ this.fallbackToLanguage = typeof opts.fallbackToLanguage === "boolean" ? opts.fallbackToLanguage : true;
1203
+ this.cache = Object.create(null);
1204
+ this.writeQueue = [];
1205
+ }
1206
+ __(...args) {
1207
+ if (typeof arguments[0] !== "string") return this._taggedLiteral(arguments[0], ...arguments);
1208
+ const str = args.shift();
1209
+ let cb = function() {};
1210
+ if (typeof args[args.length - 1] === "function") cb = args.pop();
1211
+ cb = cb || function() {};
1212
+ if (!this.cache[this.locale]) this._readLocaleFile();
1213
+ if (!this.cache[this.locale][str] && this.updateFiles) {
1214
+ this.cache[this.locale][str] = str;
1215
+ this._enqueueWrite({
1216
+ directory: this.directory,
1217
+ locale: this.locale,
1218
+ cb
1219
+ });
1220
+ } else cb();
1221
+ return shim$1.format.apply(shim$1.format, [this.cache[this.locale][str] || str].concat(args));
1222
+ }
1223
+ __n() {
1224
+ const args = Array.prototype.slice.call(arguments);
1225
+ const singular = args.shift();
1226
+ const plural = args.shift();
1227
+ const quantity = args.shift();
1228
+ let cb = function() {};
1229
+ if (typeof args[args.length - 1] === "function") cb = args.pop();
1230
+ if (!this.cache[this.locale]) this._readLocaleFile();
1231
+ let str = quantity === 1 ? singular : plural;
1232
+ if (this.cache[this.locale][singular]) str = this.cache[this.locale][singular][quantity === 1 ? "one" : "other"];
1233
+ if (!this.cache[this.locale][singular] && this.updateFiles) {
1234
+ this.cache[this.locale][singular] = {
1235
+ one: singular,
1236
+ other: plural
1237
+ };
1238
+ this._enqueueWrite({
1239
+ directory: this.directory,
1240
+ locale: this.locale,
1241
+ cb
1242
+ });
1243
+ } else cb();
1244
+ const values = [str];
1245
+ if (~str.indexOf("%d")) values.push(quantity);
1246
+ return shim$1.format.apply(shim$1.format, values.concat(args));
1247
+ }
1248
+ setLocale(locale) {
1249
+ this.locale = locale;
1250
+ }
1251
+ getLocale() {
1252
+ return this.locale;
1253
+ }
1254
+ updateLocale(obj) {
1255
+ if (!this.cache[this.locale]) this._readLocaleFile();
1256
+ for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) this.cache[this.locale][key] = obj[key];
1257
+ }
1258
+ _taggedLiteral(parts, ...args) {
1259
+ let str = "";
1260
+ parts.forEach(function(part, i) {
1261
+ const arg = args[i + 1];
1262
+ str += part;
1263
+ if (typeof arg !== "undefined") str += "%s";
1264
+ });
1265
+ return this.__.apply(this, [str].concat([].slice.call(args, 1)));
1266
+ }
1267
+ _enqueueWrite(work) {
1268
+ this.writeQueue.push(work);
1269
+ if (this.writeQueue.length === 1) this._processWriteQueue();
1270
+ }
1271
+ _processWriteQueue() {
1272
+ const _this = this;
1273
+ const work = this.writeQueue[0];
1274
+ const directory = work.directory;
1275
+ const locale = work.locale;
1276
+ const cb = work.cb;
1277
+ const languageFile = this._resolveLocaleFile(directory, locale);
1278
+ const serializedLocale = JSON.stringify(this.cache[locale], null, 2);
1279
+ shim$1.fs.writeFile(languageFile, serializedLocale, "utf-8", function(err) {
1280
+ _this.writeQueue.shift();
1281
+ if (_this.writeQueue.length > 0) _this._processWriteQueue();
1282
+ cb(err);
1283
+ });
1284
+ }
1285
+ _readLocaleFile() {
1286
+ let localeLookup = {};
1287
+ const languageFile = this._resolveLocaleFile(this.directory, this.locale);
1288
+ try {
1289
+ if (shim$1.fs.readFileSync) localeLookup = JSON.parse(shim$1.fs.readFileSync(languageFile, "utf-8"));
1290
+ } catch (err) {
1291
+ if (err instanceof SyntaxError) err.message = "syntax error in " + languageFile;
1292
+ if (err.code === "ENOENT") localeLookup = {};
1293
+ else throw err;
1294
+ }
1295
+ this.cache[this.locale] = localeLookup;
1296
+ }
1297
+ _resolveLocaleFile(directory, locale) {
1298
+ let file = shim$1.resolve(directory, "./", locale + ".json");
1299
+ if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf("_")) {
1300
+ const languageFile = shim$1.resolve(directory, "./", locale.split("_")[0] + ".json");
1301
+ if (this._fileExistsSync(languageFile)) file = languageFile;
1302
+ }
1303
+ return file;
1304
+ }
1305
+ _fileExistsSync(file) {
1306
+ return shim$1.exists(file);
1307
+ }
1308
+ };
1309
+ function y18n$1(opts, _shim) {
1310
+ shim$1 = _shim;
1311
+ const y18n$2 = new Y18N(opts);
1312
+ return {
1313
+ __: y18n$2.__.bind(y18n$2),
1314
+ __n: y18n$2.__n.bind(y18n$2),
1315
+ setLocale: y18n$2.setLocale.bind(y18n$2),
1316
+ getLocale: y18n$2.getLocale.bind(y18n$2),
1317
+ updateLocale: y18n$2.updateLocale.bind(y18n$2),
1318
+ locale: y18n$2.locale
1319
+ };
1320
+ }
1321
+
1322
+ //#endregion
1323
+ //#region node_modules/y18n/index.mjs
1324
+ const y18n = (opts) => {
1325
+ return y18n$1(opts, node_default);
1326
+ };
1327
+ var y18n_default = y18n;
1328
+
1329
+ //#endregion
1330
+ //#region node_modules/get-caller-file/index.js
1331
+ var require_get_caller_file = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1332
+ module.exports = function getCallerFile$1(position) {
1333
+ if (position === void 0) position = 2;
1334
+ 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 + "`");
1335
+ var oldPrepareStackTrace = Error.prepareStackTrace;
1336
+ Error.prepareStackTrace = function(_, stack$1) {
1337
+ return stack$1;
1338
+ };
1339
+ var stack = (/* @__PURE__ */ new Error()).stack;
1340
+ Error.prepareStackTrace = oldPrepareStackTrace;
1341
+ if (stack !== null && typeof stack === "object") return stack[position] ? stack[position].getFileName() : void 0;
1342
+ };
1343
+ }));
1344
+
1345
+ //#endregion
1346
+ //#region node_modules/yargs/lib/platform-shims/esm.mjs
1347
+ var import_get_caller_file = /* @__PURE__ */ __toESM(require_get_caller_file(), 1);
1348
+ const __dirname = fileURLToPath(import.meta.url);
1349
+ const mainFilename = __dirname.substring(0, __dirname.lastIndexOf("node_modules"));
1350
+ const require = createRequire(import.meta.url);
1351
+ var esm_default = {
1352
+ assert: {
1353
+ notStrictEqual,
1354
+ strictEqual
1355
+ },
1356
+ cliui: ui,
1357
+ findUp: sync_default,
1358
+ getEnv: (key) => {
1359
+ return process.env[key];
1360
+ },
1361
+ inspect,
1362
+ getProcessArgvBin,
1363
+ mainFilename: mainFilename || process.cwd(),
1364
+ Parser: lib_default,
1365
+ path: {
1366
+ basename,
1367
+ dirname,
1368
+ extname,
1369
+ relative,
1370
+ resolve,
1371
+ join
1372
+ },
1373
+ process: {
1374
+ argv: () => process.argv,
1375
+ cwd: process.cwd,
1376
+ emitWarning: (warning, type) => process.emitWarning(warning, type),
1377
+ execPath: () => process.execPath,
1378
+ exit: (code) => {
1379
+ process.exit(code);
1380
+ },
1381
+ nextTick: process.nextTick,
1382
+ stdColumns: typeof process.stdout.columns !== "undefined" ? process.stdout.columns : null
1383
+ },
1384
+ readFileSync: readFileSync$1,
1385
+ readdirSync: readdirSync$1,
1386
+ require,
1387
+ getCallerFile: () => {
1388
+ const callerFile = (0, import_get_caller_file.default)(3);
1389
+ return callerFile.match(/^file:\/\//) ? fileURLToPath(callerFile) : callerFile;
1390
+ },
1391
+ stringWidth,
1392
+ y18n: y18n_default({
1393
+ directory: resolve(__dirname, "../../../locales"),
1394
+ updateFiles: false
1395
+ })
1396
+ };
1397
+
1398
+ //#endregion
1399
+ //#region node_modules/yargs/build/lib/typings/common-types.js
1400
+ function assertNotStrictEqual(actual, expected, shim$2, message) {
1401
+ shim$2.assert.notStrictEqual(actual, expected, message);
1402
+ }
1403
+ function assertSingleKey(actual, shim$2) {
1404
+ shim$2.assert.strictEqual(typeof actual, "string");
1405
+ }
1406
+ function objectKeys(object) {
1407
+ return Object.keys(object);
1408
+ }
1409
+
1410
+ //#endregion
1411
+ //#region node_modules/yargs/build/lib/utils/is-promise.js
1412
+ function isPromise(maybePromise) {
1413
+ return !!maybePromise && !!maybePromise.then && typeof maybePromise.then === "function";
1414
+ }
1415
+
1416
+ //#endregion
1417
+ //#region node_modules/yargs/build/lib/yerror.js
1418
+ var YError = class YError extends Error {
1419
+ constructor(msg) {
1420
+ super(msg || "yargs error");
1421
+ this.name = "YError";
1422
+ if (Error.captureStackTrace) Error.captureStackTrace(this, YError);
1423
+ }
1424
+ };
1425
+
1426
+ //#endregion
1427
+ //#region node_modules/yargs/build/lib/parse-command.js
1428
+ function parseCommand(cmd) {
1429
+ const splitCommand = cmd.replace(/\s{2,}/g, " ").split(/\s+(?![^[]*]|[^<]*>)/);
1430
+ const bregex = /\.*[\][<>]/g;
1431
+ const firstCommand = splitCommand.shift();
1432
+ if (!firstCommand) throw new Error(`No command found in: ${cmd}`);
1433
+ const parsedCommand = {
1434
+ cmd: firstCommand.replace(bregex, ""),
1435
+ demanded: [],
1436
+ optional: []
1437
+ };
1438
+ splitCommand.forEach((cmd$1, i) => {
1439
+ let variadic = false;
1440
+ cmd$1 = cmd$1.replace(/\s/g, "");
1441
+ if (/\.+[\]>]/.test(cmd$1) && i === splitCommand.length - 1) variadic = true;
1442
+ if (/^\[/.test(cmd$1)) parsedCommand.optional.push({
1443
+ cmd: cmd$1.replace(bregex, "").split("|"),
1444
+ variadic
1445
+ });
1446
+ else parsedCommand.demanded.push({
1447
+ cmd: cmd$1.replace(bregex, "").split("|"),
1448
+ variadic
1449
+ });
1450
+ });
1451
+ return parsedCommand;
1452
+ }
1453
+
1454
+ //#endregion
1455
+ //#region node_modules/yargs/build/lib/argsert.js
1456
+ const positionName = [
1457
+ "first",
1458
+ "second",
1459
+ "third",
1460
+ "fourth",
1461
+ "fifth",
1462
+ "sixth"
1463
+ ];
1464
+ function argsert(arg1, arg2, arg3) {
1465
+ function parseArgs() {
1466
+ return typeof arg1 === "object" ? [
1467
+ {
1468
+ demanded: [],
1469
+ optional: []
1470
+ },
1471
+ arg1,
1472
+ arg2
1473
+ ] : [
1474
+ parseCommand(`cmd ${arg1}`),
1475
+ arg2,
1476
+ arg3
1477
+ ];
1478
+ }
1479
+ try {
1480
+ let position = 0;
1481
+ const [parsed, callerArguments, _length] = parseArgs();
1482
+ const args = [].slice.call(callerArguments);
1483
+ while (args.length && args[args.length - 1] === void 0) args.pop();
1484
+ const length = _length || args.length;
1485
+ if (length < parsed.demanded.length) throw new YError(`Not enough arguments provided. Expected ${parsed.demanded.length} but received ${args.length}.`);
1486
+ const totalCommands = parsed.demanded.length + parsed.optional.length;
1487
+ if (length > totalCommands) throw new YError(`Too many arguments provided. Expected max ${totalCommands} but received ${length}.`);
1488
+ parsed.demanded.forEach((demanded) => {
1489
+ const observedType = guessType(args.shift());
1490
+ if (demanded.cmd.filter((type) => type === observedType || type === "*").length === 0) argumentTypeError(observedType, demanded.cmd, position);
1491
+ position += 1;
1492
+ });
1493
+ parsed.optional.forEach((optional) => {
1494
+ if (args.length === 0) return;
1495
+ const observedType = guessType(args.shift());
1496
+ if (optional.cmd.filter((type) => type === observedType || type === "*").length === 0) argumentTypeError(observedType, optional.cmd, position);
1497
+ position += 1;
1498
+ });
1499
+ } catch (err) {
1500
+ console.warn(err.stack);
1501
+ }
1502
+ }
1503
+ function guessType(arg) {
1504
+ if (Array.isArray(arg)) return "array";
1505
+ else if (arg === null) return "null";
1506
+ return typeof arg;
1507
+ }
1508
+ function argumentTypeError(observedType, allowedTypes, position) {
1509
+ throw new YError(`Invalid ${positionName[position] || "manyith"} argument. Expected ${allowedTypes.join(" or ")} but received ${observedType}.`);
1510
+ }
1511
+
1512
+ //#endregion
1513
+ //#region node_modules/yargs/build/lib/middleware.js
1514
+ var GlobalMiddleware = class {
1515
+ constructor(yargs) {
1516
+ this.globalMiddleware = [];
1517
+ this.frozens = [];
1518
+ this.yargs = yargs;
1519
+ }
1520
+ addMiddleware(callback, applyBeforeValidation, global = true, mutates = false) {
1521
+ argsert("<array|function> [boolean] [boolean] [boolean]", [
1522
+ callback,
1523
+ applyBeforeValidation,
1524
+ global
1525
+ ], arguments.length);
1526
+ if (Array.isArray(callback)) {
1527
+ for (let i = 0; i < callback.length; i++) {
1528
+ if (typeof callback[i] !== "function") throw Error("middleware must be a function");
1529
+ const m = callback[i];
1530
+ m.applyBeforeValidation = applyBeforeValidation;
1531
+ m.global = global;
1532
+ }
1533
+ Array.prototype.push.apply(this.globalMiddleware, callback);
1534
+ } else if (typeof callback === "function") {
1535
+ const m = callback;
1536
+ m.applyBeforeValidation = applyBeforeValidation;
1537
+ m.global = global;
1538
+ m.mutates = mutates;
1539
+ this.globalMiddleware.push(callback);
1540
+ }
1541
+ return this.yargs;
1542
+ }
1543
+ addCoerceMiddleware(callback, option) {
1544
+ const aliases = this.yargs.getAliases();
1545
+ this.globalMiddleware = this.globalMiddleware.filter((m) => {
1546
+ const toCheck = [...aliases[option] || [], option];
1547
+ if (!m.option) return true;
1548
+ else return !toCheck.includes(m.option);
1549
+ });
1550
+ callback.option = option;
1551
+ return this.addMiddleware(callback, true, true, true);
1552
+ }
1553
+ getMiddleware() {
1554
+ return this.globalMiddleware;
1555
+ }
1556
+ freeze() {
1557
+ this.frozens.push([...this.globalMiddleware]);
1558
+ }
1559
+ unfreeze() {
1560
+ const frozen = this.frozens.pop();
1561
+ if (frozen !== void 0) this.globalMiddleware = frozen;
1562
+ }
1563
+ reset() {
1564
+ this.globalMiddleware = this.globalMiddleware.filter((m) => m.global);
1565
+ }
1566
+ };
1567
+ function commandMiddlewareFactory(commandMiddleware) {
1568
+ if (!commandMiddleware) return [];
1569
+ return commandMiddleware.map((middleware) => {
1570
+ middleware.applyBeforeValidation = false;
1571
+ return middleware;
1572
+ });
1573
+ }
1574
+ function applyMiddleware(argv, yargs, middlewares, beforeValidation) {
1575
+ return middlewares.reduce((acc, middleware) => {
1576
+ if (middleware.applyBeforeValidation !== beforeValidation) return acc;
1577
+ if (middleware.mutates) {
1578
+ if (middleware.applied) return acc;
1579
+ middleware.applied = true;
1580
+ }
1581
+ if (isPromise(acc)) return acc.then((initialObj) => Promise.all([initialObj, middleware(initialObj, yargs)])).then(([initialObj, middlewareObj]) => Object.assign(initialObj, middlewareObj));
1582
+ else {
1583
+ const result = middleware(acc, yargs);
1584
+ return isPromise(result) ? result.then((middlewareObj) => Object.assign(acc, middlewareObj)) : Object.assign(acc, result);
1585
+ }
1586
+ }, argv);
1587
+ }
1588
+
1589
+ //#endregion
1590
+ //#region node_modules/yargs/build/lib/utils/maybe-async-result.js
1591
+ function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
1592
+ throw err;
1593
+ }) {
1594
+ try {
1595
+ const result = isFunction(getResult) ? getResult() : getResult;
1596
+ return isPromise(result) ? result.then((result$1) => resultHandler(result$1)) : resultHandler(result);
1597
+ } catch (err) {
1598
+ return errorHandler(err);
1599
+ }
1600
+ }
1601
+ function isFunction(arg) {
1602
+ return typeof arg === "function";
1603
+ }
1604
+
1605
+ //#endregion
1606
+ //#region node_modules/yargs/build/lib/command.js
1607
+ const DEFAULT_MARKER = /(^\*)|(^\$0)/;
1608
+ var CommandInstance = class {
1609
+ constructor(usage$1, validation$1, globalMiddleware, shim$2) {
1610
+ this.requireCache = /* @__PURE__ */ new Set();
1611
+ this.handlers = {};
1612
+ this.aliasMap = {};
1613
+ this.frozens = [];
1614
+ this.shim = shim$2;
1615
+ this.usage = usage$1;
1616
+ this.globalMiddleware = globalMiddleware;
1617
+ this.validation = validation$1;
1618
+ }
1619
+ addDirectory(dir, req, callerFile, opts) {
1620
+ opts = opts || {};
1621
+ this.requireCache.add(callerFile);
1622
+ const fullDirPath = this.shim.path.resolve(this.shim.path.dirname(callerFile), dir);
1623
+ const files = this.shim.readdirSync(fullDirPath, { recursive: opts.recurse ? true : false });
1624
+ if (!Array.isArray(opts.extensions)) opts.extensions = ["js"];
1625
+ const visit = typeof opts.visit === "function" ? opts.visit : (o) => o;
1626
+ for (const fileb of files) {
1627
+ const file = fileb.toString();
1628
+ if (opts.exclude) {
1629
+ let exclude = false;
1630
+ if (typeof opts.exclude === "function") exclude = opts.exclude(file);
1631
+ else exclude = opts.exclude.test(file);
1632
+ if (exclude) continue;
1633
+ }
1634
+ if (opts.include) {
1635
+ let include = false;
1636
+ if (typeof opts.include === "function") include = opts.include(file);
1637
+ else include = opts.include.test(file);
1638
+ if (!include) continue;
1639
+ }
1640
+ let supportedExtension = false;
1641
+ for (const ext of opts.extensions) if (file.endsWith(ext)) supportedExtension = true;
1642
+ if (supportedExtension) {
1643
+ const joined = this.shim.path.join(fullDirPath, file);
1644
+ const module$1 = req(joined);
1645
+ const extendableModule = Object.create(null, Object.getOwnPropertyDescriptors({ ...module$1 }));
1646
+ if (visit(extendableModule, joined, file)) {
1647
+ if (this.requireCache.has(joined)) continue;
1648
+ else this.requireCache.add(joined);
1649
+ if (!extendableModule.command) extendableModule.command = this.shim.path.basename(joined, this.shim.path.extname(joined));
1650
+ this.addHandler(extendableModule);
1651
+ }
1652
+ }
1653
+ }
1654
+ }
1655
+ addHandler(cmd, description, builder, handler, commandMiddleware, deprecated) {
1656
+ let aliases = [];
1657
+ const middlewares = commandMiddlewareFactory(commandMiddleware);
1658
+ handler = handler || (() => {});
1659
+ if (Array.isArray(cmd)) if (isCommandAndAliases(cmd)) [cmd, ...aliases] = cmd;
1660
+ else for (const command$1 of cmd) this.addHandler(command$1);
1661
+ else if (isCommandHandlerDefinition(cmd)) {
1662
+ let command$1 = Array.isArray(cmd.command) || typeof cmd.command === "string" ? cmd.command : null;
1663
+ if (command$1 === null) throw new Error(`No command name given for module: ${this.shim.inspect(cmd)}`);
1664
+ if (cmd.aliases) command$1 = [].concat(command$1).concat(cmd.aliases);
1665
+ this.addHandler(command$1, this.extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
1666
+ return;
1667
+ } else if (isCommandBuilderDefinition(builder)) {
1668
+ this.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares, builder.deprecated);
1669
+ return;
1670
+ }
1671
+ if (typeof cmd === "string") {
1672
+ const parsedCommand = parseCommand(cmd);
1673
+ aliases = aliases.map((alias) => parseCommand(alias).cmd);
1674
+ let isDefault = false;
1675
+ const parsedAliases = [parsedCommand.cmd].concat(aliases).filter((c) => {
1676
+ if (DEFAULT_MARKER.test(c)) {
1677
+ isDefault = true;
1678
+ return false;
1679
+ }
1680
+ return true;
1681
+ });
1682
+ if (parsedAliases.length === 0 && isDefault) parsedAliases.push("$0");
1683
+ if (isDefault) {
1684
+ parsedCommand.cmd = parsedAliases[0];
1685
+ aliases = parsedAliases.slice(1);
1686
+ cmd = cmd.replace(DEFAULT_MARKER, parsedCommand.cmd);
1687
+ }
1688
+ aliases.forEach((alias) => {
1689
+ this.aliasMap[alias] = parsedCommand.cmd;
1690
+ });
1691
+ if (description !== false) this.usage.command(cmd, description, isDefault, aliases, deprecated);
1692
+ this.handlers[parsedCommand.cmd] = {
1693
+ original: cmd,
1694
+ description,
1695
+ handler,
1696
+ builder: builder || {},
1697
+ middlewares,
1698
+ deprecated,
1699
+ demanded: parsedCommand.demanded,
1700
+ optional: parsedCommand.optional
1701
+ };
1702
+ if (isDefault) this.defaultCommand = this.handlers[parsedCommand.cmd];
1703
+ }
1704
+ }
1705
+ getCommandHandlers() {
1706
+ return this.handlers;
1707
+ }
1708
+ getCommands() {
1709
+ return Object.keys(this.handlers).concat(Object.keys(this.aliasMap));
1710
+ }
1711
+ hasDefaultCommand() {
1712
+ return !!this.defaultCommand;
1713
+ }
1714
+ runCommand(command$1, yargs, parsed, commandIndex, helpOnly, helpOrVersionSet) {
1715
+ const commandHandler = this.handlers[command$1] || this.handlers[this.aliasMap[command$1]] || this.defaultCommand;
1716
+ const currentContext = yargs.getInternalMethods().getContext();
1717
+ const parentCommands = currentContext.commands.slice();
1718
+ const isDefaultCommand = !command$1;
1719
+ if (command$1) {
1720
+ currentContext.commands.push(command$1);
1721
+ currentContext.fullCommands.push(commandHandler.original);
1722
+ }
1723
+ const builderResult = this.applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, parsed.aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet);
1724
+ 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);
1725
+ }
1726
+ applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet) {
1727
+ const builder = commandHandler.builder;
1728
+ let innerYargs = yargs;
1729
+ if (isCommandBuilderCallback(builder)) {
1730
+ yargs.getInternalMethods().getUsageInstance().freeze();
1731
+ const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet);
1732
+ if (isPromise(builderOutput)) return builderOutput.then((output) => {
1733
+ innerYargs = isYargsInstance(output) ? output : yargs;
1734
+ return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
1735
+ });
1736
+ } else if (isCommandBuilderOptionDefinitions(builder)) {
1737
+ yargs.getInternalMethods().getUsageInstance().freeze();
1738
+ innerYargs = yargs.getInternalMethods().reset(aliases);
1739
+ Object.keys(commandHandler.builder).forEach((key) => {
1740
+ innerYargs.option(key, builder[key]);
1741
+ });
1742
+ }
1743
+ return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
1744
+ }
1745
+ parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly) {
1746
+ if (isDefaultCommand) innerYargs.getInternalMethods().getUsageInstance().unfreeze(true);
1747
+ if (this.shouldUpdateUsage(innerYargs)) innerYargs.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
1748
+ const innerArgv = innerYargs.getInternalMethods().runYargsParserAndExecuteCommands(null, void 0, true, commandIndex, helpOnly);
1749
+ return isPromise(innerArgv) ? innerArgv.then((argv) => ({
1750
+ aliases: innerYargs.parsed.aliases,
1751
+ innerArgv: argv
1752
+ })) : {
1753
+ aliases: innerYargs.parsed.aliases,
1754
+ innerArgv
1755
+ };
1756
+ }
1757
+ shouldUpdateUsage(yargs) {
1758
+ return !yargs.getInternalMethods().getUsageInstance().getUsageDisabled() && yargs.getInternalMethods().getUsageInstance().getUsage().length === 0;
1759
+ }
1760
+ usageFromParentCommandsCommandHandler(parentCommands, commandHandler) {
1761
+ const c = DEFAULT_MARKER.test(commandHandler.original) ? commandHandler.original.replace(DEFAULT_MARKER, "").trim() : commandHandler.original;
1762
+ const pc = parentCommands.filter((c$1) => {
1763
+ return !DEFAULT_MARKER.test(c$1);
1764
+ });
1765
+ pc.push(c);
1766
+ return `$0 ${pc.join(" ")}`;
1767
+ }
1768
+ handleValidationAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, aliases, yargs, middlewares, positionalMap) {
1769
+ if (!yargs.getInternalMethods().getHasOutput()) {
1770
+ const validation$1 = yargs.getInternalMethods().runValidation(aliases, positionalMap, yargs.parsed.error, isDefaultCommand);
1771
+ innerArgv = maybeAsyncResult(innerArgv, (result) => {
1772
+ validation$1(result);
1773
+ return result;
1774
+ });
1775
+ }
1776
+ if (commandHandler.handler && !yargs.getInternalMethods().getHasOutput()) {
1777
+ yargs.getInternalMethods().setHasOutput();
1778
+ const populateDoubleDash = !!yargs.getOptions().configuration["populate--"];
1779
+ yargs.getInternalMethods().postProcess(innerArgv, populateDoubleDash, false, false);
1780
+ innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false);
1781
+ innerArgv = maybeAsyncResult(innerArgv, (result) => {
1782
+ const handlerResult = commandHandler.handler(result);
1783
+ return isPromise(handlerResult) ? handlerResult.then(() => result) : result;
1784
+ });
1785
+ if (!isDefaultCommand) yargs.getInternalMethods().getUsageInstance().cacheHelpMessage();
1786
+ if (isPromise(innerArgv) && !yargs.getInternalMethods().hasParseCallback()) innerArgv.catch((error) => {
1787
+ try {
1788
+ yargs.getInternalMethods().getUsageInstance().fail(null, error);
1789
+ } catch (_err) {}
1790
+ });
1791
+ }
1792
+ if (!isDefaultCommand) {
1793
+ currentContext.commands.pop();
1794
+ currentContext.fullCommands.pop();
1795
+ }
1796
+ return innerArgv;
1797
+ }
1798
+ applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
1799
+ let positionalMap = {};
1800
+ if (helpOnly) return innerArgv;
1801
+ if (!yargs.getInternalMethods().getHasOutput()) positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
1802
+ const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
1803
+ const maybePromiseArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
1804
+ 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);
1805
+ }
1806
+ populatePositionals(commandHandler, argv, context, yargs) {
1807
+ argv._ = argv._.slice(context.commands.length);
1808
+ const demanded = commandHandler.demanded.slice(0);
1809
+ const optional = commandHandler.optional.slice(0);
1810
+ const positionalMap = {};
1811
+ this.validation.positionalCount(demanded.length, argv._.length);
1812
+ while (demanded.length) {
1813
+ const demand = demanded.shift();
1814
+ this.populatePositional(demand, argv, positionalMap);
1815
+ }
1816
+ while (optional.length) {
1817
+ const maybe = optional.shift();
1818
+ this.populatePositional(maybe, argv, positionalMap);
1819
+ }
1820
+ argv._ = context.commands.concat(argv._.map((a) => "" + a));
1821
+ this.postProcessPositionals(argv, positionalMap, this.cmdToParseOptions(commandHandler.original), yargs);
1822
+ return positionalMap;
1823
+ }
1824
+ populatePositional(positional, argv, positionalMap) {
1825
+ const cmd = positional.cmd[0];
1826
+ if (positional.variadic) positionalMap[cmd] = argv._.splice(0).map(String);
1827
+ else if (argv._.length) positionalMap[cmd] = [String(argv._.shift())];
1828
+ }
1829
+ cmdToParseOptions(cmdString) {
1830
+ const parseOptions = {
1831
+ array: [],
1832
+ default: {},
1833
+ alias: {},
1834
+ demand: {}
1835
+ };
1836
+ const parsed = parseCommand(cmdString);
1837
+ parsed.demanded.forEach((d) => {
1838
+ const [cmd, ...aliases] = d.cmd;
1839
+ if (d.variadic) {
1840
+ parseOptions.array.push(cmd);
1841
+ parseOptions.default[cmd] = [];
1842
+ }
1843
+ parseOptions.alias[cmd] = aliases;
1844
+ parseOptions.demand[cmd] = true;
1845
+ });
1846
+ parsed.optional.forEach((o) => {
1847
+ const [cmd, ...aliases] = o.cmd;
1848
+ if (o.variadic) {
1849
+ parseOptions.array.push(cmd);
1850
+ parseOptions.default[cmd] = [];
1851
+ }
1852
+ parseOptions.alias[cmd] = aliases;
1853
+ });
1854
+ return parseOptions;
1855
+ }
1856
+ postProcessPositionals(argv, positionalMap, parseOptions, yargs) {
1857
+ const options = Object.assign({}, yargs.getOptions());
1858
+ options.default = Object.assign(parseOptions.default, options.default);
1859
+ for (const key of Object.keys(parseOptions.alias)) options.alias[key] = (options.alias[key] || []).concat(parseOptions.alias[key]);
1860
+ options.array = options.array.concat(parseOptions.array);
1861
+ options.config = {};
1862
+ const unparsed = [];
1863
+ Object.keys(positionalMap).forEach((key) => {
1864
+ positionalMap[key].map((value) => {
1865
+ if (options.configuration["unknown-options-as-args"]) options.key[key] = true;
1866
+ unparsed.push(`--${key}`);
1867
+ unparsed.push(value);
1868
+ });
1869
+ });
1870
+ if (!unparsed.length) return;
1871
+ const config$1 = Object.assign({}, options.configuration, { "populate--": false });
1872
+ const parsed = this.shim.Parser.detailed(unparsed, Object.assign({}, options, { configuration: config$1 }));
1873
+ if (parsed.error) yargs.getInternalMethods().getUsageInstance().fail(parsed.error.message, parsed.error);
1874
+ else {
1875
+ const positionalKeys = Object.keys(positionalMap);
1876
+ Object.keys(positionalMap).forEach((key) => {
1877
+ positionalKeys.push(...parsed.aliases[key]);
1878
+ });
1879
+ Object.keys(parsed.argv).forEach((key) => {
1880
+ if (positionalKeys.includes(key)) {
1881
+ if (!positionalMap[key]) positionalMap[key] = parsed.argv[key];
1882
+ 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]);
1883
+ else argv[key] = parsed.argv[key];
1884
+ }
1885
+ });
1886
+ }
1887
+ }
1888
+ isDefaulted(yargs, key) {
1889
+ const { default: defaults } = yargs.getOptions();
1890
+ return Object.prototype.hasOwnProperty.call(defaults, key) || Object.prototype.hasOwnProperty.call(defaults, this.shim.Parser.camelCase(key));
1891
+ }
1892
+ isInConfigs(yargs, key) {
1893
+ const { configObjects } = yargs.getOptions();
1894
+ return configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, key)) || configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, this.shim.Parser.camelCase(key)));
1895
+ }
1896
+ runDefaultBuilderOn(yargs) {
1897
+ if (!this.defaultCommand) return;
1898
+ if (this.shouldUpdateUsage(yargs)) {
1899
+ const commandString = DEFAULT_MARKER.test(this.defaultCommand.original) ? this.defaultCommand.original : this.defaultCommand.original.replace(/^[^[\]<>]*/, "$0 ");
1900
+ yargs.getInternalMethods().getUsageInstance().usage(commandString, this.defaultCommand.description);
1901
+ }
1902
+ const builder = this.defaultCommand.builder;
1903
+ if (isCommandBuilderCallback(builder)) return builder(yargs, true);
1904
+ else if (!isCommandBuilderDefinition(builder)) Object.keys(builder).forEach((key) => {
1905
+ yargs.option(key, builder[key]);
1906
+ });
1907
+ }
1908
+ extractDesc({ describe, description, desc }) {
1909
+ for (const test of [
1910
+ describe,
1911
+ description,
1912
+ desc
1913
+ ]) {
1914
+ if (typeof test === "string" || test === false) return test;
1915
+ assertNotStrictEqual(test, true, this.shim);
1916
+ }
1917
+ return false;
1918
+ }
1919
+ freeze() {
1920
+ this.frozens.push({
1921
+ handlers: this.handlers,
1922
+ aliasMap: this.aliasMap,
1923
+ defaultCommand: this.defaultCommand
1924
+ });
1925
+ }
1926
+ unfreeze() {
1927
+ const frozen = this.frozens.pop();
1928
+ assertNotStrictEqual(frozen, void 0, this.shim);
1929
+ ({handlers: this.handlers, aliasMap: this.aliasMap, defaultCommand: this.defaultCommand} = frozen);
1930
+ }
1931
+ reset() {
1932
+ this.handlers = {};
1933
+ this.aliasMap = {};
1934
+ this.defaultCommand = void 0;
1935
+ this.requireCache = /* @__PURE__ */ new Set();
1936
+ return this;
1937
+ }
1938
+ };
1939
+ function command(usage$1, validation$1, globalMiddleware, shim$2) {
1940
+ return new CommandInstance(usage$1, validation$1, globalMiddleware, shim$2);
1941
+ }
1942
+ function isCommandBuilderDefinition(builder) {
1943
+ return typeof builder === "object" && !!builder.builder && typeof builder.handler === "function";
1944
+ }
1945
+ function isCommandAndAliases(cmd) {
1946
+ return cmd.every((c) => typeof c === "string");
1947
+ }
1948
+ function isCommandBuilderCallback(builder) {
1949
+ return typeof builder === "function";
1950
+ }
1951
+ function isCommandBuilderOptionDefinitions(builder) {
1952
+ return typeof builder === "object";
1953
+ }
1954
+ function isCommandHandlerDefinition(cmd) {
1955
+ return typeof cmd === "object" && !Array.isArray(cmd);
1956
+ }
1957
+
1958
+ //#endregion
1959
+ //#region node_modules/yargs/build/lib/utils/obj-filter.js
1960
+ function objFilter(original = {}, filter = () => true) {
1961
+ const obj = {};
1962
+ objectKeys(original).forEach((key) => {
1963
+ if (filter(key, original[key])) obj[key] = original[key];
1964
+ });
1965
+ return obj;
1966
+ }
1967
+
1968
+ //#endregion
1969
+ //#region node_modules/yargs/build/lib/utils/set-blocking.js
1970
+ function setBlocking(blocking) {
1971
+ if (typeof process === "undefined") return;
1972
+ [process.stdout, process.stderr].forEach((_stream) => {
1973
+ const stream = _stream;
1974
+ if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === "function") stream._handle.setBlocking(blocking);
1975
+ });
1976
+ }
1977
+
1978
+ //#endregion
1979
+ //#region node_modules/yargs/build/lib/usage.js
1980
+ function isBoolean(fail) {
1981
+ return typeof fail === "boolean";
1982
+ }
1983
+ function usage(yargs, shim$2) {
1984
+ const __ = shim$2.y18n.__;
1985
+ const self = {};
1986
+ const fails = [];
1987
+ self.failFn = function failFn(f) {
1988
+ fails.push(f);
1989
+ };
1990
+ let failMessage = null;
1991
+ let globalFailMessage = null;
1992
+ let showHelpOnFail = true;
1993
+ self.showHelpOnFail = function showHelpOnFailFn(arg1 = true, arg2) {
1994
+ const [enabled, message] = typeof arg1 === "string" ? [true, arg1] : [arg1, arg2];
1995
+ if (yargs.getInternalMethods().isGlobalContext()) globalFailMessage = message;
1996
+ failMessage = message;
1997
+ showHelpOnFail = enabled;
1998
+ return self;
1999
+ };
2000
+ let failureOutput = false;
2001
+ self.fail = function fail(msg, err) {
2002
+ const logger = yargs.getInternalMethods().getLoggerInstance();
2003
+ if (fails.length) for (let i = fails.length - 1; i >= 0; --i) {
2004
+ const fail$1 = fails[i];
2005
+ if (isBoolean(fail$1)) {
2006
+ if (err) throw err;
2007
+ else if (msg) throw Error(msg);
2008
+ } else fail$1(msg, err, self);
2009
+ }
2010
+ else {
2011
+ if (yargs.getExitProcess()) setBlocking(true);
2012
+ if (!failureOutput) {
2013
+ failureOutput = true;
2014
+ if (showHelpOnFail) {
2015
+ yargs.showHelp("error");
2016
+ logger.error();
2017
+ }
2018
+ if (msg || err) logger.error(msg || err);
2019
+ const globalOrCommandFailMessage = failMessage || globalFailMessage;
2020
+ if (globalOrCommandFailMessage) {
2021
+ if (msg || err) logger.error("");
2022
+ logger.error(globalOrCommandFailMessage);
2023
+ }
2024
+ }
2025
+ err = err || new YError(msg);
2026
+ if (yargs.getExitProcess()) return yargs.exit(1);
2027
+ else if (yargs.getInternalMethods().hasParseCallback()) return yargs.exit(1, err);
2028
+ else throw err;
2029
+ }
2030
+ };
2031
+ let usages = [];
2032
+ let usageDisabled = false;
2033
+ self.usage = (msg, description) => {
2034
+ if (msg === null) {
2035
+ usageDisabled = true;
2036
+ usages = [];
2037
+ return self;
2038
+ }
2039
+ usageDisabled = false;
2040
+ usages.push([msg, description || ""]);
2041
+ return self;
2042
+ };
2043
+ self.getUsage = () => {
2044
+ return usages;
2045
+ };
2046
+ self.getUsageDisabled = () => {
2047
+ return usageDisabled;
2048
+ };
2049
+ self.getPositionalGroupName = () => {
2050
+ return __("Positionals:");
2051
+ };
2052
+ let examples = [];
2053
+ self.example = (cmd, description) => {
2054
+ examples.push([cmd, description || ""]);
2055
+ };
2056
+ let commands = [];
2057
+ self.command = function command$1(cmd, description, isDefault, aliases, deprecated = false) {
2058
+ if (isDefault) commands = commands.map((cmdArray) => {
2059
+ cmdArray[2] = false;
2060
+ return cmdArray;
2061
+ });
2062
+ commands.push([
2063
+ cmd,
2064
+ description || "",
2065
+ isDefault,
2066
+ aliases,
2067
+ deprecated
2068
+ ]);
2069
+ };
2070
+ self.getCommands = () => commands;
2071
+ let descriptions = {};
2072
+ self.describe = function describe(keyOrKeys, desc) {
2073
+ if (Array.isArray(keyOrKeys)) keyOrKeys.forEach((k) => {
2074
+ self.describe(k, desc);
2075
+ });
2076
+ else if (typeof keyOrKeys === "object") Object.keys(keyOrKeys).forEach((k) => {
2077
+ self.describe(k, keyOrKeys[k]);
2078
+ });
2079
+ else descriptions[keyOrKeys] = desc;
2080
+ };
2081
+ self.getDescriptions = () => descriptions;
2082
+ let epilogs = [];
2083
+ self.epilog = (msg) => {
2084
+ epilogs.push(msg);
2085
+ };
2086
+ let wrapSet = false;
2087
+ let wrap;
2088
+ self.wrap = (cols) => {
2089
+ wrapSet = true;
2090
+ wrap = cols;
2091
+ };
2092
+ self.getWrap = () => {
2093
+ if (shim$2.getEnv("YARGS_DISABLE_WRAP")) return null;
2094
+ if (!wrapSet) {
2095
+ wrap = windowWidth();
2096
+ wrapSet = true;
2097
+ }
2098
+ return wrap;
2099
+ };
2100
+ const deferY18nLookupPrefix = "__yargsString__:";
2101
+ self.deferY18nLookup = (str) => deferY18nLookupPrefix + str;
2102
+ self.help = function help() {
2103
+ if (cachedHelpMessage) return cachedHelpMessage;
2104
+ normalizeAliases();
2105
+ const base$0 = yargs.customScriptName ? yargs.$0 : shim$2.path.basename(yargs.$0);
2106
+ const demandedOptions = yargs.getDemandedOptions();
2107
+ const demandedCommands = yargs.getDemandedCommands();
2108
+ const deprecatedOptions = yargs.getDeprecatedOptions();
2109
+ const groups = yargs.getGroups();
2110
+ const options = yargs.getOptions();
2111
+ let keys = [];
2112
+ keys = keys.concat(Object.keys(descriptions));
2113
+ keys = keys.concat(Object.keys(demandedOptions));
2114
+ keys = keys.concat(Object.keys(demandedCommands));
2115
+ keys = keys.concat(Object.keys(options.default));
2116
+ keys = keys.filter(filterHiddenOptions);
2117
+ keys = Object.keys(keys.reduce((acc, key) => {
2118
+ if (key !== "_") acc[key] = true;
2119
+ return acc;
2120
+ }, {}));
2121
+ const theWrap = self.getWrap();
2122
+ const ui$1 = shim$2.cliui({
2123
+ width: theWrap,
2124
+ wrap: !!theWrap
2125
+ });
2126
+ if (!usageDisabled) {
2127
+ if (usages.length) {
2128
+ usages.forEach((usage$1) => {
2129
+ ui$1.div({ text: `${usage$1[0].replace(/\$0/g, base$0)}` });
2130
+ if (usage$1[1]) ui$1.div({
2131
+ text: `${usage$1[1]}`,
2132
+ padding: [
2133
+ 1,
2134
+ 0,
2135
+ 0,
2136
+ 0
2137
+ ]
2138
+ });
2139
+ });
2140
+ ui$1.div();
2141
+ } else if (commands.length) {
2142
+ let u = null;
2143
+ if (demandedCommands._) u = `${base$0} <${__("command")}>\n`;
2144
+ else u = `${base$0} [${__("command")}]\n`;
2145
+ ui$1.div(`${u}`);
2146
+ }
2147
+ }
2148
+ if (commands.length > 1 || commands.length === 1 && !commands[0][2]) {
2149
+ ui$1.div(__("Commands:"));
2150
+ const context = yargs.getInternalMethods().getContext();
2151
+ const parentCommands = context.commands.length ? `${context.commands.join(" ")} ` : "";
2152
+ if (yargs.getInternalMethods().getParserConfiguration()["sort-commands"] === true) commands = commands.sort((a, b) => a[0].localeCompare(b[0]));
2153
+ const prefix = base$0 ? `${base$0} ` : "";
2154
+ commands.forEach((command$1) => {
2155
+ const commandString = `${prefix}${parentCommands}${command$1[0].replace(/^\$0 ?/, "")}`;
2156
+ ui$1.span({
2157
+ text: commandString,
2158
+ padding: [
2159
+ 0,
2160
+ 2,
2161
+ 0,
2162
+ 2
2163
+ ],
2164
+ width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4
2165
+ }, { text: command$1[1] });
2166
+ const hints = [];
2167
+ if (command$1[2]) hints.push(`[${__("default")}]`);
2168
+ if (command$1[3] && command$1[3].length) hints.push(`[${__("aliases:")} ${command$1[3].join(", ")}]`);
2169
+ if (command$1[4]) if (typeof command$1[4] === "string") hints.push(`[${__("deprecated: %s", command$1[4])}]`);
2170
+ else hints.push(`[${__("deprecated")}]`);
2171
+ if (hints.length) ui$1.div({
2172
+ text: hints.join(" "),
2173
+ padding: [
2174
+ 0,
2175
+ 0,
2176
+ 0,
2177
+ 2
2178
+ ],
2179
+ align: "right"
2180
+ });
2181
+ else ui$1.div();
2182
+ });
2183
+ ui$1.div();
2184
+ }
2185
+ const aliasKeys = (Object.keys(options.alias) || []).concat(Object.keys(yargs.parsed.newAliases) || []);
2186
+ keys = keys.filter((key) => !yargs.parsed.newAliases[key] && aliasKeys.every((alias) => (options.alias[alias] || []).indexOf(key) === -1));
2187
+ const defaultGroup = __("Options:");
2188
+ if (!groups[defaultGroup]) groups[defaultGroup] = [];
2189
+ addUngroupedKeys(keys, options.alias, groups, defaultGroup);
2190
+ const isLongSwitch = (sw) => /^--/.test(getText(sw));
2191
+ const displayedGroups = Object.keys(groups).filter((groupName) => groups[groupName].length > 0).map((groupName) => {
2192
+ return {
2193
+ groupName,
2194
+ normalizedKeys: groups[groupName].filter(filterHiddenOptions).map((key) => {
2195
+ if (aliasKeys.includes(key)) return key;
2196
+ for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== void 0; i++) if ((options.alias[aliasKey] || []).includes(key)) return aliasKey;
2197
+ return key;
2198
+ })
2199
+ };
2200
+ }).filter(({ normalizedKeys }) => normalizedKeys.length > 0).map(({ groupName, normalizedKeys }) => {
2201
+ return {
2202
+ groupName,
2203
+ normalizedKeys,
2204
+ switches: normalizedKeys.reduce((acc, key) => {
2205
+ acc[key] = [key].concat(options.alias[key] || []).map((sw) => {
2206
+ if (groupName === self.getPositionalGroupName()) return sw;
2207
+ else return (/^[0-9]$/.test(sw) ? options.boolean.includes(key) ? "-" : "--" : sw.length > 1 ? "--" : "-") + sw;
2208
+ }).sort((sw1, sw2) => isLongSwitch(sw1) === isLongSwitch(sw2) ? 0 : isLongSwitch(sw1) ? 1 : -1).join(", ");
2209
+ return acc;
2210
+ }, {})
2211
+ };
2212
+ });
2213
+ 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 }) => {
2214
+ normalizedKeys.forEach((key) => {
2215
+ if (isLongSwitch(switches[key])) switches[key] = addIndentation(switches[key], 4);
2216
+ });
2217
+ });
2218
+ displayedGroups.forEach(({ groupName, normalizedKeys, switches }) => {
2219
+ ui$1.div(groupName);
2220
+ normalizedKeys.forEach((key) => {
2221
+ const kswitch = switches[key];
2222
+ let desc = descriptions[key] || "";
2223
+ let type = null;
2224
+ if (desc.includes(deferY18nLookupPrefix)) desc = __(desc.substring(16));
2225
+ if (options.boolean.includes(key)) type = `[${__("boolean")}]`;
2226
+ if (options.count.includes(key)) type = `[${__("count")}]`;
2227
+ if (options.string.includes(key)) type = `[${__("string")}]`;
2228
+ if (options.normalize.includes(key)) type = `[${__("string")}]`;
2229
+ if (options.array.includes(key)) type = `[${__("array")}]`;
2230
+ if (options.number.includes(key)) type = `[${__("number")}]`;
2231
+ const deprecatedExtra = (deprecated) => typeof deprecated === "string" ? `[${__("deprecated: %s", deprecated)}]` : `[${__("deprecated")}]`;
2232
+ const extra = [
2233
+ key in deprecatedOptions ? deprecatedExtra(deprecatedOptions[key]) : null,
2234
+ type,
2235
+ key in demandedOptions ? `[${__("required")}]` : null,
2236
+ options.choices && options.choices[key] ? `[${__("choices:")} ${self.stringifiedValues(options.choices[key])}]` : null,
2237
+ defaultString(options.default[key], options.defaultDescription[key])
2238
+ ].filter(Boolean).join(" ");
2239
+ ui$1.span({
2240
+ text: getText(kswitch),
2241
+ padding: [
2242
+ 0,
2243
+ 2,
2244
+ 0,
2245
+ 2 + getIndentation(kswitch)
2246
+ ],
2247
+ width: maxWidth(switches, theWrap) + 4
2248
+ }, desc);
2249
+ const shouldHideOptionExtras = yargs.getInternalMethods().getUsageConfiguration()["hide-types"] === true;
2250
+ if (extra && !shouldHideOptionExtras) ui$1.div({
2251
+ text: extra,
2252
+ padding: [
2253
+ 0,
2254
+ 0,
2255
+ 0,
2256
+ 2
2257
+ ],
2258
+ align: "right"
2259
+ });
2260
+ else ui$1.div();
2261
+ });
2262
+ ui$1.div();
2263
+ });
2264
+ if (examples.length) {
2265
+ ui$1.div(__("Examples:"));
2266
+ examples.forEach((example) => {
2267
+ example[0] = example[0].replace(/\$0/g, base$0);
2268
+ });
2269
+ examples.forEach((example) => {
2270
+ if (example[1] === "") ui$1.div({
2271
+ text: example[0],
2272
+ padding: [
2273
+ 0,
2274
+ 2,
2275
+ 0,
2276
+ 2
2277
+ ]
2278
+ });
2279
+ else ui$1.div({
2280
+ text: example[0],
2281
+ padding: [
2282
+ 0,
2283
+ 2,
2284
+ 0,
2285
+ 2
2286
+ ],
2287
+ width: maxWidth(examples, theWrap) + 4
2288
+ }, { text: example[1] });
2289
+ });
2290
+ ui$1.div();
2291
+ }
2292
+ if (epilogs.length > 0) {
2293
+ const e = epilogs.map((epilog) => epilog.replace(/\$0/g, base$0)).join("\n");
2294
+ ui$1.div(`${e}\n`);
2295
+ }
2296
+ return ui$1.toString().replace(/\s*$/, "");
2297
+ };
2298
+ function maxWidth(table, theWrap, modifier) {
2299
+ let width = 0;
2300
+ if (!Array.isArray(table)) table = Object.values(table).map((v) => [v]);
2301
+ table.forEach((v) => {
2302
+ width = Math.max(shim$2.stringWidth(modifier ? `${modifier} ${getText(v[0])}` : getText(v[0])) + getIndentation(v[0]), width);
2303
+ });
2304
+ if (theWrap) width = Math.min(width, parseInt((theWrap * .5).toString(), 10));
2305
+ return width;
2306
+ }
2307
+ function normalizeAliases() {
2308
+ const demandedOptions = yargs.getDemandedOptions();
2309
+ const options = yargs.getOptions();
2310
+ (Object.keys(options.alias) || []).forEach((key) => {
2311
+ options.alias[key].forEach((alias) => {
2312
+ if (descriptions[alias]) self.describe(key, descriptions[alias]);
2313
+ if (alias in demandedOptions) yargs.demandOption(key, demandedOptions[alias]);
2314
+ if (options.boolean.includes(alias)) yargs.boolean(key);
2315
+ if (options.count.includes(alias)) yargs.count(key);
2316
+ if (options.string.includes(alias)) yargs.string(key);
2317
+ if (options.normalize.includes(alias)) yargs.normalize(key);
2318
+ if (options.array.includes(alias)) yargs.array(key);
2319
+ if (options.number.includes(alias)) yargs.number(key);
2320
+ });
2321
+ });
2322
+ }
2323
+ let cachedHelpMessage;
2324
+ self.cacheHelpMessage = function() {
2325
+ cachedHelpMessage = this.help();
2326
+ };
2327
+ self.clearCachedHelpMessage = function() {
2328
+ cachedHelpMessage = void 0;
2329
+ };
2330
+ self.hasCachedHelpMessage = function() {
2331
+ return !!cachedHelpMessage;
2332
+ };
2333
+ function addUngroupedKeys(keys, aliases, groups, defaultGroup) {
2334
+ let groupedKeys = [];
2335
+ let toCheck = null;
2336
+ Object.keys(groups).forEach((group) => {
2337
+ groupedKeys = groupedKeys.concat(groups[group]);
2338
+ });
2339
+ keys.forEach((key) => {
2340
+ toCheck = [key].concat(aliases[key]);
2341
+ if (!toCheck.some((k) => groupedKeys.indexOf(k) !== -1)) groups[defaultGroup].push(key);
2342
+ });
2343
+ return groupedKeys;
2344
+ }
2345
+ function filterHiddenOptions(key) {
2346
+ return yargs.getOptions().hiddenOptions.indexOf(key) < 0 || yargs.parsed.argv[yargs.getOptions().showHiddenOpt];
2347
+ }
2348
+ self.showHelp = (level) => {
2349
+ const logger = yargs.getInternalMethods().getLoggerInstance();
2350
+ if (!level) level = "error";
2351
+ (typeof level === "function" ? level : logger[level])(self.help());
2352
+ };
2353
+ self.functionDescription = (fn) => {
2354
+ return [
2355
+ "(",
2356
+ fn.name ? shim$2.Parser.decamelize(fn.name, "-") : __("generated-value"),
2357
+ ")"
2358
+ ].join("");
2359
+ };
2360
+ self.stringifiedValues = function stringifiedValues(values, separator) {
2361
+ let string = "";
2362
+ const sep = separator || ", ";
2363
+ const array = [].concat(values);
2364
+ if (!values || !array.length) return string;
2365
+ array.forEach((value) => {
2366
+ if (string.length) string += sep;
2367
+ string += JSON.stringify(value);
2368
+ });
2369
+ return string;
2370
+ };
2371
+ function defaultString(value, defaultDescription) {
2372
+ let string = `[${__("default:")} `;
2373
+ if (value === void 0 && !defaultDescription) return null;
2374
+ if (defaultDescription) string += defaultDescription;
2375
+ else switch (typeof value) {
2376
+ case "string":
2377
+ string += `"${value}"`;
2378
+ break;
2379
+ case "object":
2380
+ string += JSON.stringify(value);
2381
+ break;
2382
+ default: string += value;
2383
+ }
2384
+ return `${string}]`;
2385
+ }
2386
+ function windowWidth() {
2387
+ const maxWidth$1 = 80;
2388
+ if (shim$2.process.stdColumns) return Math.min(maxWidth$1, shim$2.process.stdColumns);
2389
+ else return maxWidth$1;
2390
+ }
2391
+ let version = null;
2392
+ self.version = (ver) => {
2393
+ version = ver;
2394
+ };
2395
+ self.showVersion = (level) => {
2396
+ const logger = yargs.getInternalMethods().getLoggerInstance();
2397
+ if (!level) level = "error";
2398
+ (typeof level === "function" ? level : logger[level])(version);
2399
+ };
2400
+ self.reset = function reset(localLookup) {
2401
+ failMessage = null;
2402
+ failureOutput = false;
2403
+ usages = [];
2404
+ usageDisabled = false;
2405
+ epilogs = [];
2406
+ examples = [];
2407
+ commands = [];
2408
+ descriptions = objFilter(descriptions, (k) => !localLookup[k]);
2409
+ return self;
2410
+ };
2411
+ const frozens = [];
2412
+ self.freeze = function freeze() {
2413
+ frozens.push({
2414
+ failMessage,
2415
+ failureOutput,
2416
+ usages,
2417
+ usageDisabled,
2418
+ epilogs,
2419
+ examples,
2420
+ commands,
2421
+ descriptions
2422
+ });
2423
+ };
2424
+ self.unfreeze = function unfreeze(defaultCommand = false) {
2425
+ const frozen = frozens.pop();
2426
+ if (!frozen) return;
2427
+ if (defaultCommand) {
2428
+ descriptions = {
2429
+ ...frozen.descriptions,
2430
+ ...descriptions
2431
+ };
2432
+ commands = [...frozen.commands, ...commands];
2433
+ usages = [...frozen.usages, ...usages];
2434
+ examples = [...frozen.examples, ...examples];
2435
+ epilogs = [...frozen.epilogs, ...epilogs];
2436
+ } else ({failMessage, failureOutput, usages, usageDisabled, epilogs, examples, commands, descriptions} = frozen);
2437
+ };
2438
+ return self;
2439
+ }
2440
+ function isIndentedText(text) {
2441
+ return typeof text === "object";
2442
+ }
2443
+ function addIndentation(text, indent) {
2444
+ return isIndentedText(text) ? {
2445
+ text: text.text,
2446
+ indentation: text.indentation + indent
2447
+ } : {
2448
+ text,
2449
+ indentation: indent
2450
+ };
2451
+ }
2452
+ function getIndentation(text) {
2453
+ return isIndentedText(text) ? text.indentation : 0;
2454
+ }
2455
+ function getText(text) {
2456
+ return isIndentedText(text) ? text.text : text;
2457
+ }
2458
+
2459
+ //#endregion
2460
+ //#region node_modules/yargs/build/lib/completion-templates.js
2461
+ const completionShTemplate = `###-begin-{{app_name}}-completions-###
2462
+ #
2463
+ # yargs command completion script
2464
+ #
2465
+ # Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
2466
+ # or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
2467
+ #
2468
+ _{{app_name}}_yargs_completions()
2469
+ {
2470
+ local cur_word args type_list
2471
+
2472
+ cur_word="\${COMP_WORDS[COMP_CWORD]}"
2473
+ args=("\${COMP_WORDS[@]}")
2474
+
2475
+ # ask yargs to generate completions.
2476
+ # see https://stackoverflow.com/a/40944195/7080036 for the spaces-handling awk
2477
+ mapfile -t type_list < <({{app_path}} --get-yargs-completions "\${args[@]}")
2478
+ mapfile -t COMPREPLY < <(compgen -W "$( printf '%q ' "\${type_list[@]}" )" -- "\${cur_word}" |
2479
+ awk '/ / { print "\\""$0"\\"" } /^[^ ]+$/ { print $0 }')
2480
+
2481
+ # if no match was found, fall back to filename completion
2482
+ if [ \${#COMPREPLY[@]} -eq 0 ]; then
2483
+ COMPREPLY=()
2484
+ fi
2485
+
2486
+ return 0
2487
+ }
2488
+ complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
2489
+ ###-end-{{app_name}}-completions-###
2490
+ `;
2491
+ const completionZshTemplate = `#compdef {{app_name}}
2492
+ ###-begin-{{app_name}}-completions-###
2493
+ #
2494
+ # yargs command completion script
2495
+ #
2496
+ # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
2497
+ # or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
2498
+ #
2499
+ _{{app_name}}_yargs_completions()
2500
+ {
2501
+ local reply
2502
+ local si=$IFS
2503
+ IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
2504
+ IFS=$si
2505
+ if [[ \${#reply} -gt 0 ]]; then
2506
+ _describe 'values' reply
2507
+ else
2508
+ _default
2509
+ fi
2510
+ }
2511
+ if [[ "'\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
2512
+ _{{app_name}}_yargs_completions "$@"
2513
+ else
2514
+ compdef _{{app_name}}_yargs_completions {{app_name}}
2515
+ fi
2516
+ ###-end-{{app_name}}-completions-###
2517
+ `;
2518
+
2519
+ //#endregion
2520
+ //#region node_modules/yargs/build/lib/completion.js
2521
+ var Completion = class {
2522
+ constructor(yargs, usage$1, command$1, shim$2) {
2523
+ var _a$1, _b$1, _c$1;
2524
+ this.yargs = yargs;
2525
+ this.usage = usage$1;
2526
+ this.command = command$1;
2527
+ this.shim = shim$2;
2528
+ this.completionKey = "get-yargs-completions";
2529
+ this.aliases = null;
2530
+ this.customCompletionFunction = null;
2531
+ this.indexAfterLastReset = 0;
2532
+ this.zshShell = (_c$1 = ((_a$1 = this.shim.getEnv("SHELL")) === null || _a$1 === void 0 ? void 0 : _a$1.includes("zsh")) || ((_b$1 = this.shim.getEnv("ZSH_NAME")) === null || _b$1 === void 0 ? void 0 : _b$1.includes("zsh"))) !== null && _c$1 !== void 0 ? _c$1 : false;
2533
+ }
2534
+ defaultCompletion(args, argv, current, done) {
2535
+ const handlers = this.command.getCommandHandlers();
2536
+ for (let i = 0, ii = args.length; i < ii; ++i) if (handlers[args[i]] && handlers[args[i]].builder) {
2537
+ const builder = handlers[args[i]].builder;
2538
+ if (isCommandBuilderCallback(builder)) {
2539
+ this.indexAfterLastReset = i + 1;
2540
+ const y = this.yargs.getInternalMethods().reset();
2541
+ builder(y, true);
2542
+ return y.argv;
2543
+ }
2544
+ }
2545
+ const completions = [];
2546
+ this.commandCompletions(completions, args, current);
2547
+ this.optionCompletions(completions, args, argv, current);
2548
+ this.choicesFromOptionsCompletions(completions, args, argv, current);
2549
+ this.choicesFromPositionalsCompletions(completions, args, argv, current);
2550
+ done(null, completions);
2551
+ }
2552
+ commandCompletions(completions, args, current) {
2553
+ const parentCommands = this.yargs.getInternalMethods().getContext().commands;
2554
+ if (!current.match(/^-/) && parentCommands[parentCommands.length - 1] !== current && !this.previousArgHasChoices(args)) this.usage.getCommands().forEach((usageCommand) => {
2555
+ const commandName = parseCommand(usageCommand[0]).cmd;
2556
+ if (args.indexOf(commandName) === -1) if (!this.zshShell) completions.push(commandName);
2557
+ else {
2558
+ const desc = usageCommand[1] || "";
2559
+ completions.push(commandName.replace(/:/g, "\\:") + ":" + desc);
2560
+ }
2561
+ });
2562
+ }
2563
+ optionCompletions(completions, args, argv, current) {
2564
+ if ((current.match(/^-/) || current === "" && completions.length === 0) && !this.previousArgHasChoices(args)) {
2565
+ const options = this.yargs.getOptions();
2566
+ const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
2567
+ Object.keys(options.key).forEach((key) => {
2568
+ const negable = !!options.configuration["boolean-negation"] && options.boolean.includes(key);
2569
+ if (!positionalKeys.includes(key) && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, key, negable)) this.completeOptionKey(key, completions, current, negable && !!options.default[key]);
2570
+ });
2571
+ }
2572
+ }
2573
+ choicesFromOptionsCompletions(completions, args, argv, current) {
2574
+ if (this.previousArgHasChoices(args)) {
2575
+ const choices = this.getPreviousArgChoices(args);
2576
+ if (choices && choices.length > 0) completions.push(...choices.map((c) => c.replace(/:/g, "\\:")));
2577
+ }
2578
+ }
2579
+ choicesFromPositionalsCompletions(completions, args, argv, current) {
2580
+ if (current === "" && completions.length > 0 && this.previousArgHasChoices(args)) return;
2581
+ const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
2582
+ const offset = Math.max(this.indexAfterLastReset, this.yargs.getInternalMethods().getContext().commands.length + 1);
2583
+ const positionalKey = positionalKeys[argv._.length - offset - 1];
2584
+ if (!positionalKey) return;
2585
+ const choices = this.yargs.getOptions().choices[positionalKey] || [];
2586
+ for (const choice of choices) if (choice.startsWith(current)) completions.push(choice.replace(/:/g, "\\:"));
2587
+ }
2588
+ getPreviousArgChoices(args) {
2589
+ if (args.length < 1) return;
2590
+ let previousArg = args[args.length - 1];
2591
+ let filter = "";
2592
+ if (!previousArg.startsWith("-") && args.length > 1) {
2593
+ filter = previousArg;
2594
+ previousArg = args[args.length - 2];
2595
+ }
2596
+ if (!previousArg.startsWith("-")) return;
2597
+ const previousArgKey = previousArg.replace(/^-+/, "");
2598
+ const options = this.yargs.getOptions();
2599
+ const possibleAliases = [previousArgKey, ...this.yargs.getAliases()[previousArgKey] || []];
2600
+ let choices;
2601
+ for (const possibleAlias of possibleAliases) if (Object.prototype.hasOwnProperty.call(options.key, possibleAlias) && Array.isArray(options.choices[possibleAlias])) {
2602
+ choices = options.choices[possibleAlias];
2603
+ break;
2604
+ }
2605
+ if (choices) return choices.filter((choice) => !filter || choice.startsWith(filter));
2606
+ }
2607
+ previousArgHasChoices(args) {
2608
+ const choices = this.getPreviousArgChoices(args);
2609
+ return choices !== void 0 && choices.length > 0;
2610
+ }
2611
+ argsContainKey(args, key, negable) {
2612
+ const argsContains = (s) => args.indexOf((/^[^0-9]$/.test(s) ? "-" : "--") + s) !== -1;
2613
+ if (argsContains(key)) return true;
2614
+ if (negable && argsContains(`no-${key}`)) return true;
2615
+ if (this.aliases) {
2616
+ for (const alias of this.aliases[key]) if (argsContains(alias)) return true;
2617
+ }
2618
+ return false;
2619
+ }
2620
+ completeOptionKey(key, completions, current, negable) {
2621
+ var _a$1, _b$1, _c$1, _d;
2622
+ let keyWithDesc = key;
2623
+ if (this.zshShell) {
2624
+ const descs = this.usage.getDescriptions();
2625
+ const aliasKey = (_b$1 = (_a$1 = this === null || this === void 0 ? void 0 : this.aliases) === null || _a$1 === void 0 ? void 0 : _a$1[key]) === null || _b$1 === void 0 ? void 0 : _b$1.find((alias) => {
2626
+ const desc$1 = descs[alias];
2627
+ return typeof desc$1 === "string" && desc$1.length > 0;
2628
+ });
2629
+ const descFromAlias = aliasKey ? descs[aliasKey] : void 0;
2630
+ const desc = (_d = (_c$1 = descs[key]) !== null && _c$1 !== void 0 ? _c$1 : descFromAlias) !== null && _d !== void 0 ? _d : "";
2631
+ keyWithDesc = `${key.replace(/:/g, "\\:")}:${desc.replace("__yargsString__:", "").replace(/(\r\n|\n|\r)/gm, " ")}`;
2632
+ }
2633
+ const startsByTwoDashes = (s) => /^--/.test(s);
2634
+ const isShortOption = (s) => /^[^0-9]$/.test(s);
2635
+ const dashes = !startsByTwoDashes(current) && isShortOption(key) ? "-" : "--";
2636
+ completions.push(dashes + keyWithDesc);
2637
+ if (negable) completions.push(dashes + "no-" + keyWithDesc);
2638
+ }
2639
+ customCompletion(args, argv, current, done) {
2640
+ assertNotStrictEqual(this.customCompletionFunction, null, this.shim);
2641
+ if (isSyncCompletionFunction(this.customCompletionFunction)) {
2642
+ const result = this.customCompletionFunction(current, argv);
2643
+ if (isPromise(result)) return result.then((list) => {
2644
+ this.shim.process.nextTick(() => {
2645
+ done(null, list);
2646
+ });
2647
+ }).catch((err) => {
2648
+ this.shim.process.nextTick(() => {
2649
+ done(err, void 0);
2650
+ });
2651
+ });
2652
+ return done(null, result);
2653
+ } else if (isFallbackCompletionFunction(this.customCompletionFunction)) return this.customCompletionFunction(current, argv, (onCompleted = done) => this.defaultCompletion(args, argv, current, onCompleted), (completions) => {
2654
+ done(null, completions);
2655
+ });
2656
+ else return this.customCompletionFunction(current, argv, (completions) => {
2657
+ done(null, completions);
2658
+ });
2659
+ }
2660
+ getCompletion(args, done) {
2661
+ const current = args.length ? args[args.length - 1] : "";
2662
+ const argv = this.yargs.parse(args, true);
2663
+ const completionFunction = this.customCompletionFunction ? (argv$1) => this.customCompletion(args, argv$1, current, done) : (argv$1) => this.defaultCompletion(args, argv$1, current, done);
2664
+ return isPromise(argv) ? argv.then(completionFunction) : completionFunction(argv);
2665
+ }
2666
+ generateCompletionScript($0, cmd) {
2667
+ let script = this.zshShell ? completionZshTemplate : completionShTemplate;
2668
+ const name = this.shim.path.basename($0);
2669
+ if ($0.match(/\.js$/)) $0 = `./${$0}`;
2670
+ script = script.replace(/{{app_name}}/g, name);
2671
+ script = script.replace(/{{completion_command}}/g, cmd);
2672
+ return script.replace(/{{app_path}}/g, $0);
2673
+ }
2674
+ registerFunction(fn) {
2675
+ this.customCompletionFunction = fn;
2676
+ }
2677
+ setParsed(parsed) {
2678
+ this.aliases = parsed.aliases;
2679
+ }
2680
+ };
2681
+ function completion(yargs, usage$1, command$1, shim$2) {
2682
+ return new Completion(yargs, usage$1, command$1, shim$2);
2683
+ }
2684
+ function isSyncCompletionFunction(completionFunction) {
2685
+ return completionFunction.length < 3;
2686
+ }
2687
+ function isFallbackCompletionFunction(completionFunction) {
2688
+ return completionFunction.length > 3;
2689
+ }
2690
+
2691
+ //#endregion
2692
+ //#region node_modules/yargs/build/lib/utils/levenshtein.js
2693
+ function levenshtein(a, b) {
2694
+ if (a.length === 0) return b.length;
2695
+ if (b.length === 0) return a.length;
2696
+ const matrix = [];
2697
+ let i;
2698
+ for (i = 0; i <= b.length; i++) matrix[i] = [i];
2699
+ let j;
2700
+ for (j = 0; j <= a.length; j++) matrix[0][j] = j;
2701
+ 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];
2702
+ 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;
2703
+ else matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
2704
+ return matrix[b.length][a.length];
2705
+ }
2706
+
2707
+ //#endregion
2708
+ //#region node_modules/yargs/build/lib/validation.js
2709
+ const specialKeys = [
2710
+ "$0",
2711
+ "--",
2712
+ "_"
2713
+ ];
2714
+ function validation(yargs, usage$1, shim$2) {
2715
+ const __ = shim$2.y18n.__;
2716
+ const __n = shim$2.y18n.__n;
2717
+ const self = {};
2718
+ self.nonOptionCount = function nonOptionCount(argv) {
2719
+ const demandedCommands = yargs.getDemandedCommands();
2720
+ const _s = argv._.length + (argv["--"] ? argv["--"].length : 0) - yargs.getInternalMethods().getContext().commands.length;
2721
+ if (demandedCommands._ && (_s < demandedCommands._.min || _s > demandedCommands._.max)) {
2722
+ if (_s < demandedCommands._.min) if (demandedCommands._.minMsg !== void 0) usage$1.fail(demandedCommands._.minMsg ? demandedCommands._.minMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.min.toString()) : null);
2723
+ else usage$1.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()));
2724
+ else if (_s > demandedCommands._.max) if (demandedCommands._.maxMsg !== void 0) usage$1.fail(demandedCommands._.maxMsg ? demandedCommands._.maxMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.max.toString()) : null);
2725
+ else usage$1.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()));
2726
+ }
2727
+ };
2728
+ self.positionalCount = function positionalCount(required, observed) {
2729
+ if (observed < required) usage$1.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 + ""));
2730
+ };
2731
+ self.requiredArguments = function requiredArguments(argv, demandedOptions) {
2732
+ let missing = null;
2733
+ for (const key of Object.keys(demandedOptions)) if (!Object.prototype.hasOwnProperty.call(argv, key) || typeof argv[key] === "undefined") {
2734
+ missing = missing || {};
2735
+ missing[key] = demandedOptions[key];
2736
+ }
2737
+ if (missing) {
2738
+ const customMsgs = [];
2739
+ for (const key of Object.keys(missing)) {
2740
+ const msg = missing[key];
2741
+ if (msg && customMsgs.indexOf(msg) < 0) customMsgs.push(msg);
2742
+ }
2743
+ const customMsg = customMsgs.length ? `\n${customMsgs.join("\n")}` : "";
2744
+ usage$1.fail(__n("Missing required argument: %s", "Missing required arguments: %s", Object.keys(missing).length, Object.keys(missing).join(", ") + customMsg));
2745
+ }
2746
+ };
2747
+ self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
2748
+ var _a$1;
2749
+ const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
2750
+ const unknown = [];
2751
+ const currentContext = yargs.getInternalMethods().getContext();
2752
+ Object.keys(argv).forEach((key) => {
2753
+ 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);
2754
+ });
2755
+ if (checkPositionals && (currentContext.commands.length > 0 || commandKeys.length > 0 || isDefaultCommand)) argv._.slice(currentContext.commands.length).forEach((key) => {
2756
+ if (!commandKeys.includes("" + key)) unknown.push("" + key);
2757
+ });
2758
+ if (checkPositionals) {
2759
+ const maxNonOptDemanded = ((_a$1 = yargs.getDemandedCommands()._) === null || _a$1 === void 0 ? void 0 : _a$1.max) || 0;
2760
+ const expected = currentContext.commands.length + maxNonOptDemanded;
2761
+ if (expected < argv._.length) argv._.slice(expected).forEach((key) => {
2762
+ key = String(key);
2763
+ if (!currentContext.commands.includes(key) && !unknown.includes(key)) unknown.push(key);
2764
+ });
2765
+ }
2766
+ if (unknown.length) usage$1.fail(__n("Unknown argument: %s", "Unknown arguments: %s", unknown.length, unknown.map((s) => s.trim() ? s : `"${s}"`).join(", ")));
2767
+ };
2768
+ self.unknownCommands = function unknownCommands(argv) {
2769
+ const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
2770
+ const unknown = [];
2771
+ const currentContext = yargs.getInternalMethods().getContext();
2772
+ if (currentContext.commands.length > 0 || commandKeys.length > 0) argv._.slice(currentContext.commands.length).forEach((key) => {
2773
+ if (!commandKeys.includes("" + key)) unknown.push("" + key);
2774
+ });
2775
+ if (unknown.length > 0) {
2776
+ usage$1.fail(__n("Unknown command: %s", "Unknown commands: %s", unknown.length, unknown.join(", ")));
2777
+ return true;
2778
+ } else return false;
2779
+ };
2780
+ self.isValidAndSomeAliasIsNotNew = function isValidAndSomeAliasIsNotNew(key, aliases) {
2781
+ if (!Object.prototype.hasOwnProperty.call(aliases, key)) return false;
2782
+ const newAliases = yargs.parsed.newAliases;
2783
+ return [key, ...aliases[key]].some((a) => !Object.prototype.hasOwnProperty.call(newAliases, a) || !newAliases[key]);
2784
+ };
2785
+ self.limitedChoices = function limitedChoices(argv) {
2786
+ const options = yargs.getOptions();
2787
+ const invalid = {};
2788
+ if (!Object.keys(options.choices).length) return;
2789
+ Object.keys(argv).forEach((key) => {
2790
+ if (specialKeys.indexOf(key) === -1 && Object.prototype.hasOwnProperty.call(options.choices, key)) [].concat(argv[key]).forEach((value) => {
2791
+ if (options.choices[key].indexOf(value) === -1 && value !== void 0) invalid[key] = (invalid[key] || []).concat(value);
2792
+ });
2793
+ });
2794
+ const invalidKeys = Object.keys(invalid);
2795
+ if (!invalidKeys.length) return;
2796
+ let msg = __("Invalid values:");
2797
+ invalidKeys.forEach((key) => {
2798
+ msg += `\n ${__("Argument: %s, Given: %s, Choices: %s", key, usage$1.stringifiedValues(invalid[key]), usage$1.stringifiedValues(options.choices[key]))}`;
2799
+ });
2800
+ usage$1.fail(msg);
2801
+ };
2802
+ let implied = {};
2803
+ self.implies = function implies(key, value) {
2804
+ argsert("<string|object> [array|number|string]", [key, value], arguments.length);
2805
+ if (typeof key === "object") Object.keys(key).forEach((k) => {
2806
+ self.implies(k, key[k]);
2807
+ });
2808
+ else {
2809
+ yargs.global(key);
2810
+ if (!implied[key]) implied[key] = [];
2811
+ if (Array.isArray(value)) value.forEach((i) => self.implies(key, i));
2812
+ else {
2813
+ assertNotStrictEqual(value, void 0, shim$2);
2814
+ implied[key].push(value);
2815
+ }
2816
+ }
2817
+ };
2818
+ self.getImplied = function getImplied() {
2819
+ return implied;
2820
+ };
2821
+ function keyExists(argv, val) {
2822
+ const num = Number(val);
2823
+ val = isNaN(num) ? val : num;
2824
+ if (typeof val === "number") val = argv._.length >= val;
2825
+ else if (val.match(/^--no-.+/)) {
2826
+ val = val.match(/^--no-(.+)/)[1];
2827
+ val = !Object.prototype.hasOwnProperty.call(argv, val);
2828
+ } else val = Object.prototype.hasOwnProperty.call(argv, val);
2829
+ return val;
2830
+ }
2831
+ self.implications = function implications(argv) {
2832
+ const implyFail = [];
2833
+ Object.keys(implied).forEach((key) => {
2834
+ const origKey = key;
2835
+ (implied[key] || []).forEach((value) => {
2836
+ let key$1 = origKey;
2837
+ const origValue = value;
2838
+ key$1 = keyExists(argv, key$1);
2839
+ value = keyExists(argv, value);
2840
+ if (key$1 && !value) implyFail.push(` ${origKey} -> ${origValue}`);
2841
+ });
2842
+ });
2843
+ if (implyFail.length) {
2844
+ let msg = `${__("Implications failed:")}\n`;
2845
+ implyFail.forEach((value) => {
2846
+ msg += value;
2847
+ });
2848
+ usage$1.fail(msg);
2849
+ }
2850
+ };
2851
+ let conflicting = {};
2852
+ self.conflicts = function conflicts(key, value) {
2853
+ argsert("<string|object> [array|string]", [key, value], arguments.length);
2854
+ if (typeof key === "object") Object.keys(key).forEach((k) => {
2855
+ self.conflicts(k, key[k]);
2856
+ });
2857
+ else {
2858
+ yargs.global(key);
2859
+ if (!conflicting[key]) conflicting[key] = [];
2860
+ if (Array.isArray(value)) value.forEach((i) => self.conflicts(key, i));
2861
+ else conflicting[key].push(value);
2862
+ }
2863
+ };
2864
+ self.getConflicting = () => conflicting;
2865
+ self.conflicting = function conflictingFn(argv) {
2866
+ Object.keys(argv).forEach((key) => {
2867
+ if (conflicting[key]) conflicting[key].forEach((value) => {
2868
+ if (value && argv[key] !== void 0 && argv[value] !== void 0) usage$1.fail(__("Arguments %s and %s are mutually exclusive", key, value));
2869
+ });
2870
+ });
2871
+ if (yargs.getInternalMethods().getParserConfiguration()["strip-dashed"]) Object.keys(conflicting).forEach((key) => {
2872
+ conflicting[key].forEach((value) => {
2873
+ if (value && argv[shim$2.Parser.camelCase(key)] !== void 0 && argv[shim$2.Parser.camelCase(value)] !== void 0) usage$1.fail(__("Arguments %s and %s are mutually exclusive", key, value));
2874
+ });
2875
+ });
2876
+ };
2877
+ self.recommendCommands = function recommendCommands(cmd, potentialCommands) {
2878
+ const threshold = 3;
2879
+ potentialCommands = potentialCommands.sort((a, b) => b.length - a.length);
2880
+ let recommended = null;
2881
+ let bestDistance = Infinity;
2882
+ for (let i = 0, candidate; (candidate = potentialCommands[i]) !== void 0; i++) {
2883
+ const d = levenshtein(cmd, candidate);
2884
+ if (d <= threshold && d < bestDistance) {
2885
+ bestDistance = d;
2886
+ recommended = candidate;
2887
+ }
2888
+ }
2889
+ if (recommended) usage$1.fail(__("Did you mean %s?", recommended));
2890
+ };
2891
+ self.reset = function reset(localLookup) {
2892
+ implied = objFilter(implied, (k) => !localLookup[k]);
2893
+ conflicting = objFilter(conflicting, (k) => !localLookup[k]);
2894
+ return self;
2895
+ };
2896
+ const frozens = [];
2897
+ self.freeze = function freeze() {
2898
+ frozens.push({
2899
+ implied,
2900
+ conflicting
2901
+ });
2902
+ };
2903
+ self.unfreeze = function unfreeze() {
2904
+ const frozen = frozens.pop();
2905
+ assertNotStrictEqual(frozen, void 0, shim$2);
2906
+ ({implied, conflicting} = frozen);
2907
+ };
2908
+ return self;
2909
+ }
2910
+
2911
+ //#endregion
2912
+ //#region node_modules/yargs/build/lib/utils/apply-extends.js
2913
+ let previouslyVisitedConfigs = [];
2914
+ let shim;
2915
+ function applyExtends(config$1, cwd, mergeExtends, _shim) {
2916
+ shim = _shim;
2917
+ let defaultConfig = {};
2918
+ if (Object.prototype.hasOwnProperty.call(config$1, "extends")) {
2919
+ if (typeof config$1.extends !== "string") return defaultConfig;
2920
+ const isPath = /\.json|\..*rc$/.test(config$1.extends);
2921
+ let pathToDefault = null;
2922
+ if (!isPath) try {
2923
+ pathToDefault = import.meta.resolve(config$1.extends);
2924
+ } catch (_err) {
2925
+ return config$1;
2926
+ }
2927
+ else pathToDefault = getPathToDefaultConfig(cwd, config$1.extends);
2928
+ checkForCircularExtends(pathToDefault);
2929
+ previouslyVisitedConfigs.push(pathToDefault);
2930
+ defaultConfig = isPath ? JSON.parse(shim.readFileSync(pathToDefault, "utf8")) : _shim.require(config$1.extends);
2931
+ delete config$1.extends;
2932
+ defaultConfig = applyExtends(defaultConfig, shim.path.dirname(pathToDefault), mergeExtends, shim);
2933
+ }
2934
+ previouslyVisitedConfigs = [];
2935
+ return mergeExtends ? mergeDeep(defaultConfig, config$1) : Object.assign({}, defaultConfig, config$1);
2936
+ }
2937
+ function checkForCircularExtends(cfgPath) {
2938
+ if (previouslyVisitedConfigs.indexOf(cfgPath) > -1) throw new YError(`Circular extended configurations: '${cfgPath}'.`);
2939
+ }
2940
+ function getPathToDefaultConfig(cwd, pathToExtend) {
2941
+ return shim.path.resolve(cwd, pathToExtend);
2942
+ }
2943
+ function mergeDeep(config1, config2) {
2944
+ const target = {};
2945
+ function isObject(obj) {
2946
+ return obj && typeof obj === "object" && !Array.isArray(obj);
2947
+ }
2948
+ Object.assign(target, config1);
2949
+ for (const key of Object.keys(config2)) if (isObject(config2[key]) && isObject(target[key])) target[key] = mergeDeep(config1[key], config2[key]);
2950
+ else target[key] = config2[key];
2951
+ return target;
2952
+ }
2953
+
2954
+ //#endregion
2955
+ //#region node_modules/yargs/build/lib/yargs-factory.js
2956
+ var __classPrivateFieldSet = void 0 && (void 0).__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2957
+ if (kind === "m") throw new TypeError("Private method is not writable");
2958
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2959
+ 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");
2960
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2961
+ };
2962
+ var __classPrivateFieldGet = void 0 && (void 0).__classPrivateFieldGet || function(receiver, state, kind, f) {
2963
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2964
+ 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");
2965
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2966
+ };
2967
+ 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;
2968
+ function YargsFactory(_shim) {
2969
+ return (processArgs = [], cwd = _shim.process.cwd(), parentRequire) => {
2970
+ const yargs = new YargsInstance(processArgs, cwd, parentRequire, _shim);
2971
+ Object.defineProperty(yargs, "argv", {
2972
+ get: () => {
2973
+ return yargs.parse();
2974
+ },
2975
+ enumerable: true
2976
+ });
2977
+ yargs.help();
2978
+ yargs.version();
2979
+ return yargs;
2980
+ };
2981
+ }
2982
+ const kCopyDoubleDash = Symbol("copyDoubleDash");
2983
+ const kCreateLogger = Symbol("copyDoubleDash");
2984
+ const kDeleteFromParserHintObject = Symbol("deleteFromParserHintObject");
2985
+ const kEmitWarning = Symbol("emitWarning");
2986
+ const kFreeze = Symbol("freeze");
2987
+ const kGetDollarZero = Symbol("getDollarZero");
2988
+ const kGetParserConfiguration = Symbol("getParserConfiguration");
2989
+ const kGetUsageConfiguration = Symbol("getUsageConfiguration");
2990
+ const kGuessLocale = Symbol("guessLocale");
2991
+ const kGuessVersion = Symbol("guessVersion");
2992
+ const kParsePositionalNumbers = Symbol("parsePositionalNumbers");
2993
+ const kPkgUp = Symbol("pkgUp");
2994
+ const kPopulateParserHintArray = Symbol("populateParserHintArray");
2995
+ const kPopulateParserHintSingleValueDictionary = Symbol("populateParserHintSingleValueDictionary");
2996
+ const kPopulateParserHintArrayDictionary = Symbol("populateParserHintArrayDictionary");
2997
+ const kPopulateParserHintDictionary = Symbol("populateParserHintDictionary");
2998
+ const kSanitizeKey = Symbol("sanitizeKey");
2999
+ const kSetKey = Symbol("setKey");
3000
+ const kUnfreeze = Symbol("unfreeze");
3001
+ const kValidateAsync = Symbol("validateAsync");
3002
+ const kGetCommandInstance = Symbol("getCommandInstance");
3003
+ const kGetContext = Symbol("getContext");
3004
+ const kGetHasOutput = Symbol("getHasOutput");
3005
+ const kGetLoggerInstance = Symbol("getLoggerInstance");
3006
+ const kGetParseContext = Symbol("getParseContext");
3007
+ const kGetUsageInstance = Symbol("getUsageInstance");
3008
+ const kGetValidationInstance = Symbol("getValidationInstance");
3009
+ const kHasParseCallback = Symbol("hasParseCallback");
3010
+ const kIsGlobalContext = Symbol("isGlobalContext");
3011
+ const kPostProcess = Symbol("postProcess");
3012
+ const kRebase = Symbol("rebase");
3013
+ const kReset = Symbol("reset");
3014
+ const kRunYargsParserAndExecuteCommands = Symbol("runYargsParserAndExecuteCommands");
3015
+ const kRunValidation = Symbol("runValidation");
3016
+ const kSetHasOutput = Symbol("setHasOutput");
3017
+ const kTrackManuallySetKeys = Symbol("kTrackManuallySetKeys");
3018
+ const DEFAULT_LOCALE = "en_US";
3019
+ var YargsInstance = class {
3020
+ constructor(processArgs = [], cwd, parentRequire, shim$2) {
3021
+ this.customScriptName = false;
3022
+ this.parsed = false;
3023
+ _YargsInstance_command.set(this, void 0);
3024
+ _YargsInstance_cwd.set(this, void 0);
3025
+ _YargsInstance_context.set(this, {
3026
+ commands: [],
3027
+ fullCommands: []
3028
+ });
3029
+ _YargsInstance_completion.set(this, null);
3030
+ _YargsInstance_completionCommand.set(this, null);
3031
+ _YargsInstance_defaultShowHiddenOpt.set(this, "show-hidden");
3032
+ _YargsInstance_exitError.set(this, null);
3033
+ _YargsInstance_detectLocale.set(this, true);
3034
+ _YargsInstance_emittedWarnings.set(this, {});
3035
+ _YargsInstance_exitProcess.set(this, true);
3036
+ _YargsInstance_frozens.set(this, []);
3037
+ _YargsInstance_globalMiddleware.set(this, void 0);
3038
+ _YargsInstance_groups.set(this, {});
3039
+ _YargsInstance_hasOutput.set(this, false);
3040
+ _YargsInstance_helpOpt.set(this, null);
3041
+ _YargsInstance_isGlobalContext.set(this, true);
3042
+ _YargsInstance_logger.set(this, void 0);
3043
+ _YargsInstance_output.set(this, "");
3044
+ _YargsInstance_options.set(this, void 0);
3045
+ _YargsInstance_parentRequire.set(this, void 0);
3046
+ _YargsInstance_parserConfig.set(this, {});
3047
+ _YargsInstance_parseFn.set(this, null);
3048
+ _YargsInstance_parseContext.set(this, null);
3049
+ _YargsInstance_pkgs.set(this, {});
3050
+ _YargsInstance_preservedGroups.set(this, {});
3051
+ _YargsInstance_processArgs.set(this, void 0);
3052
+ _YargsInstance_recommendCommands.set(this, false);
3053
+ _YargsInstance_shim.set(this, void 0);
3054
+ _YargsInstance_strict.set(this, false);
3055
+ _YargsInstance_strictCommands.set(this, false);
3056
+ _YargsInstance_strictOptions.set(this, false);
3057
+ _YargsInstance_usage.set(this, void 0);
3058
+ _YargsInstance_usageConfig.set(this, {});
3059
+ _YargsInstance_versionOpt.set(this, null);
3060
+ _YargsInstance_validation.set(this, void 0);
3061
+ __classPrivateFieldSet(this, _YargsInstance_shim, shim$2, "f");
3062
+ __classPrivateFieldSet(this, _YargsInstance_processArgs, processArgs, "f");
3063
+ __classPrivateFieldSet(this, _YargsInstance_cwd, cwd, "f");
3064
+ __classPrivateFieldSet(this, _YargsInstance_parentRequire, parentRequire, "f");
3065
+ __classPrivateFieldSet(this, _YargsInstance_globalMiddleware, new GlobalMiddleware(this), "f");
3066
+ this.$0 = this[kGetDollarZero]();
3067
+ this[kReset]();
3068
+ __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f"), "f");
3069
+ __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), "f");
3070
+ __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f"), "f");
3071
+ __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f"), "f");
3072
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
3073
+ __classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger](), "f");
3074
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(DEFAULT_LOCALE);
3075
+ }
3076
+ addHelpOpt(opt, msg) {
3077
+ const defaultHelpOpt = "help";
3078
+ argsert("[string|boolean] [string]", [opt, msg], arguments.length);
3079
+ if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
3080
+ this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
3081
+ __classPrivateFieldSet(this, _YargsInstance_helpOpt, null, "f");
3082
+ }
3083
+ if (opt === false && msg === void 0) return this;
3084
+ __classPrivateFieldSet(this, _YargsInstance_helpOpt, typeof opt === "string" ? opt : defaultHelpOpt, "f");
3085
+ this.boolean(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
3086
+ this.describe(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"), msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show help"));
3087
+ return this;
3088
+ }
3089
+ help(opt, msg) {
3090
+ return this.addHelpOpt(opt, msg);
3091
+ }
3092
+ addShowHiddenOpt(opt, msg) {
3093
+ argsert("[string|boolean] [string]", [opt, msg], arguments.length);
3094
+ if (opt === false && msg === void 0) return this;
3095
+ const showHiddenOpt = typeof opt === "string" ? opt : __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
3096
+ this.boolean(showHiddenOpt);
3097
+ this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show hidden options"));
3098
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = showHiddenOpt;
3099
+ return this;
3100
+ }
3101
+ showHidden(opt, msg) {
3102
+ return this.addShowHiddenOpt(opt, msg);
3103
+ }
3104
+ alias(key, value) {
3105
+ argsert("<object|string|array> [string|array]", [key, value], arguments.length);
3106
+ this[kPopulateParserHintArrayDictionary](this.alias.bind(this), "alias", key, value);
3107
+ return this;
3108
+ }
3109
+ array(keys) {
3110
+ argsert("<array|string>", [keys], arguments.length);
3111
+ this[kPopulateParserHintArray]("array", keys);
3112
+ this[kTrackManuallySetKeys](keys);
3113
+ return this;
3114
+ }
3115
+ boolean(keys) {
3116
+ argsert("<array|string>", [keys], arguments.length);
3117
+ this[kPopulateParserHintArray]("boolean", keys);
3118
+ this[kTrackManuallySetKeys](keys);
3119
+ return this;
3120
+ }
3121
+ check(f, global) {
3122
+ argsert("<function> [boolean]", [f, global], arguments.length);
3123
+ this.middleware((argv, _yargs) => {
3124
+ return maybeAsyncResult(() => {
3125
+ return f(argv, _yargs.getOptions());
3126
+ }, (result) => {
3127
+ if (!result) __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__("Argument check failed: %s", f.toString()));
3128
+ else if (typeof result === "string" || result instanceof Error) __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(result.toString(), result);
3129
+ return argv;
3130
+ }, (err) => {
3131
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message ? err.message : err.toString(), err);
3132
+ return argv;
3133
+ });
3134
+ }, false, global);
3135
+ return this;
3136
+ }
3137
+ choices(key, value) {
3138
+ argsert("<object|string|array> [string|array]", [key, value], arguments.length);
3139
+ this[kPopulateParserHintArrayDictionary](this.choices.bind(this), "choices", key, value);
3140
+ return this;
3141
+ }
3142
+ coerce(keys, value) {
3143
+ argsert("<object|string|array> [function]", [keys, value], arguments.length);
3144
+ if (Array.isArray(keys)) {
3145
+ if (!value) throw new YError("coerce callback must be provided");
3146
+ for (const key of keys) this.coerce(key, value);
3147
+ return this;
3148
+ } else if (typeof keys === "object") {
3149
+ for (const key of Object.keys(keys)) this.coerce(key, keys[key]);
3150
+ return this;
3151
+ }
3152
+ if (!value) throw new YError("coerce callback must be provided");
3153
+ const coerceKey = keys;
3154
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[coerceKey] = true;
3155
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
3156
+ var _a$1;
3157
+ const argvKeys = [coerceKey, ...(_a$1 = yargs.getAliases()[coerceKey]) !== null && _a$1 !== void 0 ? _a$1 : []].filter((key) => Object.prototype.hasOwnProperty.call(argv, key));
3158
+ if (argvKeys.length === 0) return argv;
3159
+ return maybeAsyncResult(() => {
3160
+ return value(argv[argvKeys[0]]);
3161
+ }, (result) => {
3162
+ argvKeys.forEach((key) => {
3163
+ argv[key] = result;
3164
+ });
3165
+ return argv;
3166
+ }, (err) => {
3167
+ throw new YError(err.message);
3168
+ });
3169
+ }, coerceKey);
3170
+ return this;
3171
+ }
3172
+ conflicts(key1, key2) {
3173
+ argsert("<string|object> [string|array]", [key1, key2], arguments.length);
3174
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicts(key1, key2);
3175
+ return this;
3176
+ }
3177
+ config(key = "config", msg, parseFn) {
3178
+ argsert("[object|string] [string|function] [function]", [
3179
+ key,
3180
+ msg,
3181
+ parseFn
3182
+ ], arguments.length);
3183
+ if (typeof key === "object" && !Array.isArray(key)) {
3184
+ key = applyExtends(key, __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3185
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(key);
3186
+ return this;
3187
+ }
3188
+ if (typeof msg === "function") {
3189
+ parseFn = msg;
3190
+ msg = void 0;
3191
+ }
3192
+ this.describe(key, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Path to JSON config file"));
3193
+ (Array.isArray(key) ? key : [key]).forEach((k) => {
3194
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").config[k] = parseFn || true;
3195
+ });
3196
+ return this;
3197
+ }
3198
+ completion(cmd, desc, fn) {
3199
+ argsert("[string] [string|boolean|function] [function]", [
3200
+ cmd,
3201
+ desc,
3202
+ fn
3203
+ ], arguments.length);
3204
+ if (typeof desc === "function") {
3205
+ fn = desc;
3206
+ desc = void 0;
3207
+ }
3208
+ __classPrivateFieldSet(this, _YargsInstance_completionCommand, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion", "f");
3209
+ if (!desc && desc !== false) desc = "generate completion script";
3210
+ this.command(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), desc);
3211
+ if (fn) __classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn);
3212
+ return this;
3213
+ }
3214
+ command(cmd, description, builder, handler, middlewares, deprecated) {
3215
+ argsert("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]", [
3216
+ cmd,
3217
+ description,
3218
+ builder,
3219
+ handler,
3220
+ middlewares,
3221
+ deprecated
3222
+ ], arguments.length);
3223
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description, builder, handler, middlewares, deprecated);
3224
+ return this;
3225
+ }
3226
+ commands(cmd, description, builder, handler, middlewares, deprecated) {
3227
+ return this.command(cmd, description, builder, handler, middlewares, deprecated);
3228
+ }
3229
+ commandDir(dir, opts) {
3230
+ argsert("<string> [object]", [dir, opts], arguments.length);
3231
+ const req = __classPrivateFieldGet(this, _YargsInstance_parentRequire, "f") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").require;
3232
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").addDirectory(dir, req, __classPrivateFieldGet(this, _YargsInstance_shim, "f").getCallerFile(), opts);
3233
+ return this;
3234
+ }
3235
+ count(keys) {
3236
+ argsert("<array|string>", [keys], arguments.length);
3237
+ this[kPopulateParserHintArray]("count", keys);
3238
+ this[kTrackManuallySetKeys](keys);
3239
+ return this;
3240
+ }
3241
+ default(key, value, defaultDescription) {
3242
+ argsert("<object|string|array> [*] [string]", [
3243
+ key,
3244
+ value,
3245
+ defaultDescription
3246
+ ], arguments.length);
3247
+ if (defaultDescription) {
3248
+ assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3249
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = defaultDescription;
3250
+ }
3251
+ if (typeof value === "function") {
3252
+ assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3253
+ if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key]) __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = __classPrivateFieldGet(this, _YargsInstance_usage, "f").functionDescription(value);
3254
+ value = value.call();
3255
+ }
3256
+ this[kPopulateParserHintSingleValueDictionary](this.default.bind(this), "default", key, value);
3257
+ return this;
3258
+ }
3259
+ defaults(key, value, defaultDescription) {
3260
+ return this.default(key, value, defaultDescription);
3261
+ }
3262
+ demandCommand(min = 1, max, minMsg, maxMsg) {
3263
+ argsert("[number] [number|string] [string|null|undefined] [string|null|undefined]", [
3264
+ min,
3265
+ max,
3266
+ minMsg,
3267
+ maxMsg
3268
+ ], arguments.length);
3269
+ if (typeof max !== "number") {
3270
+ minMsg = max;
3271
+ max = Infinity;
3272
+ }
3273
+ this.global("_", false);
3274
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands._ = {
3275
+ min,
3276
+ max,
3277
+ minMsg,
3278
+ maxMsg
3279
+ };
3280
+ return this;
3281
+ }
3282
+ demand(keys, max, msg) {
3283
+ if (Array.isArray(max)) {
3284
+ max.forEach((key) => {
3285
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3286
+ this.demandOption(key, msg);
3287
+ });
3288
+ max = Infinity;
3289
+ } else if (typeof max !== "number") {
3290
+ msg = max;
3291
+ max = Infinity;
3292
+ }
3293
+ if (typeof keys === "number") {
3294
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3295
+ this.demandCommand(keys, max, msg, msg);
3296
+ } else if (Array.isArray(keys)) keys.forEach((key) => {
3297
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3298
+ this.demandOption(key, msg);
3299
+ });
3300
+ else if (typeof msg === "string") this.demandOption(keys, msg);
3301
+ else if (msg === true || typeof msg === "undefined") this.demandOption(keys);
3302
+ return this;
3303
+ }
3304
+ demandOption(keys, msg) {
3305
+ argsert("<object|string|array> [string]", [keys, msg], arguments.length);
3306
+ this[kPopulateParserHintSingleValueDictionary](this.demandOption.bind(this), "demandedOptions", keys, msg);
3307
+ return this;
3308
+ }
3309
+ deprecateOption(option, message) {
3310
+ argsert("<string> [string|boolean]", [option, message], arguments.length);
3311
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message;
3312
+ return this;
3313
+ }
3314
+ describe(keys, description) {
3315
+ argsert("<object|string|array> [string]", [keys, description], arguments.length);
3316
+ this[kSetKey](keys, true);
3317
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description);
3318
+ return this;
3319
+ }
3320
+ detectLocale(detect) {
3321
+ argsert("<boolean>", [detect], arguments.length);
3322
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, detect, "f");
3323
+ return this;
3324
+ }
3325
+ env(prefix) {
3326
+ argsert("[string|boolean]", [prefix], arguments.length);
3327
+ if (prefix === false) delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
3328
+ else __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix || "";
3329
+ return this;
3330
+ }
3331
+ epilogue(msg) {
3332
+ argsert("<string>", [msg], arguments.length);
3333
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").epilog(msg);
3334
+ return this;
3335
+ }
3336
+ epilog(msg) {
3337
+ return this.epilogue(msg);
3338
+ }
3339
+ example(cmd, description) {
3340
+ argsert("<string|array> [string]", [cmd, description], arguments.length);
3341
+ if (Array.isArray(cmd)) cmd.forEach((exampleParams) => this.example(...exampleParams));
3342
+ else __classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description);
3343
+ return this;
3344
+ }
3345
+ exit(code, err) {
3346
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3347
+ __classPrivateFieldSet(this, _YargsInstance_exitError, err, "f");
3348
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.exit(code);
3349
+ }
3350
+ exitProcess(enabled = true) {
3351
+ argsert("[boolean]", [enabled], arguments.length);
3352
+ __classPrivateFieldSet(this, _YargsInstance_exitProcess, enabled, "f");
3353
+ return this;
3354
+ }
3355
+ fail(f) {
3356
+ argsert("<function|boolean>", [f], arguments.length);
3357
+ if (typeof f === "boolean" && f !== false) throw new YError("Invalid first argument. Expected function or boolean 'false'");
3358
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").failFn(f);
3359
+ return this;
3360
+ }
3361
+ getAliases() {
3362
+ return this.parsed ? this.parsed.aliases : {};
3363
+ }
3364
+ async getCompletion(args, done) {
3365
+ argsert("<array> [function]", [args, done], arguments.length);
3366
+ if (!done) return new Promise((resolve$1, reject) => {
3367
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
3368
+ if (err) reject(err);
3369
+ else resolve$1(completions);
3370
+ });
3371
+ });
3372
+ else return __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, done);
3373
+ }
3374
+ getDemandedOptions() {
3375
+ argsert([], 0);
3376
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedOptions;
3377
+ }
3378
+ getDemandedCommands() {
3379
+ argsert([], 0);
3380
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands;
3381
+ }
3382
+ getDeprecatedOptions() {
3383
+ argsert([], 0);
3384
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions;
3385
+ }
3386
+ getDetectLocale() {
3387
+ return __classPrivateFieldGet(this, _YargsInstance_detectLocale, "f");
3388
+ }
3389
+ getExitProcess() {
3390
+ return __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f");
3391
+ }
3392
+ getGroups() {
3393
+ return Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_groups, "f"), __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"));
3394
+ }
3395
+ getHelp() {
3396
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3397
+ if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
3398
+ if (!this.parsed) {
3399
+ const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true);
3400
+ if (isPromise(parse)) return parse.then(() => {
3401
+ return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
3402
+ });
3403
+ }
3404
+ const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
3405
+ if (isPromise(builderResponse)) return builderResponse.then(() => {
3406
+ return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
3407
+ });
3408
+ }
3409
+ return Promise.resolve(__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
3410
+ }
3411
+ getOptions() {
3412
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f");
3413
+ }
3414
+ getStrict() {
3415
+ return __classPrivateFieldGet(this, _YargsInstance_strict, "f");
3416
+ }
3417
+ getStrictCommands() {
3418
+ return __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f");
3419
+ }
3420
+ getStrictOptions() {
3421
+ return __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f");
3422
+ }
3423
+ global(globals, global) {
3424
+ argsert("<string|array> [boolean]", [globals, global], arguments.length);
3425
+ globals = [].concat(globals);
3426
+ if (global !== false) __classPrivateFieldGet(this, _YargsInstance_options, "f").local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local.filter((l) => globals.indexOf(l) === -1);
3427
+ else globals.forEach((g) => {
3428
+ if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").local.includes(g)) __classPrivateFieldGet(this, _YargsInstance_options, "f").local.push(g);
3429
+ });
3430
+ return this;
3431
+ }
3432
+ group(opts, groupName) {
3433
+ argsert("<string|array> <string>", [opts, groupName], arguments.length);
3434
+ const existing = __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName] || __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName];
3435
+ if (__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]) delete __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName];
3436
+ const seen = {};
3437
+ __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName] = (existing || []).concat(opts).filter((key) => {
3438
+ if (seen[key]) return false;
3439
+ return seen[key] = true;
3440
+ });
3441
+ return this;
3442
+ }
3443
+ hide(key) {
3444
+ argsert("<string>", [key], arguments.length);
3445
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").hiddenOptions.push(key);
3446
+ return this;
3447
+ }
3448
+ implies(key, value) {
3449
+ argsert("<string|object> [number|string|array]", [key, value], arguments.length);
3450
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").implies(key, value);
3451
+ return this;
3452
+ }
3453
+ locale(locale) {
3454
+ argsert("[string]", [locale], arguments.length);
3455
+ if (locale === void 0) {
3456
+ this[kGuessLocale]();
3457
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
3458
+ }
3459
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
3460
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(locale);
3461
+ return this;
3462
+ }
3463
+ middleware(callback, applyBeforeValidation, global) {
3464
+ return __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addMiddleware(callback, !!applyBeforeValidation, global);
3465
+ }
3466
+ nargs(key, value) {
3467
+ argsert("<string|object|array> [number]", [key, value], arguments.length);
3468
+ this[kPopulateParserHintSingleValueDictionary](this.nargs.bind(this), "narg", key, value);
3469
+ return this;
3470
+ }
3471
+ normalize(keys) {
3472
+ argsert("<array|string>", [keys], arguments.length);
3473
+ this[kPopulateParserHintArray]("normalize", keys);
3474
+ return this;
3475
+ }
3476
+ number(keys) {
3477
+ argsert("<array|string>", [keys], arguments.length);
3478
+ this[kPopulateParserHintArray]("number", keys);
3479
+ this[kTrackManuallySetKeys](keys);
3480
+ return this;
3481
+ }
3482
+ option(key, opt) {
3483
+ argsert("<string|object> [object]", [key, opt], arguments.length);
3484
+ if (typeof key === "object") Object.keys(key).forEach((k) => {
3485
+ this.options(k, key[k]);
3486
+ });
3487
+ else {
3488
+ if (typeof opt !== "object") opt = {};
3489
+ this[kTrackManuallySetKeys](key);
3490
+ if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && (key === "version" || (opt === null || opt === void 0 ? void 0 : opt.alias) === "version")) this[kEmitWarning]([
3491
+ "\"version\" is a reserved word.",
3492
+ "Please do one of the following:",
3493
+ "- Disable version with `yargs.version(false)` if using \"version\" as an option",
3494
+ "- Use the built-in `yargs.version` method instead (if applicable)",
3495
+ "- Use a different option key",
3496
+ "https://yargs.js.org/docs/#api-reference-version"
3497
+ ].join("\n"), void 0, "versionWarning");
3498
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[key] = true;
3499
+ if (opt.alias) this.alias(key, opt.alias);
3500
+ const deprecate = opt.deprecate || opt.deprecated;
3501
+ if (deprecate) this.deprecateOption(key, deprecate);
3502
+ const demand = opt.demand || opt.required || opt.require;
3503
+ if (demand) this.demand(key, demand);
3504
+ if (opt.demandOption) this.demandOption(key, typeof opt.demandOption === "string" ? opt.demandOption : void 0);
3505
+ if (opt.conflicts) this.conflicts(key, opt.conflicts);
3506
+ if ("default" in opt) this.default(key, opt.default);
3507
+ if (opt.implies !== void 0) this.implies(key, opt.implies);
3508
+ if (opt.nargs !== void 0) this.nargs(key, opt.nargs);
3509
+ if (opt.config) this.config(key, opt.configParser);
3510
+ if (opt.normalize) this.normalize(key);
3511
+ if (opt.choices) this.choices(key, opt.choices);
3512
+ if (opt.coerce) this.coerce(key, opt.coerce);
3513
+ if (opt.group) this.group(key, opt.group);
3514
+ if (opt.boolean || opt.type === "boolean") {
3515
+ this.boolean(key);
3516
+ if (opt.alias) this.boolean(opt.alias);
3517
+ }
3518
+ if (opt.array || opt.type === "array") {
3519
+ this.array(key);
3520
+ if (opt.alias) this.array(opt.alias);
3521
+ }
3522
+ if (opt.number || opt.type === "number") {
3523
+ this.number(key);
3524
+ if (opt.alias) this.number(opt.alias);
3525
+ }
3526
+ if (opt.string || opt.type === "string") {
3527
+ this.string(key);
3528
+ if (opt.alias) this.string(opt.alias);
3529
+ }
3530
+ if (opt.count || opt.type === "count") this.count(key);
3531
+ if (typeof opt.global === "boolean") this.global(key, opt.global);
3532
+ if (opt.defaultDescription) __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = opt.defaultDescription;
3533
+ if (opt.skipValidation) this.skipValidation(key);
3534
+ const desc = opt.describe || opt.description || opt.desc;
3535
+ const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions();
3536
+ if (!Object.prototype.hasOwnProperty.call(descriptions, key) || typeof desc === "string") this.describe(key, desc);
3537
+ if (opt.hidden) this.hide(key);
3538
+ if (opt.requiresArg) this.requiresArg(key);
3539
+ }
3540
+ return this;
3541
+ }
3542
+ options(key, opt) {
3543
+ return this.option(key, opt);
3544
+ }
3545
+ parse(args, shortCircuit, _parseFn) {
3546
+ argsert("[string|array] [function|boolean|object] [function]", [
3547
+ args,
3548
+ shortCircuit,
3549
+ _parseFn
3550
+ ], arguments.length);
3551
+ this[kFreeze]();
3552
+ if (typeof args === "undefined") args = __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
3553
+ if (typeof shortCircuit === "object") {
3554
+ __classPrivateFieldSet(this, _YargsInstance_parseContext, shortCircuit, "f");
3555
+ shortCircuit = _parseFn;
3556
+ }
3557
+ if (typeof shortCircuit === "function") {
3558
+ __classPrivateFieldSet(this, _YargsInstance_parseFn, shortCircuit, "f");
3559
+ shortCircuit = false;
3560
+ }
3561
+ if (!shortCircuit) __classPrivateFieldSet(this, _YargsInstance_processArgs, args, "f");
3562
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldSet(this, _YargsInstance_exitProcess, false, "f");
3563
+ const parsed = this[kRunYargsParserAndExecuteCommands](args, !!shortCircuit);
3564
+ const tmpParsed = this.parsed;
3565
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").setParsed(this.parsed);
3566
+ if (isPromise(parsed)) return parsed.then((argv) => {
3567
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
3568
+ return argv;
3569
+ }).catch((err) => {
3570
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldGet(this, _YargsInstance_parseFn, "f")(err, this.parsed.argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
3571
+ throw err;
3572
+ }).finally(() => {
3573
+ this[kUnfreeze]();
3574
+ this.parsed = tmpParsed;
3575
+ });
3576
+ else {
3577
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), parsed, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
3578
+ this[kUnfreeze]();
3579
+ this.parsed = tmpParsed;
3580
+ }
3581
+ return parsed;
3582
+ }
3583
+ parseAsync(args, shortCircuit, _parseFn) {
3584
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
3585
+ return !isPromise(maybePromise) ? Promise.resolve(maybePromise) : maybePromise;
3586
+ }
3587
+ parseSync(args, shortCircuit, _parseFn) {
3588
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
3589
+ if (isPromise(maybePromise)) throw new YError(".parseSync() must not be used with asynchronous builders, handlers, or middleware");
3590
+ return maybePromise;
3591
+ }
3592
+ parserConfiguration(config$1) {
3593
+ argsert("<object>", [config$1], arguments.length);
3594
+ __classPrivateFieldSet(this, _YargsInstance_parserConfig, config$1, "f");
3595
+ return this;
3596
+ }
3597
+ pkgConf(key, rootPath) {
3598
+ argsert("<string> [string]", [key, rootPath], arguments.length);
3599
+ let conf = null;
3600
+ const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"));
3601
+ if (obj[key] && typeof obj[key] === "object") {
3602
+ conf = applyExtends(obj[key], rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3603
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(conf);
3604
+ }
3605
+ return this;
3606
+ }
3607
+ positional(key, opts) {
3608
+ argsert("<string> <object>", [key, opts], arguments.length);
3609
+ const supportedOpts = [
3610
+ "default",
3611
+ "defaultDescription",
3612
+ "implies",
3613
+ "normalize",
3614
+ "choices",
3615
+ "conflicts",
3616
+ "coerce",
3617
+ "type",
3618
+ "describe",
3619
+ "desc",
3620
+ "description",
3621
+ "alias"
3622
+ ];
3623
+ opts = objFilter(opts, (k, v) => {
3624
+ if (k === "type" && ![
3625
+ "string",
3626
+ "number",
3627
+ "boolean"
3628
+ ].includes(v)) return false;
3629
+ return supportedOpts.includes(k);
3630
+ });
3631
+ const fullCommand = __classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands[__classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands.length - 1];
3632
+ const parseOptions = fullCommand ? __classPrivateFieldGet(this, _YargsInstance_command, "f").cmdToParseOptions(fullCommand) : {
3633
+ array: [],
3634
+ alias: {},
3635
+ default: {},
3636
+ demand: {}
3637
+ };
3638
+ objectKeys(parseOptions).forEach((pk) => {
3639
+ const parseOption = parseOptions[pk];
3640
+ if (Array.isArray(parseOption)) {
3641
+ if (parseOption.indexOf(key) !== -1) opts[pk] = true;
3642
+ } else if (parseOption[key] && !(pk in opts)) opts[pk] = parseOption[key];
3643
+ });
3644
+ this.group(key, __classPrivateFieldGet(this, _YargsInstance_usage, "f").getPositionalGroupName());
3645
+ return this.option(key, opts);
3646
+ }
3647
+ recommendCommands(recommend = true) {
3648
+ argsert("[boolean]", [recommend], arguments.length);
3649
+ __classPrivateFieldSet(this, _YargsInstance_recommendCommands, recommend, "f");
3650
+ return this;
3651
+ }
3652
+ required(keys, max, msg) {
3653
+ return this.demand(keys, max, msg);
3654
+ }
3655
+ require(keys, max, msg) {
3656
+ return this.demand(keys, max, msg);
3657
+ }
3658
+ requiresArg(keys) {
3659
+ argsert("<array|string|object> [number]", [keys], arguments.length);
3660
+ if (typeof keys === "string" && __classPrivateFieldGet(this, _YargsInstance_options, "f").narg[keys]) return this;
3661
+ else this[kPopulateParserHintSingleValueDictionary](this.requiresArg.bind(this), "narg", keys, NaN);
3662
+ return this;
3663
+ }
3664
+ showCompletionScript($0, cmd) {
3665
+ argsert("[string] [string]", [$0, cmd], arguments.length);
3666
+ $0 = $0 || this.$0;
3667
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(__classPrivateFieldGet(this, _YargsInstance_completion, "f").generateCompletionScript($0, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion"));
3668
+ return this;
3669
+ }
3670
+ showHelp(level) {
3671
+ argsert("[string|function]", [level], arguments.length);
3672
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3673
+ if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
3674
+ if (!this.parsed) {
3675
+ const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true);
3676
+ if (isPromise(parse)) {
3677
+ parse.then(() => {
3678
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
3679
+ });
3680
+ return this;
3681
+ }
3682
+ }
3683
+ const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
3684
+ if (isPromise(builderResponse)) {
3685
+ builderResponse.then(() => {
3686
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
3687
+ });
3688
+ return this;
3689
+ }
3690
+ }
3691
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
3692
+ return this;
3693
+ }
3694
+ scriptName(scriptName) {
3695
+ this.customScriptName = true;
3696
+ this.$0 = scriptName;
3697
+ return this;
3698
+ }
3699
+ showHelpOnFail(enabled, message) {
3700
+ argsert("[boolean|string] [string]", [enabled, message], arguments.length);
3701
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelpOnFail(enabled, message);
3702
+ return this;
3703
+ }
3704
+ showVersion(level) {
3705
+ argsert("[string|function]", [level], arguments.length);
3706
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion(level);
3707
+ return this;
3708
+ }
3709
+ skipValidation(keys) {
3710
+ argsert("<array|string>", [keys], arguments.length);
3711
+ this[kPopulateParserHintArray]("skipValidation", keys);
3712
+ return this;
3713
+ }
3714
+ strict(enabled) {
3715
+ argsert("[boolean]", [enabled], arguments.length);
3716
+ __classPrivateFieldSet(this, _YargsInstance_strict, enabled !== false, "f");
3717
+ return this;
3718
+ }
3719
+ strictCommands(enabled) {
3720
+ argsert("[boolean]", [enabled], arguments.length);
3721
+ __classPrivateFieldSet(this, _YargsInstance_strictCommands, enabled !== false, "f");
3722
+ return this;
3723
+ }
3724
+ strictOptions(enabled) {
3725
+ argsert("[boolean]", [enabled], arguments.length);
3726
+ __classPrivateFieldSet(this, _YargsInstance_strictOptions, enabled !== false, "f");
3727
+ return this;
3728
+ }
3729
+ string(keys) {
3730
+ argsert("<array|string>", [keys], arguments.length);
3731
+ this[kPopulateParserHintArray]("string", keys);
3732
+ this[kTrackManuallySetKeys](keys);
3733
+ return this;
3734
+ }
3735
+ terminalWidth() {
3736
+ argsert([], 0);
3737
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.stdColumns;
3738
+ }
3739
+ updateLocale(obj) {
3740
+ return this.updateStrings(obj);
3741
+ }
3742
+ updateStrings(obj) {
3743
+ argsert("<object>", [obj], arguments.length);
3744
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
3745
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj);
3746
+ return this;
3747
+ }
3748
+ usage(msg, description, builder, handler) {
3749
+ argsert("<string|null|undefined> [string|boolean] [function|object] [function]", [
3750
+ msg,
3751
+ description,
3752
+ builder,
3753
+ handler
3754
+ ], arguments.length);
3755
+ if (description !== void 0) {
3756
+ assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3757
+ if ((msg || "").match(/^\$0( |$)/)) return this.command(msg, description, builder, handler);
3758
+ else throw new YError(".usage() description must start with $0 if being used as alias for .command()");
3759
+ } else {
3760
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").usage(msg);
3761
+ return this;
3762
+ }
3763
+ }
3764
+ usageConfiguration(config$1) {
3765
+ argsert("<object>", [config$1], arguments.length);
3766
+ __classPrivateFieldSet(this, _YargsInstance_usageConfig, config$1, "f");
3767
+ return this;
3768
+ }
3769
+ version(opt, msg, ver) {
3770
+ const defaultVersionOpt = "version";
3771
+ argsert("[boolean|string] [string] [string]", [
3772
+ opt,
3773
+ msg,
3774
+ ver
3775
+ ], arguments.length);
3776
+ if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")) {
3777
+ this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
3778
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(void 0);
3779
+ __classPrivateFieldSet(this, _YargsInstance_versionOpt, null, "f");
3780
+ }
3781
+ if (arguments.length === 0) {
3782
+ ver = this[kGuessVersion]();
3783
+ opt = defaultVersionOpt;
3784
+ } else if (arguments.length === 1) {
3785
+ if (opt === false) return this;
3786
+ ver = opt;
3787
+ opt = defaultVersionOpt;
3788
+ } else if (arguments.length === 2) {
3789
+ ver = msg;
3790
+ msg = void 0;
3791
+ }
3792
+ __classPrivateFieldSet(this, _YargsInstance_versionOpt, typeof opt === "string" ? opt : defaultVersionOpt, "f");
3793
+ msg = msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show version number");
3794
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(ver || void 0);
3795
+ this.boolean(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
3796
+ this.describe(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"), msg);
3797
+ return this;
3798
+ }
3799
+ wrap(cols) {
3800
+ argsert("<number|null|undefined>", [cols], arguments.length);
3801
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
3802
+ return this;
3803
+ }
3804
+ [(_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) {
3805
+ if (!argv._ || !argv["--"]) return argv;
3806
+ argv._.push.apply(argv._, argv["--"]);
3807
+ try {
3808
+ delete argv["--"];
3809
+ } catch (_err) {}
3810
+ return argv;
3811
+ }
3812
+ [kCreateLogger]() {
3813
+ return {
3814
+ log: (...args) => {
3815
+ if (!this[kHasParseCallback]()) console.log(...args);
3816
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3817
+ if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length) __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + "\n", "f");
3818
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
3819
+ },
3820
+ error: (...args) => {
3821
+ if (!this[kHasParseCallback]()) console.error(...args);
3822
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3823
+ if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length) __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + "\n", "f");
3824
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
3825
+ }
3826
+ };
3827
+ }
3828
+ [kDeleteFromParserHintObject](optionKey) {
3829
+ objectKeys(__classPrivateFieldGet(this, _YargsInstance_options, "f")).forEach((hintKey) => {
3830
+ if (((key) => key === "configObjects")(hintKey)) return;
3831
+ const hint = __classPrivateFieldGet(this, _YargsInstance_options, "f")[hintKey];
3832
+ if (Array.isArray(hint)) {
3833
+ if (hint.includes(optionKey)) hint.splice(hint.indexOf(optionKey), 1);
3834
+ } else if (typeof hint === "object") delete hint[optionKey];
3835
+ });
3836
+ delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
3837
+ }
3838
+ [kEmitWarning](warning, type, deduplicationId) {
3839
+ if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) {
3840
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type);
3841
+ __classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true;
3842
+ }
3843
+ }
3844
+ [kFreeze]() {
3845
+ __classPrivateFieldGet(this, _YargsInstance_frozens, "f").push({
3846
+ options: __classPrivateFieldGet(this, _YargsInstance_options, "f"),
3847
+ configObjects: __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects.slice(0),
3848
+ exitProcess: __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"),
3849
+ groups: __classPrivateFieldGet(this, _YargsInstance_groups, "f"),
3850
+ strict: __classPrivateFieldGet(this, _YargsInstance_strict, "f"),
3851
+ strictCommands: __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"),
3852
+ strictOptions: __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"),
3853
+ completionCommand: __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"),
3854
+ output: __classPrivateFieldGet(this, _YargsInstance_output, "f"),
3855
+ exitError: __classPrivateFieldGet(this, _YargsInstance_exitError, "f"),
3856
+ hasOutput: __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"),
3857
+ parsed: this.parsed,
3858
+ parseFn: __classPrivateFieldGet(this, _YargsInstance_parseFn, "f"),
3859
+ parseContext: __classPrivateFieldGet(this, _YargsInstance_parseContext, "f")
3860
+ });
3861
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").freeze();
3862
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").freeze();
3863
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").freeze();
3864
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").freeze();
3865
+ }
3866
+ [kGetDollarZero]() {
3867
+ let $0 = "";
3868
+ let default$0;
3869
+ 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);
3870
+ else default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(0, 1);
3871
+ $0 = default$0.map((x) => {
3872
+ const b = this[kRebase](__classPrivateFieldGet(this, _YargsInstance_cwd, "f"), x);
3873
+ return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x;
3874
+ }).join(" ").trim();
3875
+ 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())}/`, "");
3876
+ return $0;
3877
+ }
3878
+ [kGetParserConfiguration]() {
3879
+ return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
3880
+ }
3881
+ [kGetUsageConfiguration]() {
3882
+ return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f");
3883
+ }
3884
+ [kGuessLocale]() {
3885
+ if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f")) return;
3886
+ 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";
3887
+ this.locale(locale.replace(/[.:].*/, ""));
3888
+ }
3889
+ [kGuessVersion]() {
3890
+ return this[kPkgUp]().version || "unknown";
3891
+ }
3892
+ [kParsePositionalNumbers](argv) {
3893
+ const args = argv["--"] ? argv["--"] : argv._;
3894
+ 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);
3895
+ return argv;
3896
+ }
3897
+ [kPkgUp](rootPath) {
3898
+ const npath = rootPath || "*";
3899
+ if (__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath]) return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
3900
+ let obj = {};
3901
+ try {
3902
+ let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename;
3903
+ if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir);
3904
+ const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names) => {
3905
+ if (names.includes("package.json")) return "package.json";
3906
+ else return;
3907
+ });
3908
+ assertNotStrictEqual(pkgJsonPath, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3909
+ obj = JSON.parse(__classPrivateFieldGet(this, _YargsInstance_shim, "f").readFileSync(pkgJsonPath, "utf8"));
3910
+ } catch (_noop) {}
3911
+ __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
3912
+ return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
3913
+ }
3914
+ [kPopulateParserHintArray](type, keys) {
3915
+ keys = [].concat(keys);
3916
+ keys.forEach((key) => {
3917
+ key = this[kSanitizeKey](key);
3918
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type].push(key);
3919
+ });
3920
+ }
3921
+ [kPopulateParserHintSingleValueDictionary](builder, type, key, value) {
3922
+ this[kPopulateParserHintDictionary](builder, type, key, value, (type$1, key$1, value$1) => {
3923
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type$1][key$1] = value$1;
3924
+ });
3925
+ }
3926
+ [kPopulateParserHintArrayDictionary](builder, type, key, value) {
3927
+ this[kPopulateParserHintDictionary](builder, type, key, value, (type$1, key$1, value$1) => {
3928
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type$1][key$1] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type$1][key$1] || []).concat(value$1);
3929
+ });
3930
+ }
3931
+ [kPopulateParserHintDictionary](builder, type, key, value, singleKeyHandler) {
3932
+ if (Array.isArray(key)) key.forEach((k) => {
3933
+ builder(k, value);
3934
+ });
3935
+ else if (((key$1) => typeof key$1 === "object")(key)) for (const k of objectKeys(key)) builder(k, key[k]);
3936
+ else singleKeyHandler(type, this[kSanitizeKey](key), value);
3937
+ }
3938
+ [kSanitizeKey](key) {
3939
+ if (key === "__proto__") return "___proto___";
3940
+ return key;
3941
+ }
3942
+ [kSetKey](key, set) {
3943
+ this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), "key", key, set);
3944
+ return this;
3945
+ }
3946
+ [kUnfreeze]() {
3947
+ var _a$1, _b$1, _c$1, _d, _e, _f, _g, _h, _j, _k, _l, _m;
3948
+ const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
3949
+ assertNotStrictEqual(frozen, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3950
+ let configObjects;
3951
+ _a$1 = this, _b$1 = this, _c$1 = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {options: { set value(_o) {
3952
+ __classPrivateFieldSet(_a$1, _YargsInstance_options, _o, "f");
3953
+ } }.value, configObjects, exitProcess: { set value(_o) {
3954
+ __classPrivateFieldSet(_b$1, _YargsInstance_exitProcess, _o, "f");
3955
+ } }.value, groups: { set value(_o) {
3956
+ __classPrivateFieldSet(_c$1, _YargsInstance_groups, _o, "f");
3957
+ } }.value, output: { set value(_o) {
3958
+ __classPrivateFieldSet(_d, _YargsInstance_output, _o, "f");
3959
+ } }.value, exitError: { set value(_o) {
3960
+ __classPrivateFieldSet(_e, _YargsInstance_exitError, _o, "f");
3961
+ } }.value, hasOutput: { set value(_o) {
3962
+ __classPrivateFieldSet(_f, _YargsInstance_hasOutput, _o, "f");
3963
+ } }.value, parsed: this.parsed, strict: { set value(_o) {
3964
+ __classPrivateFieldSet(_g, _YargsInstance_strict, _o, "f");
3965
+ } }.value, strictCommands: { set value(_o) {
3966
+ __classPrivateFieldSet(_h, _YargsInstance_strictCommands, _o, "f");
3967
+ } }.value, strictOptions: { set value(_o) {
3968
+ __classPrivateFieldSet(_j, _YargsInstance_strictOptions, _o, "f");
3969
+ } }.value, completionCommand: { set value(_o) {
3970
+ __classPrivateFieldSet(_k, _YargsInstance_completionCommand, _o, "f");
3971
+ } }.value, parseFn: { set value(_o) {
3972
+ __classPrivateFieldSet(_l, _YargsInstance_parseFn, _o, "f");
3973
+ } }.value, parseContext: { set value(_o) {
3974
+ __classPrivateFieldSet(_m, _YargsInstance_parseContext, _o, "f");
3975
+ } }.value} = frozen;
3976
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = configObjects;
3977
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").unfreeze();
3978
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").unfreeze();
3979
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").unfreeze();
3980
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").unfreeze();
3981
+ }
3982
+ [kValidateAsync](validation$1, argv) {
3983
+ return maybeAsyncResult(argv, (result) => {
3984
+ validation$1(result);
3985
+ return result;
3986
+ });
3987
+ }
3988
+ getInternalMethods() {
3989
+ return {
3990
+ getCommandInstance: this[kGetCommandInstance].bind(this),
3991
+ getContext: this[kGetContext].bind(this),
3992
+ getHasOutput: this[kGetHasOutput].bind(this),
3993
+ getLoggerInstance: this[kGetLoggerInstance].bind(this),
3994
+ getParseContext: this[kGetParseContext].bind(this),
3995
+ getParserConfiguration: this[kGetParserConfiguration].bind(this),
3996
+ getUsageConfiguration: this[kGetUsageConfiguration].bind(this),
3997
+ getUsageInstance: this[kGetUsageInstance].bind(this),
3998
+ getValidationInstance: this[kGetValidationInstance].bind(this),
3999
+ hasParseCallback: this[kHasParseCallback].bind(this),
4000
+ isGlobalContext: this[kIsGlobalContext].bind(this),
4001
+ postProcess: this[kPostProcess].bind(this),
4002
+ reset: this[kReset].bind(this),
4003
+ runValidation: this[kRunValidation].bind(this),
4004
+ runYargsParserAndExecuteCommands: this[kRunYargsParserAndExecuteCommands].bind(this),
4005
+ setHasOutput: this[kSetHasOutput].bind(this)
4006
+ };
4007
+ }
4008
+ [kGetCommandInstance]() {
4009
+ return __classPrivateFieldGet(this, _YargsInstance_command, "f");
4010
+ }
4011
+ [kGetContext]() {
4012
+ return __classPrivateFieldGet(this, _YargsInstance_context, "f");
4013
+ }
4014
+ [kGetHasOutput]() {
4015
+ return __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f");
4016
+ }
4017
+ [kGetLoggerInstance]() {
4018
+ return __classPrivateFieldGet(this, _YargsInstance_logger, "f");
4019
+ }
4020
+ [kGetParseContext]() {
4021
+ return __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") || {};
4022
+ }
4023
+ [kGetUsageInstance]() {
4024
+ return __classPrivateFieldGet(this, _YargsInstance_usage, "f");
4025
+ }
4026
+ [kGetValidationInstance]() {
4027
+ return __classPrivateFieldGet(this, _YargsInstance_validation, "f");
4028
+ }
4029
+ [kHasParseCallback]() {
4030
+ return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f");
4031
+ }
4032
+ [kIsGlobalContext]() {
4033
+ return __classPrivateFieldGet(this, _YargsInstance_isGlobalContext, "f");
4034
+ }
4035
+ [kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) {
4036
+ if (calledFromCommand) return argv;
4037
+ if (isPromise(argv)) return argv;
4038
+ if (!populateDoubleDash) argv = this[kCopyDoubleDash](argv);
4039
+ if (this[kGetParserConfiguration]()["parse-positional-numbers"] || this[kGetParserConfiguration]()["parse-positional-numbers"] === void 0) argv = this[kParsePositionalNumbers](argv);
4040
+ if (runGlobalMiddleware) argv = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
4041
+ return argv;
4042
+ }
4043
+ [kReset](aliases = {}) {
4044
+ __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f") || {}, "f");
4045
+ const tmpOptions = {};
4046
+ tmpOptions.local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local || [];
4047
+ tmpOptions.configObjects = __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || [];
4048
+ const localLookup = {};
4049
+ tmpOptions.local.forEach((l) => {
4050
+ localLookup[l] = true;
4051
+ (aliases[l] || []).forEach((a) => {
4052
+ localLookup[a] = true;
4053
+ });
4054
+ });
4055
+ Object.assign(__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"), Object.keys(__classPrivateFieldGet(this, _YargsInstance_groups, "f")).reduce((acc, groupName) => {
4056
+ const keys = __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName].filter((key) => !(key in localLookup));
4057
+ if (keys.length > 0) acc[groupName] = keys;
4058
+ return acc;
4059
+ }, {}));
4060
+ __classPrivateFieldSet(this, _YargsInstance_groups, {}, "f");
4061
+ const arrayOptions = [
4062
+ "array",
4063
+ "boolean",
4064
+ "string",
4065
+ "skipValidation",
4066
+ "count",
4067
+ "normalize",
4068
+ "number",
4069
+ "hiddenOptions"
4070
+ ];
4071
+ const objectOptions = [
4072
+ "narg",
4073
+ "key",
4074
+ "alias",
4075
+ "default",
4076
+ "defaultDescription",
4077
+ "config",
4078
+ "choices",
4079
+ "demandedOptions",
4080
+ "demandedCommands",
4081
+ "deprecatedOptions"
4082
+ ];
4083
+ arrayOptions.forEach((k) => {
4084
+ tmpOptions[k] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[k] || []).filter((k$1) => !localLookup[k$1]);
4085
+ });
4086
+ objectOptions.forEach((k) => {
4087
+ tmpOptions[k] = objFilter(__classPrivateFieldGet(this, _YargsInstance_options, "f")[k], (k$1) => !localLookup[k$1]);
4088
+ });
4089
+ tmpOptions.envPrefix = __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
4090
+ __classPrivateFieldSet(this, _YargsInstance_options, tmpOptions, "f");
4091
+ __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f") ? __classPrivateFieldGet(this, _YargsInstance_usage, "f").reset(localLookup) : usage(this, __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4092
+ __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");
4093
+ __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");
4094
+ 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");
4095
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").reset();
4096
+ __classPrivateFieldSet(this, _YargsInstance_completionCommand, null, "f");
4097
+ __classPrivateFieldSet(this, _YargsInstance_output, "", "f");
4098
+ __classPrivateFieldSet(this, _YargsInstance_exitError, null, "f");
4099
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, false, "f");
4100
+ this.parsed = false;
4101
+ return this;
4102
+ }
4103
+ [kRebase](base, dir) {
4104
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.relative(base, dir);
4105
+ }
4106
+ [kRunYargsParserAndExecuteCommands](args, shortCircuit, calledFromCommand, commandIndex = 0, helpOnly = false) {
4107
+ var _a$1, _b$1, _c$1, _d;
4108
+ let skipValidation = !!calledFromCommand || helpOnly;
4109
+ args = args || __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
4110
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__;
4111
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration]();
4112
+ const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration["populate--"];
4113
+ const config$1 = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, { "populate--": true });
4114
+ const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), { configuration: {
4115
+ "parse-positional-numbers": false,
4116
+ ...config$1
4117
+ } }));
4118
+ const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"));
4119
+ let argvPromise = void 0;
4120
+ const aliases = parsed.aliases;
4121
+ let helpOptSet = false;
4122
+ let versionOptSet = false;
4123
+ Object.keys(argv).forEach((key) => {
4124
+ if (key === __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f") && argv[key]) helpOptSet = true;
4125
+ else if (key === __classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && argv[key]) versionOptSet = true;
4126
+ });
4127
+ argv.$0 = this.$0;
4128
+ this.parsed = parsed;
4129
+ if (commandIndex === 0) __classPrivateFieldGet(this, _YargsInstance_usage, "f").clearCachedHelpMessage();
4130
+ try {
4131
+ this[kGuessLocale]();
4132
+ if (shortCircuit) return this[kPostProcess](argv, populateDoubleDash, !!calledFromCommand, false);
4133
+ if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
4134
+ if ([__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")].concat(aliases[__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")] || []).filter((k) => k.length > 1).includes("" + argv._[argv._.length - 1])) {
4135
+ argv._.pop();
4136
+ helpOptSet = true;
4137
+ }
4138
+ }
4139
+ __classPrivateFieldSet(this, _YargsInstance_isGlobalContext, false, "f");
4140
+ const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands();
4141
+ const requestCompletions = ((_a$1 = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _a$1 === void 0 ? void 0 : _a$1.completionKey) ? [(_b$1 = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _b$1 === void 0 ? void 0 : _b$1.completionKey, ...(_d = this.getAliases()[(_c$1 = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _c$1 === void 0 ? void 0 : _c$1.completionKey]) !== null && _d !== void 0 ? _d : []].some((key) => Object.prototype.hasOwnProperty.call(argv, key)) : false;
4142
+ const skipRecommendation = helpOptSet || requestCompletions || helpOnly;
4143
+ if (argv._.length) {
4144
+ if (handlerKeys.length) {
4145
+ let firstUnknownCommand;
4146
+ for (let i = commandIndex || 0, cmd; argv._[i] !== void 0; i++) {
4147
+ cmd = String(argv._[i]);
4148
+ if (handlerKeys.includes(cmd) && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
4149
+ const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(cmd, this, parsed, i + 1, helpOnly, helpOptSet || versionOptSet || helpOnly);
4150
+ return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
4151
+ } else if (!firstUnknownCommand && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
4152
+ firstUnknownCommand = cmd;
4153
+ break;
4154
+ }
4155
+ }
4156
+ if (!__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && __classPrivateFieldGet(this, _YargsInstance_recommendCommands, "f") && firstUnknownCommand && !skipRecommendation) __classPrivateFieldGet(this, _YargsInstance_validation, "f").recommendCommands(firstUnknownCommand, handlerKeys);
4157
+ }
4158
+ if (__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") && argv._.includes(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) && !requestCompletions) {
4159
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
4160
+ this.showCompletionScript();
4161
+ this.exit(0);
4162
+ }
4163
+ }
4164
+ if (__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && !skipRecommendation) {
4165
+ const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(null, this, parsed, 0, helpOnly, helpOptSet || versionOptSet || helpOnly);
4166
+ return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
4167
+ }
4168
+ if (requestCompletions) {
4169
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
4170
+ args = [].concat(args);
4171
+ const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey}`) + 1);
4172
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(completionArgs, (err, completions) => {
4173
+ if (err) throw new YError(err.message);
4174
+ (completions || []).forEach((completion$1) => {
4175
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(completion$1);
4176
+ });
4177
+ this.exit(0);
4178
+ });
4179
+ return this[kPostProcess](argv, !populateDoubleDash, !!calledFromCommand, false);
4180
+ }
4181
+ if (!__classPrivateFieldGet(this, _YargsInstance_hasOutput, "f")) {
4182
+ if (helpOptSet) {
4183
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
4184
+ skipValidation = true;
4185
+ this.showHelp((message) => {
4186
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(message);
4187
+ this.exit(0);
4188
+ });
4189
+ } else if (versionOptSet) {
4190
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
4191
+ skipValidation = true;
4192
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion("log");
4193
+ this.exit(0);
4194
+ }
4195
+ }
4196
+ 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);
4197
+ if (!skipValidation) {
4198
+ if (parsed.error) throw new YError(parsed.error.message);
4199
+ if (!requestCompletions) {
4200
+ const validation$1 = this[kRunValidation](aliases, {}, parsed.error);
4201
+ if (!calledFromCommand) argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), true);
4202
+ argvPromise = this[kValidateAsync](validation$1, argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv);
4203
+ if (isPromise(argvPromise) && !calledFromCommand) argvPromise = argvPromise.then(() => {
4204
+ return applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
4205
+ });
4206
+ }
4207
+ }
4208
+ } catch (err) {
4209
+ if (err instanceof YError) __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message, err);
4210
+ else throw err;
4211
+ }
4212
+ return this[kPostProcess](argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv, populateDoubleDash, !!calledFromCommand, true);
4213
+ }
4214
+ [kRunValidation](aliases, positionalMap, parseErrors, isDefaultCommand) {
4215
+ const demandedOptions = { ...this.getDemandedOptions() };
4216
+ return (argv) => {
4217
+ if (parseErrors) throw new YError(parseErrors.message);
4218
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").nonOptionCount(argv);
4219
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").requiredArguments(argv, demandedOptions);
4220
+ let failedStrictCommands = false;
4221
+ if (__classPrivateFieldGet(this, _YargsInstance_strictCommands, "f")) failedStrictCommands = __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownCommands(argv);
4222
+ if (__classPrivateFieldGet(this, _YargsInstance_strict, "f") && !failedStrictCommands) __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, positionalMap, !!isDefaultCommand);
4223
+ else if (__classPrivateFieldGet(this, _YargsInstance_strictOptions, "f")) __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, {}, false, false);
4224
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").limitedChoices(argv);
4225
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").implications(argv);
4226
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicting(argv);
4227
+ };
4228
+ }
4229
+ [kSetHasOutput]() {
4230
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4231
+ }
4232
+ [kTrackManuallySetKeys](keys) {
4233
+ if (typeof keys === "string") __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
4234
+ else for (const k of keys) __classPrivateFieldGet(this, _YargsInstance_options, "f").key[k] = true;
4235
+ }
4236
+ };
4237
+ function isYargsInstance(y) {
4238
+ return !!y && typeof y.getInternalMethods === "function";
4239
+ }
4240
+
4241
+ //#endregion
4242
+ //#region node_modules/yargs/index.mjs
4243
+ const Yargs = YargsFactory(esm_default);
4244
+ var yargs_default = Yargs;
4245
+
4246
+ //#endregion
7
4247
  //#region src/tasks/validateConfigs.ts
8
4248
  const validateConfigs = (configs) => {
9
4249
  const errors = [];
@@ -14,7 +4254,7 @@ const validateConfigs = (configs) => {
14
4254
  if ([config$1.endpoint, config$1.schema].filter((i$1) => i$1).length > 1) errors.push(`you provided two or more conflicting options in ${whichConfig}, only one of either \`endpoint\`, \`schema\` or \`fetcher\` is allowed`);
15
4255
  if (!config$1.output) errors.push(`you didn't provide an \`output\` option in ${whichConfig}`);
16
4256
  });
17
- errors.forEach((error) => console.log(kleur.red(`Error: ${error}`)));
4257
+ errors.forEach((error) => console.log(kleur_default.red(`Error: ${error}`)));
18
4258
  return errors.length === 0;
19
4259
  };
20
4260
 
@@ -36,7 +4276,7 @@ function parseColonSeparatedStrings(array = []) {
36
4276
 
37
4277
  //#endregion
38
4278
  //#region src/cli.ts
39
- const program = yargs(process.argv.slice(2)).option("output", {
4279
+ const program = yargs_default(process.argv.slice(2)).option("output", {
40
4280
  alias: "o",
41
4281
  description: "Output directory",
42
4282
  required: true,
@@ -97,7 +4337,7 @@ const config = {
97
4337
  };
98
4338
  if (!validateConfigs([config])) process.exit(1);
99
4339
  generate(config).catch((e) => {
100
- console.error(kleur.red("Cannot generate, got an error:"));
4340
+ console.error(kleur_default.red("Cannot generate, got an error:"));
101
4341
  console.error(e);
102
4342
  process.exit(1);
103
4343
  }).then(() => {
@@ -105,7 +4345,7 @@ generate(config).catch((e) => {
105
4345
  });
106
4346
  function printHelp({ dirPath }) {
107
4347
  console.log();
108
- console.log(`${kleur.green("Success!")} Generated client code inside '${dirPath}'`);
4348
+ console.log(`${kleur_default.green("Success!")} Generated client code inside '${dirPath}'`);
109
4349
  console.log();
110
4350
  console.log();
111
4351
  }