@ui-tars-test/cli 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +231 -0
  2. package/bin/index.js +13 -0
  3. package/dist/337.js +1396 -0
  4. package/dist/337.js.LICENSE.txt +14 -0
  5. package/dist/337.js.map +1 -0
  6. package/dist/337.mjs +1395 -0
  7. package/dist/337.mjs.LICENSE.txt +14 -0
  8. package/dist/337.mjs.map +1 -0
  9. package/dist/597.js +19 -0
  10. package/dist/597.mjs +18 -0
  11. package/dist/663.js +98 -0
  12. package/dist/663.js.map +1 -0
  13. package/dist/663.mjs +97 -0
  14. package/dist/663.mjs.map +1 -0
  15. package/dist/760.js +2957 -0
  16. package/dist/760.js.map +1 -0
  17. package/dist/760.mjs +2956 -0
  18. package/dist/760.mjs.map +1 -0
  19. package/dist/940.js +1013 -0
  20. package/dist/940.js.map +1 -0
  21. package/dist/940.mjs +1011 -0
  22. package/dist/940.mjs.map +1 -0
  23. package/dist/955.js +317 -0
  24. package/dist/955.js.map +1 -0
  25. package/dist/955.mjs +317 -0
  26. package/dist/955.mjs.map +1 -0
  27. package/dist/bundle/index.js +299060 -0
  28. package/dist/cli/commands.js +75 -0
  29. package/dist/cli/commands.js.map +1 -0
  30. package/dist/cli/commands.mjs +41 -0
  31. package/dist/cli/commands.mjs.map +1 -0
  32. package/dist/cli/start.js +447 -0
  33. package/dist/cli/start.js.map +1 -0
  34. package/dist/cli/start.mjs +396 -0
  35. package/dist/cli/start.mjs.map +1 -0
  36. package/dist/gui-agent-macos +0 -0
  37. package/dist/index.js +14 -0
  38. package/dist/index.js.LICENSE.txt +471 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/index.mjs +8 -0
  41. package/dist/index.mjs.LICENSE.txt +471 -0
  42. package/dist/index.mjs.map +1 -0
  43. package/dist/src/cli/commands.d.ts +2 -0
  44. package/dist/src/cli/commands.d.ts.map +1 -0
  45. package/dist/src/cli/start.d.ts +11 -0
  46. package/dist/src/cli/start.d.ts.map +1 -0
  47. package/dist/src/index.d.ts +2 -0
  48. package/dist/src/index.d.ts.map +1 -0
  49. package/package.json +59 -0
package/dist/760.mjs ADDED
@@ -0,0 +1,2956 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ export const __webpack_ids__ = [
6
+ "760"
7
+ ];
8
+ export const __webpack_modules__ = {
9
+ "../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/index.mjs": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10
+ __webpack_require__.d(__webpack_exports__, {
11
+ default: ()=>node_modules_yargs
12
+ });
13
+ var esm = __webpack_require__("../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/lib/platform-shims/esm.mjs");
14
+ function assertNotStrictEqual(actual, expected, shim, message) {
15
+ shim.assert.notStrictEqual(actual, expected, message);
16
+ }
17
+ function assertSingleKey(actual, shim) {
18
+ shim.assert.strictEqual(typeof actual, 'string');
19
+ }
20
+ function objectKeys(object) {
21
+ return Object.keys(object);
22
+ }
23
+ function isPromise(maybePromise) {
24
+ return !!maybePromise && !!maybePromise.then && 'function' == typeof maybePromise.then;
25
+ }
26
+ var yerror = __webpack_require__("../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/build/lib/yerror.js");
27
+ function parseCommand(cmd) {
28
+ const extraSpacesStrippedCommand = cmd.replace(/\s{2,}/g, ' ');
29
+ const splitCommand = extraSpacesStrippedCommand.split(/\s+(?![^[]*]|[^<]*>)/);
30
+ const bregex = /\.*[\][<>]/g;
31
+ const firstCommand = splitCommand.shift();
32
+ if (!firstCommand) throw new Error(`No command found in: ${cmd}`);
33
+ const parsedCommand = {
34
+ cmd: firstCommand.replace(bregex, ''),
35
+ demanded: [],
36
+ optional: []
37
+ };
38
+ splitCommand.forEach((cmd, i)=>{
39
+ let variadic = false;
40
+ cmd = cmd.replace(/\s/g, '');
41
+ if (/\.+[\]>]/.test(cmd) && i === splitCommand.length - 1) variadic = true;
42
+ if (/^\[/.test(cmd)) parsedCommand.optional.push({
43
+ cmd: cmd.replace(bregex, '').split('|'),
44
+ variadic
45
+ });
46
+ else parsedCommand.demanded.push({
47
+ cmd: cmd.replace(bregex, '').split('|'),
48
+ variadic
49
+ });
50
+ });
51
+ return parsedCommand;
52
+ }
53
+ const positionName = [
54
+ 'first',
55
+ 'second',
56
+ 'third',
57
+ 'fourth',
58
+ 'fifth',
59
+ 'sixth'
60
+ ];
61
+ function argsert(arg1, arg2, arg3) {
62
+ function parseArgs() {
63
+ return 'object' == typeof arg1 ? [
64
+ {
65
+ demanded: [],
66
+ optional: []
67
+ },
68
+ arg1,
69
+ arg2
70
+ ] : [
71
+ parseCommand(`cmd ${arg1}`),
72
+ arg2,
73
+ arg3
74
+ ];
75
+ }
76
+ try {
77
+ let position = 0;
78
+ const [parsed, callerArguments, _length] = parseArgs();
79
+ const args = [].slice.call(callerArguments);
80
+ while(args.length && void 0 === args[args.length - 1])args.pop();
81
+ const length = _length || args.length;
82
+ if (length < parsed.demanded.length) throw new yerror.s(`Not enough arguments provided. Expected ${parsed.demanded.length} but received ${args.length}.`);
83
+ const totalCommands = parsed.demanded.length + parsed.optional.length;
84
+ if (length > totalCommands) throw new yerror.s(`Too many arguments provided. Expected max ${totalCommands} but received ${length}.`);
85
+ parsed.demanded.forEach((demanded)=>{
86
+ const arg = args.shift();
87
+ const observedType = guessType(arg);
88
+ const matchingTypes = demanded.cmd.filter((type)=>type === observedType || '*' === type);
89
+ if (0 === matchingTypes.length) argumentTypeError(observedType, demanded.cmd, position);
90
+ position += 1;
91
+ });
92
+ parsed.optional.forEach((optional)=>{
93
+ if (0 === args.length) return;
94
+ const arg = args.shift();
95
+ const observedType = guessType(arg);
96
+ const matchingTypes = optional.cmd.filter((type)=>type === observedType || '*' === type);
97
+ if (0 === matchingTypes.length) argumentTypeError(observedType, optional.cmd, position);
98
+ position += 1;
99
+ });
100
+ } catch (err) {
101
+ console.warn(err.stack);
102
+ }
103
+ }
104
+ function guessType(arg) {
105
+ if (Array.isArray(arg)) return 'array';
106
+ if (null === arg) return 'null';
107
+ return typeof arg;
108
+ }
109
+ function argumentTypeError(observedType, allowedTypes, position) {
110
+ throw new yerror.s(`Invalid ${positionName[position] || 'manyith'} argument. Expected ${allowedTypes.join(' or ')} but received ${observedType}.`);
111
+ }
112
+ class GlobalMiddleware {
113
+ constructor(yargs){
114
+ this.globalMiddleware = [];
115
+ this.frozens = [];
116
+ this.yargs = yargs;
117
+ }
118
+ addMiddleware(callback, applyBeforeValidation, global = true, mutates = false) {
119
+ argsert('<array|function> [boolean] [boolean] [boolean]', [
120
+ callback,
121
+ applyBeforeValidation,
122
+ global
123
+ ], arguments.length);
124
+ if (Array.isArray(callback)) {
125
+ for(let i = 0; i < callback.length; i++){
126
+ if ('function' != typeof callback[i]) throw Error('middleware must be a function');
127
+ const m = callback[i];
128
+ m.applyBeforeValidation = applyBeforeValidation;
129
+ m.global = global;
130
+ }
131
+ Array.prototype.push.apply(this.globalMiddleware, callback);
132
+ } else if ('function' == typeof callback) {
133
+ const m = callback;
134
+ m.applyBeforeValidation = applyBeforeValidation;
135
+ m.global = global;
136
+ m.mutates = mutates;
137
+ this.globalMiddleware.push(callback);
138
+ }
139
+ return this.yargs;
140
+ }
141
+ addCoerceMiddleware(callback, option) {
142
+ const aliases = this.yargs.getAliases();
143
+ this.globalMiddleware = this.globalMiddleware.filter((m)=>{
144
+ const toCheck = [
145
+ ...aliases[option] || [],
146
+ option
147
+ ];
148
+ if (!m.option) return true;
149
+ return !toCheck.includes(m.option);
150
+ });
151
+ callback.option = option;
152
+ return this.addMiddleware(callback, true, true, true);
153
+ }
154
+ getMiddleware() {
155
+ return this.globalMiddleware;
156
+ }
157
+ freeze() {
158
+ this.frozens.push([
159
+ ...this.globalMiddleware
160
+ ]);
161
+ }
162
+ unfreeze() {
163
+ const frozen = this.frozens.pop();
164
+ if (void 0 !== frozen) this.globalMiddleware = frozen;
165
+ }
166
+ reset() {
167
+ this.globalMiddleware = this.globalMiddleware.filter((m)=>m.global);
168
+ }
169
+ }
170
+ function commandMiddlewareFactory(commandMiddleware) {
171
+ if (!commandMiddleware) return [];
172
+ return commandMiddleware.map((middleware)=>{
173
+ middleware.applyBeforeValidation = false;
174
+ return middleware;
175
+ });
176
+ }
177
+ function applyMiddleware(argv, yargs, middlewares, beforeValidation) {
178
+ return middlewares.reduce((acc, middleware)=>{
179
+ if (middleware.applyBeforeValidation !== beforeValidation) return acc;
180
+ if (middleware.mutates) {
181
+ if (middleware.applied) return acc;
182
+ middleware.applied = true;
183
+ }
184
+ if (isPromise(acc)) return acc.then((initialObj)=>Promise.all([
185
+ initialObj,
186
+ middleware(initialObj, yargs)
187
+ ])).then(([initialObj, middlewareObj])=>Object.assign(initialObj, middlewareObj));
188
+ {
189
+ const result = middleware(acc, yargs);
190
+ return isPromise(result) ? result.then((middlewareObj)=>Object.assign(acc, middlewareObj)) : Object.assign(acc, result);
191
+ }
192
+ }, argv);
193
+ }
194
+ function maybeAsyncResult(getResult, resultHandler, errorHandler = (err)=>{
195
+ throw err;
196
+ }) {
197
+ try {
198
+ const result = isFunction(getResult) ? getResult() : getResult;
199
+ return isPromise(result) ? result.then((result)=>resultHandler(result)) : resultHandler(result);
200
+ } catch (err) {
201
+ return errorHandler(err);
202
+ }
203
+ }
204
+ function isFunction(arg) {
205
+ return 'function' == typeof arg;
206
+ }
207
+ function whichModule(exported) {
208
+ if ('undefined' == typeof require) return null;
209
+ for(let i = 0, files = Object.keys(__webpack_require__.c), mod; i < files.length; i++){
210
+ mod = __webpack_require__.c[files[i]];
211
+ if (mod.exports === exported) return mod;
212
+ }
213
+ return null;
214
+ }
215
+ const DEFAULT_MARKER = /(^\*)|(^\$0)/;
216
+ class CommandInstance {
217
+ constructor(usage, validation, globalMiddleware, shim){
218
+ this.requireCache = new Set();
219
+ this.handlers = {};
220
+ this.aliasMap = {};
221
+ this.frozens = [];
222
+ this.shim = shim;
223
+ this.usage = usage;
224
+ this.globalMiddleware = globalMiddleware;
225
+ this.validation = validation;
226
+ }
227
+ addDirectory(dir, req, callerFile, opts) {
228
+ opts = opts || {};
229
+ if ('boolean' != typeof opts.recurse) opts.recurse = false;
230
+ if (!Array.isArray(opts.extensions)) opts.extensions = [
231
+ 'js'
232
+ ];
233
+ const parentVisit = 'function' == typeof opts.visit ? opts.visit : (o)=>o;
234
+ opts.visit = (obj, joined, filename)=>{
235
+ const visited = parentVisit(obj, joined, filename);
236
+ if (visited) {
237
+ if (this.requireCache.has(joined)) return visited;
238
+ this.requireCache.add(joined);
239
+ this.addHandler(visited);
240
+ }
241
+ return visited;
242
+ };
243
+ this.shim.requireDirectory({
244
+ require: req,
245
+ filename: callerFile
246
+ }, dir, opts);
247
+ }
248
+ addHandler(cmd, description, builder, handler, commandMiddleware, deprecated) {
249
+ let aliases = [];
250
+ const middlewares = commandMiddlewareFactory(commandMiddleware);
251
+ handler = handler || (()=>{});
252
+ if (Array.isArray(cmd)) if (isCommandAndAliases(cmd)) [cmd, ...aliases] = cmd;
253
+ else for (const command of cmd)this.addHandler(command);
254
+ else if (isCommandHandlerDefinition(cmd)) {
255
+ let command = Array.isArray(cmd.command) || 'string' == typeof cmd.command ? cmd.command : this.moduleName(cmd);
256
+ if (cmd.aliases) command = [].concat(command).concat(cmd.aliases);
257
+ this.addHandler(command, this.extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
258
+ return;
259
+ } else if (isCommandBuilderDefinition(builder)) return void this.addHandler([
260
+ cmd
261
+ ].concat(aliases), description, builder.builder, builder.handler, builder.middlewares, builder.deprecated);
262
+ if ('string' == typeof cmd) {
263
+ const parsedCommand = parseCommand(cmd);
264
+ aliases = aliases.map((alias)=>parseCommand(alias).cmd);
265
+ let isDefault = false;
266
+ const parsedAliases = [
267
+ parsedCommand.cmd
268
+ ].concat(aliases).filter((c)=>{
269
+ if (DEFAULT_MARKER.test(c)) {
270
+ isDefault = true;
271
+ return false;
272
+ }
273
+ return true;
274
+ });
275
+ if (0 === parsedAliases.length && isDefault) parsedAliases.push('$0');
276
+ if (isDefault) {
277
+ parsedCommand.cmd = parsedAliases[0];
278
+ aliases = parsedAliases.slice(1);
279
+ cmd = cmd.replace(DEFAULT_MARKER, parsedCommand.cmd);
280
+ }
281
+ aliases.forEach((alias)=>{
282
+ this.aliasMap[alias] = parsedCommand.cmd;
283
+ });
284
+ if (false !== description) this.usage.command(cmd, description, isDefault, aliases, deprecated);
285
+ this.handlers[parsedCommand.cmd] = {
286
+ original: cmd,
287
+ description,
288
+ handler,
289
+ builder: builder || {},
290
+ middlewares,
291
+ deprecated,
292
+ demanded: parsedCommand.demanded,
293
+ optional: parsedCommand.optional
294
+ };
295
+ if (isDefault) this.defaultCommand = this.handlers[parsedCommand.cmd];
296
+ }
297
+ }
298
+ getCommandHandlers() {
299
+ return this.handlers;
300
+ }
301
+ getCommands() {
302
+ return Object.keys(this.handlers).concat(Object.keys(this.aliasMap));
303
+ }
304
+ hasDefaultCommand() {
305
+ return !!this.defaultCommand;
306
+ }
307
+ runCommand(command, yargs, parsed, commandIndex, helpOnly, helpOrVersionSet) {
308
+ const commandHandler = this.handlers[command] || this.handlers[this.aliasMap[command]] || this.defaultCommand;
309
+ const currentContext = yargs.getInternalMethods().getContext();
310
+ const parentCommands = currentContext.commands.slice();
311
+ const isDefaultCommand = !command;
312
+ if (command) {
313
+ currentContext.commands.push(command);
314
+ currentContext.fullCommands.push(commandHandler.original);
315
+ }
316
+ const builderResult = this.applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, parsed.aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet);
317
+ 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);
318
+ }
319
+ applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet) {
320
+ const builder = commandHandler.builder;
321
+ let innerYargs = yargs;
322
+ if (isCommandBuilderCallback(builder)) {
323
+ yargs.getInternalMethods().getUsageInstance().freeze();
324
+ const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet);
325
+ if (isPromise(builderOutput)) return builderOutput.then((output)=>{
326
+ innerYargs = isYargsInstance(output) ? output : yargs;
327
+ return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
328
+ });
329
+ } else if (isCommandBuilderOptionDefinitions(builder)) {
330
+ yargs.getInternalMethods().getUsageInstance().freeze();
331
+ innerYargs = yargs.getInternalMethods().reset(aliases);
332
+ Object.keys(commandHandler.builder).forEach((key)=>{
333
+ innerYargs.option(key, builder[key]);
334
+ });
335
+ }
336
+ return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
337
+ }
338
+ parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly) {
339
+ if (isDefaultCommand) innerYargs.getInternalMethods().getUsageInstance().unfreeze(true);
340
+ if (this.shouldUpdateUsage(innerYargs)) innerYargs.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
341
+ const innerArgv = innerYargs.getInternalMethods().runYargsParserAndExecuteCommands(null, void 0, true, commandIndex, helpOnly);
342
+ return isPromise(innerArgv) ? innerArgv.then((argv)=>({
343
+ aliases: innerYargs.parsed.aliases,
344
+ innerArgv: argv
345
+ })) : {
346
+ aliases: innerYargs.parsed.aliases,
347
+ innerArgv: innerArgv
348
+ };
349
+ }
350
+ shouldUpdateUsage(yargs) {
351
+ return !yargs.getInternalMethods().getUsageInstance().getUsageDisabled() && 0 === yargs.getInternalMethods().getUsageInstance().getUsage().length;
352
+ }
353
+ usageFromParentCommandsCommandHandler(parentCommands, commandHandler) {
354
+ const c = DEFAULT_MARKER.test(commandHandler.original) ? commandHandler.original.replace(DEFAULT_MARKER, '').trim() : commandHandler.original;
355
+ const pc = parentCommands.filter((c)=>!DEFAULT_MARKER.test(c));
356
+ pc.push(c);
357
+ return `$0 ${pc.join(' ')}`;
358
+ }
359
+ handleValidationAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, aliases, yargs, middlewares, positionalMap) {
360
+ if (!yargs.getInternalMethods().getHasOutput()) {
361
+ const validation = yargs.getInternalMethods().runValidation(aliases, positionalMap, yargs.parsed.error, isDefaultCommand);
362
+ innerArgv = maybeAsyncResult(innerArgv, (result)=>{
363
+ validation(result);
364
+ return result;
365
+ });
366
+ }
367
+ if (commandHandler.handler && !yargs.getInternalMethods().getHasOutput()) {
368
+ yargs.getInternalMethods().setHasOutput();
369
+ const populateDoubleDash = !!yargs.getOptions().configuration['populate--'];
370
+ yargs.getInternalMethods().postProcess(innerArgv, populateDoubleDash, false, false);
371
+ innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false);
372
+ innerArgv = maybeAsyncResult(innerArgv, (result)=>{
373
+ const handlerResult = commandHandler.handler(result);
374
+ return isPromise(handlerResult) ? handlerResult.then(()=>result) : result;
375
+ });
376
+ if (!isDefaultCommand) yargs.getInternalMethods().getUsageInstance().cacheHelpMessage();
377
+ if (isPromise(innerArgv) && !yargs.getInternalMethods().hasParseCallback()) innerArgv.catch((error)=>{
378
+ try {
379
+ yargs.getInternalMethods().getUsageInstance().fail(null, error);
380
+ } catch (_err) {}
381
+ });
382
+ }
383
+ if (!isDefaultCommand) {
384
+ currentContext.commands.pop();
385
+ currentContext.fullCommands.pop();
386
+ }
387
+ return innerArgv;
388
+ }
389
+ applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
390
+ let positionalMap = {};
391
+ if (helpOnly) return innerArgv;
392
+ if (!yargs.getInternalMethods().getHasOutput()) positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
393
+ const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
394
+ const maybePromiseArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
395
+ 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);
396
+ }
397
+ populatePositionals(commandHandler, argv, context, yargs) {
398
+ argv._ = argv._.slice(context.commands.length);
399
+ const demanded = commandHandler.demanded.slice(0);
400
+ const optional = commandHandler.optional.slice(0);
401
+ const positionalMap = {};
402
+ this.validation.positionalCount(demanded.length, argv._.length);
403
+ while(demanded.length){
404
+ const demand = demanded.shift();
405
+ this.populatePositional(demand, argv, positionalMap);
406
+ }
407
+ while(optional.length){
408
+ const maybe = optional.shift();
409
+ this.populatePositional(maybe, argv, positionalMap);
410
+ }
411
+ argv._ = context.commands.concat(argv._.map((a)=>'' + a));
412
+ this.postProcessPositionals(argv, positionalMap, this.cmdToParseOptions(commandHandler.original), yargs);
413
+ return positionalMap;
414
+ }
415
+ populatePositional(positional, argv, positionalMap) {
416
+ const cmd = positional.cmd[0];
417
+ if (positional.variadic) positionalMap[cmd] = argv._.splice(0).map(String);
418
+ else if (argv._.length) positionalMap[cmd] = [
419
+ String(argv._.shift())
420
+ ];
421
+ }
422
+ cmdToParseOptions(cmdString) {
423
+ const parseOptions = {
424
+ array: [],
425
+ default: {},
426
+ alias: {},
427
+ demand: {}
428
+ };
429
+ const parsed = parseCommand(cmdString);
430
+ parsed.demanded.forEach((d)=>{
431
+ const [cmd, ...aliases] = d.cmd;
432
+ if (d.variadic) {
433
+ parseOptions.array.push(cmd);
434
+ parseOptions.default[cmd] = [];
435
+ }
436
+ parseOptions.alias[cmd] = aliases;
437
+ parseOptions.demand[cmd] = true;
438
+ });
439
+ parsed.optional.forEach((o)=>{
440
+ const [cmd, ...aliases] = o.cmd;
441
+ if (o.variadic) {
442
+ parseOptions.array.push(cmd);
443
+ parseOptions.default[cmd] = [];
444
+ }
445
+ parseOptions.alias[cmd] = aliases;
446
+ });
447
+ return parseOptions;
448
+ }
449
+ postProcessPositionals(argv, positionalMap, parseOptions, yargs) {
450
+ const options = Object.assign({}, yargs.getOptions());
451
+ options.default = Object.assign(parseOptions.default, options.default);
452
+ for (const key of Object.keys(parseOptions.alias))options.alias[key] = (options.alias[key] || []).concat(parseOptions.alias[key]);
453
+ options.array = options.array.concat(parseOptions.array);
454
+ options.config = {};
455
+ const unparsed = [];
456
+ Object.keys(positionalMap).forEach((key)=>{
457
+ positionalMap[key].map((value)=>{
458
+ if (options.configuration['unknown-options-as-args']) options.key[key] = true;
459
+ unparsed.push(`--${key}`);
460
+ unparsed.push(value);
461
+ });
462
+ });
463
+ if (!unparsed.length) return;
464
+ const config = Object.assign({}, options.configuration, {
465
+ 'populate--': false
466
+ });
467
+ const parsed = this.shim.Parser.detailed(unparsed, Object.assign({}, options, {
468
+ configuration: config
469
+ }));
470
+ if (parsed.error) yargs.getInternalMethods().getUsageInstance().fail(parsed.error.message, parsed.error);
471
+ else {
472
+ const positionalKeys = Object.keys(positionalMap);
473
+ Object.keys(positionalMap).forEach((key)=>{
474
+ positionalKeys.push(...parsed.aliases[key]);
475
+ });
476
+ Object.keys(parsed.argv).forEach((key)=>{
477
+ if (positionalKeys.includes(key)) {
478
+ if (!positionalMap[key]) positionalMap[key] = parsed.argv[key];
479
+ 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]);
480
+ else argv[key] = parsed.argv[key];
481
+ }
482
+ });
483
+ }
484
+ }
485
+ isDefaulted(yargs, key) {
486
+ const { default: defaults } = yargs.getOptions();
487
+ return Object.prototype.hasOwnProperty.call(defaults, key) || Object.prototype.hasOwnProperty.call(defaults, this.shim.Parser.camelCase(key));
488
+ }
489
+ isInConfigs(yargs, key) {
490
+ const { configObjects } = yargs.getOptions();
491
+ return configObjects.some((c)=>Object.prototype.hasOwnProperty.call(c, key)) || configObjects.some((c)=>Object.prototype.hasOwnProperty.call(c, this.shim.Parser.camelCase(key)));
492
+ }
493
+ runDefaultBuilderOn(yargs) {
494
+ if (!this.defaultCommand) return;
495
+ if (this.shouldUpdateUsage(yargs)) {
496
+ const commandString = DEFAULT_MARKER.test(this.defaultCommand.original) ? this.defaultCommand.original : this.defaultCommand.original.replace(/^[^[\]<>]*/, '$0 ');
497
+ yargs.getInternalMethods().getUsageInstance().usage(commandString, this.defaultCommand.description);
498
+ }
499
+ const builder = this.defaultCommand.builder;
500
+ if (isCommandBuilderCallback(builder)) return builder(yargs, true);
501
+ if (!isCommandBuilderDefinition(builder)) Object.keys(builder).forEach((key)=>{
502
+ yargs.option(key, builder[key]);
503
+ });
504
+ }
505
+ moduleName(obj) {
506
+ const mod = whichModule(obj);
507
+ if (!mod) throw new Error(`No command name given for module: ${this.shim.inspect(obj)}`);
508
+ return this.commandFromFilename(mod.filename);
509
+ }
510
+ commandFromFilename(filename) {
511
+ return this.shim.path.basename(filename, this.shim.path.extname(filename));
512
+ }
513
+ extractDesc({ describe, description, desc }) {
514
+ for (const test of [
515
+ describe,
516
+ description,
517
+ desc
518
+ ]){
519
+ if ('string' == typeof test || false === test) return test;
520
+ assertNotStrictEqual(test, true, this.shim);
521
+ }
522
+ return false;
523
+ }
524
+ freeze() {
525
+ this.frozens.push({
526
+ handlers: this.handlers,
527
+ aliasMap: this.aliasMap,
528
+ defaultCommand: this.defaultCommand
529
+ });
530
+ }
531
+ unfreeze() {
532
+ const frozen = this.frozens.pop();
533
+ assertNotStrictEqual(frozen, void 0, this.shim);
534
+ ({ handlers: this.handlers, aliasMap: this.aliasMap, defaultCommand: this.defaultCommand } = frozen);
535
+ }
536
+ reset() {
537
+ this.handlers = {};
538
+ this.aliasMap = {};
539
+ this.defaultCommand = void 0;
540
+ this.requireCache = new Set();
541
+ return this;
542
+ }
543
+ }
544
+ function command_command(usage, validation, globalMiddleware, shim) {
545
+ return new CommandInstance(usage, validation, globalMiddleware, shim);
546
+ }
547
+ function isCommandBuilderDefinition(builder) {
548
+ return 'object' == typeof builder && !!builder.builder && 'function' == typeof builder.handler;
549
+ }
550
+ function isCommandAndAliases(cmd) {
551
+ return cmd.every((c)=>'string' == typeof c);
552
+ }
553
+ function isCommandBuilderCallback(builder) {
554
+ return 'function' == typeof builder;
555
+ }
556
+ function isCommandBuilderOptionDefinitions(builder) {
557
+ return 'object' == typeof builder;
558
+ }
559
+ function isCommandHandlerDefinition(cmd) {
560
+ return 'object' == typeof cmd && !Array.isArray(cmd);
561
+ }
562
+ function objFilter(original = {}, filter = ()=>true) {
563
+ const obj = {};
564
+ objectKeys(original).forEach((key)=>{
565
+ if (filter(key, original[key])) obj[key] = original[key];
566
+ });
567
+ return obj;
568
+ }
569
+ function setBlocking(blocking) {
570
+ if ('undefined' == typeof process) return;
571
+ [
572
+ process.stdout,
573
+ process.stderr
574
+ ].forEach((_stream)=>{
575
+ const stream = _stream;
576
+ if (stream._handle && stream.isTTY && 'function' == typeof stream._handle.setBlocking) stream._handle.setBlocking(blocking);
577
+ });
578
+ }
579
+ function isBoolean(fail) {
580
+ return 'boolean' == typeof fail;
581
+ }
582
+ function usage_usage(yargs, shim) {
583
+ const __ = shim.y18n.__;
584
+ const self = {};
585
+ const fails = [];
586
+ self.failFn = function(f) {
587
+ fails.push(f);
588
+ };
589
+ let failMessage = null;
590
+ let globalFailMessage = null;
591
+ let showHelpOnFail = true;
592
+ self.showHelpOnFail = function(arg1 = true, arg2) {
593
+ const [enabled, message] = 'string' == typeof arg1 ? [
594
+ true,
595
+ arg1
596
+ ] : [
597
+ arg1,
598
+ arg2
599
+ ];
600
+ if (yargs.getInternalMethods().isGlobalContext()) globalFailMessage = message;
601
+ failMessage = message;
602
+ showHelpOnFail = enabled;
603
+ return self;
604
+ };
605
+ let failureOutput = false;
606
+ self.fail = function(msg, err) {
607
+ const logger = yargs.getInternalMethods().getLoggerInstance();
608
+ if (fails.length) for(let i = fails.length - 1; i >= 0; --i){
609
+ const fail = fails[i];
610
+ if (isBoolean(fail)) {
611
+ if (err) throw err;
612
+ else if (msg) throw Error(msg);
613
+ } else fail(msg, err, self);
614
+ }
615
+ else {
616
+ if (yargs.getExitProcess()) setBlocking(true);
617
+ if (!failureOutput) {
618
+ failureOutput = true;
619
+ if (showHelpOnFail) {
620
+ yargs.showHelp('error');
621
+ logger.error();
622
+ }
623
+ if (msg || err) logger.error(msg || err);
624
+ const globalOrCommandFailMessage = failMessage || globalFailMessage;
625
+ if (globalOrCommandFailMessage) {
626
+ if (msg || err) logger.error('');
627
+ logger.error(globalOrCommandFailMessage);
628
+ }
629
+ }
630
+ err = err || new yerror.s(msg);
631
+ if (yargs.getExitProcess()) return yargs.exit(1);
632
+ if (yargs.getInternalMethods().hasParseCallback()) return yargs.exit(1, err);
633
+ throw err;
634
+ }
635
+ };
636
+ let usages = [];
637
+ let usageDisabled = false;
638
+ self.usage = (msg, description)=>{
639
+ if (null === msg) {
640
+ usageDisabled = true;
641
+ usages = [];
642
+ return self;
643
+ }
644
+ usageDisabled = false;
645
+ usages.push([
646
+ msg,
647
+ description || ''
648
+ ]);
649
+ return self;
650
+ };
651
+ self.getUsage = ()=>usages;
652
+ self.getUsageDisabled = ()=>usageDisabled;
653
+ self.getPositionalGroupName = ()=>__('Positionals:');
654
+ let examples = [];
655
+ self.example = (cmd, description)=>{
656
+ examples.push([
657
+ cmd,
658
+ description || ''
659
+ ]);
660
+ };
661
+ let commands = [];
662
+ self.command = function(cmd, description, isDefault, aliases, deprecated = false) {
663
+ if (isDefault) commands = commands.map((cmdArray)=>{
664
+ cmdArray[2] = false;
665
+ return cmdArray;
666
+ });
667
+ commands.push([
668
+ cmd,
669
+ description || '',
670
+ isDefault,
671
+ aliases,
672
+ deprecated
673
+ ]);
674
+ };
675
+ self.getCommands = ()=>commands;
676
+ let descriptions = {};
677
+ self.describe = function(keyOrKeys, desc) {
678
+ if (Array.isArray(keyOrKeys)) keyOrKeys.forEach((k)=>{
679
+ self.describe(k, desc);
680
+ });
681
+ else if ('object' == typeof keyOrKeys) Object.keys(keyOrKeys).forEach((k)=>{
682
+ self.describe(k, keyOrKeys[k]);
683
+ });
684
+ else descriptions[keyOrKeys] = desc;
685
+ };
686
+ self.getDescriptions = ()=>descriptions;
687
+ let epilogs = [];
688
+ self.epilog = (msg)=>{
689
+ epilogs.push(msg);
690
+ };
691
+ let wrapSet = false;
692
+ let wrap;
693
+ self.wrap = (cols)=>{
694
+ wrapSet = true;
695
+ wrap = cols;
696
+ };
697
+ self.getWrap = ()=>{
698
+ if (shim.getEnv('YARGS_DISABLE_WRAP')) return null;
699
+ if (!wrapSet) {
700
+ wrap = windowWidth();
701
+ wrapSet = true;
702
+ }
703
+ return wrap;
704
+ };
705
+ const deferY18nLookupPrefix = '__yargsString__:';
706
+ self.deferY18nLookup = (str)=>deferY18nLookupPrefix + str;
707
+ self.help = function() {
708
+ if (cachedHelpMessage) return cachedHelpMessage;
709
+ normalizeAliases();
710
+ const base$0 = yargs.customScriptName ? yargs.$0 : shim.path.basename(yargs.$0);
711
+ const demandedOptions = yargs.getDemandedOptions();
712
+ const demandedCommands = yargs.getDemandedCommands();
713
+ const deprecatedOptions = yargs.getDeprecatedOptions();
714
+ const groups = yargs.getGroups();
715
+ const options = yargs.getOptions();
716
+ let keys = [];
717
+ keys = keys.concat(Object.keys(descriptions));
718
+ keys = keys.concat(Object.keys(demandedOptions));
719
+ keys = keys.concat(Object.keys(demandedCommands));
720
+ keys = keys.concat(Object.keys(options.default));
721
+ keys = keys.filter(filterHiddenOptions);
722
+ keys = Object.keys(keys.reduce((acc, key)=>{
723
+ if ('_' !== key) acc[key] = true;
724
+ return acc;
725
+ }, {}));
726
+ const theWrap = self.getWrap();
727
+ const ui = shim.cliui({
728
+ width: theWrap,
729
+ wrap: !!theWrap
730
+ });
731
+ if (!usageDisabled) {
732
+ if (usages.length) {
733
+ usages.forEach((usage)=>{
734
+ ui.div({
735
+ text: `${usage[0].replace(/\$0/g, base$0)}`
736
+ });
737
+ if (usage[1]) ui.div({
738
+ text: `${usage[1]}`,
739
+ padding: [
740
+ 1,
741
+ 0,
742
+ 0,
743
+ 0
744
+ ]
745
+ });
746
+ });
747
+ ui.div();
748
+ } else if (commands.length) {
749
+ let u = null;
750
+ u = demandedCommands._ ? `${base$0} <${__('command')}>\n` : `${base$0} [${__('command')}]\n`;
751
+ ui.div(`${u}`);
752
+ }
753
+ }
754
+ if (commands.length > 1 || 1 === commands.length && !commands[0][2]) {
755
+ ui.div(__('Commands:'));
756
+ const context = yargs.getInternalMethods().getContext();
757
+ const parentCommands = context.commands.length ? `${context.commands.join(' ')} ` : '';
758
+ if (true === yargs.getInternalMethods().getParserConfiguration()['sort-commands']) commands = commands.sort((a, b)=>a[0].localeCompare(b[0]));
759
+ const prefix = base$0 ? `${base$0} ` : '';
760
+ commands.forEach((command)=>{
761
+ const commandString = `${prefix}${parentCommands}${command[0].replace(/^\$0 ?/, '')}`;
762
+ ui.span({
763
+ text: commandString,
764
+ padding: [
765
+ 0,
766
+ 2,
767
+ 0,
768
+ 2
769
+ ],
770
+ width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4
771
+ }, {
772
+ text: command[1]
773
+ });
774
+ const hints = [];
775
+ if (command[2]) hints.push(`[${__('default')}]`);
776
+ if (command[3] && command[3].length) hints.push(`[${__('aliases:')} ${command[3].join(', ')}]`);
777
+ if (command[4]) if ('string' == typeof command[4]) hints.push(`[${__('deprecated: %s', command[4])}]`);
778
+ else hints.push(`[${__('deprecated')}]`);
779
+ if (hints.length) ui.div({
780
+ text: hints.join(' '),
781
+ padding: [
782
+ 0,
783
+ 0,
784
+ 0,
785
+ 2
786
+ ],
787
+ align: 'right'
788
+ });
789
+ else ui.div();
790
+ });
791
+ ui.div();
792
+ }
793
+ const aliasKeys = (Object.keys(options.alias) || []).concat(Object.keys(yargs.parsed.newAliases) || []);
794
+ keys = keys.filter((key)=>!yargs.parsed.newAliases[key] && aliasKeys.every((alias)=>-1 === (options.alias[alias] || []).indexOf(key)));
795
+ const defaultGroup = __('Options:');
796
+ if (!groups[defaultGroup]) groups[defaultGroup] = [];
797
+ addUngroupedKeys(keys, options.alias, groups, defaultGroup);
798
+ const isLongSwitch = (sw)=>/^--/.test(getText(sw));
799
+ const displayedGroups = Object.keys(groups).filter((groupName)=>groups[groupName].length > 0).map((groupName)=>{
800
+ const normalizedKeys = groups[groupName].filter(filterHiddenOptions).map((key)=>{
801
+ if (aliasKeys.includes(key)) return key;
802
+ for(let i = 0, aliasKey; void 0 !== (aliasKey = aliasKeys[i]); i++)if ((options.alias[aliasKey] || []).includes(key)) return aliasKey;
803
+ return key;
804
+ });
805
+ return {
806
+ groupName,
807
+ normalizedKeys
808
+ };
809
+ }).filter(({ normalizedKeys })=>normalizedKeys.length > 0).map(({ groupName, normalizedKeys })=>{
810
+ const switches = normalizedKeys.reduce((acc, key)=>{
811
+ acc[key] = [
812
+ key
813
+ ].concat(options.alias[key] || []).map((sw)=>{
814
+ if (groupName === self.getPositionalGroupName()) return sw;
815
+ return (/^[0-9]$/.test(sw) ? options.boolean.includes(key) ? '-' : '--' : sw.length > 1 ? '--' : '-') + sw;
816
+ }).sort((sw1, sw2)=>isLongSwitch(sw1) === isLongSwitch(sw2) ? 0 : isLongSwitch(sw1) ? 1 : -1).join(', ');
817
+ return acc;
818
+ }, {});
819
+ return {
820
+ groupName,
821
+ normalizedKeys,
822
+ switches
823
+ };
824
+ });
825
+ const shortSwitchesUsed = displayedGroups.filter(({ groupName })=>groupName !== self.getPositionalGroupName()).some(({ normalizedKeys, switches })=>!normalizedKeys.every((key)=>isLongSwitch(switches[key])));
826
+ if (shortSwitchesUsed) displayedGroups.filter(({ groupName })=>groupName !== self.getPositionalGroupName()).forEach(({ normalizedKeys, switches })=>{
827
+ normalizedKeys.forEach((key)=>{
828
+ if (isLongSwitch(switches[key])) switches[key] = addIndentation(switches[key], 4);
829
+ });
830
+ });
831
+ displayedGroups.forEach(({ groupName, normalizedKeys, switches })=>{
832
+ ui.div(groupName);
833
+ normalizedKeys.forEach((key)=>{
834
+ const kswitch = switches[key];
835
+ let desc = descriptions[key] || '';
836
+ let type = null;
837
+ if (desc.includes(deferY18nLookupPrefix)) desc = __(desc.substring(deferY18nLookupPrefix.length));
838
+ if (options.boolean.includes(key)) type = `[${__('boolean')}]`;
839
+ if (options.count.includes(key)) type = `[${__('count')}]`;
840
+ if (options.string.includes(key)) type = `[${__('string')}]`;
841
+ if (options.normalize.includes(key)) type = `[${__('string')}]`;
842
+ if (options.array.includes(key)) type = `[${__('array')}]`;
843
+ if (options.number.includes(key)) type = `[${__('number')}]`;
844
+ const deprecatedExtra = (deprecated)=>'string' == typeof deprecated ? `[${__('deprecated: %s', deprecated)}]` : `[${__('deprecated')}]`;
845
+ const extra = [
846
+ key in deprecatedOptions ? deprecatedExtra(deprecatedOptions[key]) : null,
847
+ type,
848
+ key in demandedOptions ? `[${__('required')}]` : null,
849
+ options.choices && options.choices[key] ? `[${__('choices:')} ${self.stringifiedValues(options.choices[key])}]` : null,
850
+ defaultString(options.default[key], options.defaultDescription[key])
851
+ ].filter(Boolean).join(' ');
852
+ ui.span({
853
+ text: getText(kswitch),
854
+ padding: [
855
+ 0,
856
+ 2,
857
+ 0,
858
+ 2 + getIndentation(kswitch)
859
+ ],
860
+ width: maxWidth(switches, theWrap) + 4
861
+ }, desc);
862
+ const shouldHideOptionExtras = true === yargs.getInternalMethods().getUsageConfiguration()['hide-types'];
863
+ if (extra && !shouldHideOptionExtras) ui.div({
864
+ text: extra,
865
+ padding: [
866
+ 0,
867
+ 0,
868
+ 0,
869
+ 2
870
+ ],
871
+ align: 'right'
872
+ });
873
+ else ui.div();
874
+ });
875
+ ui.div();
876
+ });
877
+ if (examples.length) {
878
+ ui.div(__('Examples:'));
879
+ examples.forEach((example)=>{
880
+ example[0] = example[0].replace(/\$0/g, base$0);
881
+ });
882
+ examples.forEach((example)=>{
883
+ if ('' === example[1]) ui.div({
884
+ text: example[0],
885
+ padding: [
886
+ 0,
887
+ 2,
888
+ 0,
889
+ 2
890
+ ]
891
+ });
892
+ else ui.div({
893
+ text: example[0],
894
+ padding: [
895
+ 0,
896
+ 2,
897
+ 0,
898
+ 2
899
+ ],
900
+ width: maxWidth(examples, theWrap) + 4
901
+ }, {
902
+ text: example[1]
903
+ });
904
+ });
905
+ ui.div();
906
+ }
907
+ if (epilogs.length > 0) {
908
+ const e = epilogs.map((epilog)=>epilog.replace(/\$0/g, base$0)).join('\n');
909
+ ui.div(`${e}\n`);
910
+ }
911
+ return ui.toString().replace(/\s*$/, '');
912
+ };
913
+ function maxWidth(table, theWrap, modifier) {
914
+ let width = 0;
915
+ if (!Array.isArray(table)) table = Object.values(table).map((v)=>[
916
+ v
917
+ ]);
918
+ table.forEach((v)=>{
919
+ width = Math.max(shim.stringWidth(modifier ? `${modifier} ${getText(v[0])}` : getText(v[0])) + getIndentation(v[0]), width);
920
+ });
921
+ if (theWrap) width = Math.min(width, parseInt((0.5 * theWrap).toString(), 10));
922
+ return width;
923
+ }
924
+ function normalizeAliases() {
925
+ const demandedOptions = yargs.getDemandedOptions();
926
+ const options = yargs.getOptions();
927
+ (Object.keys(options.alias) || []).forEach((key)=>{
928
+ options.alias[key].forEach((alias)=>{
929
+ if (descriptions[alias]) self.describe(key, descriptions[alias]);
930
+ if (alias in demandedOptions) yargs.demandOption(key, demandedOptions[alias]);
931
+ if (options.boolean.includes(alias)) yargs.boolean(key);
932
+ if (options.count.includes(alias)) yargs.count(key);
933
+ if (options.string.includes(alias)) yargs.string(key);
934
+ if (options.normalize.includes(alias)) yargs.normalize(key);
935
+ if (options.array.includes(alias)) yargs.array(key);
936
+ if (options.number.includes(alias)) yargs.number(key);
937
+ });
938
+ });
939
+ }
940
+ let cachedHelpMessage;
941
+ self.cacheHelpMessage = function() {
942
+ cachedHelpMessage = this.help();
943
+ };
944
+ self.clearCachedHelpMessage = function() {
945
+ cachedHelpMessage = void 0;
946
+ };
947
+ self.hasCachedHelpMessage = function() {
948
+ return !!cachedHelpMessage;
949
+ };
950
+ function addUngroupedKeys(keys, aliases, groups, defaultGroup) {
951
+ let groupedKeys = [];
952
+ let toCheck = null;
953
+ Object.keys(groups).forEach((group)=>{
954
+ groupedKeys = groupedKeys.concat(groups[group]);
955
+ });
956
+ keys.forEach((key)=>{
957
+ toCheck = [
958
+ key
959
+ ].concat(aliases[key]);
960
+ if (!toCheck.some((k)=>-1 !== groupedKeys.indexOf(k))) groups[defaultGroup].push(key);
961
+ });
962
+ return groupedKeys;
963
+ }
964
+ function filterHiddenOptions(key) {
965
+ return yargs.getOptions().hiddenOptions.indexOf(key) < 0 || yargs.parsed.argv[yargs.getOptions().showHiddenOpt];
966
+ }
967
+ self.showHelp = (level)=>{
968
+ const logger = yargs.getInternalMethods().getLoggerInstance();
969
+ if (!level) level = 'error';
970
+ const emit = 'function' == typeof level ? level : logger[level];
971
+ emit(self.help());
972
+ };
973
+ self.functionDescription = (fn)=>{
974
+ const description = fn.name ? shim.Parser.decamelize(fn.name, '-') : __('generated-value');
975
+ return [
976
+ '(',
977
+ description,
978
+ ')'
979
+ ].join('');
980
+ };
981
+ self.stringifiedValues = function(values, separator) {
982
+ let string = '';
983
+ const sep = separator || ', ';
984
+ const array = [].concat(values);
985
+ if (!values || !array.length) return string;
986
+ array.forEach((value)=>{
987
+ if (string.length) string += sep;
988
+ string += JSON.stringify(value);
989
+ });
990
+ return string;
991
+ };
992
+ function defaultString(value, defaultDescription) {
993
+ let string = `[${__('default:')} `;
994
+ if (void 0 === value && !defaultDescription) return null;
995
+ if (defaultDescription) string += defaultDescription;
996
+ else switch(typeof value){
997
+ case 'string':
998
+ string += `"${value}"`;
999
+ break;
1000
+ case 'object':
1001
+ string += JSON.stringify(value);
1002
+ break;
1003
+ default:
1004
+ string += value;
1005
+ }
1006
+ return `${string}]`;
1007
+ }
1008
+ function windowWidth() {
1009
+ const maxWidth = 80;
1010
+ if (shim.process.stdColumns) return Math.min(maxWidth, shim.process.stdColumns);
1011
+ return maxWidth;
1012
+ }
1013
+ let version = null;
1014
+ self.version = (ver)=>{
1015
+ version = ver;
1016
+ };
1017
+ self.showVersion = (level)=>{
1018
+ const logger = yargs.getInternalMethods().getLoggerInstance();
1019
+ if (!level) level = 'error';
1020
+ const emit = 'function' == typeof level ? level : logger[level];
1021
+ emit(version);
1022
+ };
1023
+ self.reset = function(localLookup) {
1024
+ failMessage = null;
1025
+ failureOutput = false;
1026
+ usages = [];
1027
+ usageDisabled = false;
1028
+ epilogs = [];
1029
+ examples = [];
1030
+ commands = [];
1031
+ descriptions = objFilter(descriptions, (k)=>!localLookup[k]);
1032
+ return self;
1033
+ };
1034
+ const frozens = [];
1035
+ self.freeze = function() {
1036
+ frozens.push({
1037
+ failMessage,
1038
+ failureOutput,
1039
+ usages,
1040
+ usageDisabled,
1041
+ epilogs,
1042
+ examples,
1043
+ commands,
1044
+ descriptions
1045
+ });
1046
+ };
1047
+ self.unfreeze = function(defaultCommand = false) {
1048
+ const frozen = frozens.pop();
1049
+ if (!frozen) return;
1050
+ if (defaultCommand) {
1051
+ descriptions = {
1052
+ ...frozen.descriptions,
1053
+ ...descriptions
1054
+ };
1055
+ commands = [
1056
+ ...frozen.commands,
1057
+ ...commands
1058
+ ];
1059
+ usages = [
1060
+ ...frozen.usages,
1061
+ ...usages
1062
+ ];
1063
+ examples = [
1064
+ ...frozen.examples,
1065
+ ...examples
1066
+ ];
1067
+ epilogs = [
1068
+ ...frozen.epilogs,
1069
+ ...epilogs
1070
+ ];
1071
+ } else ({ failMessage, failureOutput, usages, usageDisabled, epilogs, examples, commands, descriptions } = frozen);
1072
+ };
1073
+ return self;
1074
+ }
1075
+ function isIndentedText(text) {
1076
+ return 'object' == typeof text;
1077
+ }
1078
+ function addIndentation(text, indent) {
1079
+ return isIndentedText(text) ? {
1080
+ text: text.text,
1081
+ indentation: text.indentation + indent
1082
+ } : {
1083
+ text,
1084
+ indentation: indent
1085
+ };
1086
+ }
1087
+ function getIndentation(text) {
1088
+ return isIndentedText(text) ? text.indentation : 0;
1089
+ }
1090
+ function getText(text) {
1091
+ return isIndentedText(text) ? text.text : text;
1092
+ }
1093
+ const completionShTemplate = `###-begin-{{app_name}}-completions-###
1094
+ #
1095
+ # yargs command completion script
1096
+ #
1097
+ # Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
1098
+ # or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
1099
+ #
1100
+ _{{app_name}}_yargs_completions()
1101
+ {
1102
+ local cur_word args type_list
1103
+
1104
+ cur_word="\${COMP_WORDS[COMP_CWORD]}"
1105
+ args=("\${COMP_WORDS[@]}")
1106
+
1107
+ # ask yargs to generate completions.
1108
+ type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
1109
+
1110
+ COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
1111
+
1112
+ # if no match was found, fall back to filename completion
1113
+ if [ \${#COMPREPLY[@]} -eq 0 ]; then
1114
+ COMPREPLY=()
1115
+ fi
1116
+
1117
+ return 0
1118
+ }
1119
+ complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
1120
+ ###-end-{{app_name}}-completions-###
1121
+ `;
1122
+ const completionZshTemplate = `#compdef {{app_name}}
1123
+ ###-begin-{{app_name}}-completions-###
1124
+ #
1125
+ # yargs command completion script
1126
+ #
1127
+ # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
1128
+ # or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
1129
+ #
1130
+ _{{app_name}}_yargs_completions()
1131
+ {
1132
+ local reply
1133
+ local si=$IFS
1134
+ IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
1135
+ IFS=$si
1136
+ _describe 'values' reply
1137
+ }
1138
+ compdef _{{app_name}}_yargs_completions {{app_name}}
1139
+ ###-end-{{app_name}}-completions-###
1140
+ `;
1141
+ class Completion {
1142
+ constructor(yargs, usage, command, shim){
1143
+ var _a, _b, _c;
1144
+ this.yargs = yargs;
1145
+ this.usage = usage;
1146
+ this.command = command;
1147
+ this.shim = shim;
1148
+ this.completionKey = 'get-yargs-completions';
1149
+ this.aliases = null;
1150
+ this.customCompletionFunction = null;
1151
+ this.indexAfterLastReset = 0;
1152
+ this.zshShell = null != (_c = (null == (_a = this.shim.getEnv('SHELL')) ? void 0 : _a.includes('zsh')) || (null == (_b = this.shim.getEnv('ZSH_NAME')) ? void 0 : _b.includes('zsh'))) ? _c : false;
1153
+ }
1154
+ defaultCompletion(args, argv, current, done) {
1155
+ const handlers = this.command.getCommandHandlers();
1156
+ for(let i = 0, ii = args.length; i < ii; ++i)if (handlers[args[i]] && handlers[args[i]].builder) {
1157
+ const builder = handlers[args[i]].builder;
1158
+ if (isCommandBuilderCallback(builder)) {
1159
+ this.indexAfterLastReset = i + 1;
1160
+ const y = this.yargs.getInternalMethods().reset();
1161
+ builder(y, true);
1162
+ return y.argv;
1163
+ }
1164
+ }
1165
+ const completions = [];
1166
+ this.commandCompletions(completions, args, current);
1167
+ this.optionCompletions(completions, args, argv, current);
1168
+ this.choicesFromOptionsCompletions(completions, args, argv, current);
1169
+ this.choicesFromPositionalsCompletions(completions, args, argv, current);
1170
+ done(null, completions);
1171
+ }
1172
+ commandCompletions(completions, args, current) {
1173
+ const parentCommands = this.yargs.getInternalMethods().getContext().commands;
1174
+ if (!current.match(/^-/) && parentCommands[parentCommands.length - 1] !== current && !this.previousArgHasChoices(args)) this.usage.getCommands().forEach((usageCommand)=>{
1175
+ const commandName = parseCommand(usageCommand[0]).cmd;
1176
+ if (-1 === args.indexOf(commandName)) if (this.zshShell) {
1177
+ const desc = usageCommand[1] || '';
1178
+ completions.push(commandName.replace(/:/g, '\\:') + ':' + desc);
1179
+ } else completions.push(commandName);
1180
+ });
1181
+ }
1182
+ optionCompletions(completions, args, argv, current) {
1183
+ if ((current.match(/^-/) || '' === current && 0 === completions.length) && !this.previousArgHasChoices(args)) {
1184
+ const options = this.yargs.getOptions();
1185
+ const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
1186
+ Object.keys(options.key).forEach((key)=>{
1187
+ const negable = !!options.configuration['boolean-negation'] && options.boolean.includes(key);
1188
+ const isPositionalKey = positionalKeys.includes(key);
1189
+ if (!isPositionalKey && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, key, negable)) this.completeOptionKey(key, completions, current, negable && !!options.default[key]);
1190
+ });
1191
+ }
1192
+ }
1193
+ choicesFromOptionsCompletions(completions, args, argv, current) {
1194
+ if (this.previousArgHasChoices(args)) {
1195
+ const choices = this.getPreviousArgChoices(args);
1196
+ if (choices && choices.length > 0) completions.push(...choices.map((c)=>c.replace(/:/g, '\\:')));
1197
+ }
1198
+ }
1199
+ choicesFromPositionalsCompletions(completions, args, argv, current) {
1200
+ if ('' === current && completions.length > 0 && this.previousArgHasChoices(args)) return;
1201
+ const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
1202
+ const offset = Math.max(this.indexAfterLastReset, this.yargs.getInternalMethods().getContext().commands.length + 1);
1203
+ const positionalKey = positionalKeys[argv._.length - offset - 1];
1204
+ if (!positionalKey) return;
1205
+ const choices = this.yargs.getOptions().choices[positionalKey] || [];
1206
+ for (const choice of choices)if (choice.startsWith(current)) completions.push(choice.replace(/:/g, '\\:'));
1207
+ }
1208
+ getPreviousArgChoices(args) {
1209
+ if (args.length < 1) return;
1210
+ let previousArg = args[args.length - 1];
1211
+ let filter = '';
1212
+ if (!previousArg.startsWith('-') && args.length > 1) {
1213
+ filter = previousArg;
1214
+ previousArg = args[args.length - 2];
1215
+ }
1216
+ if (!previousArg.startsWith('-')) return;
1217
+ const previousArgKey = previousArg.replace(/^-+/, '');
1218
+ const options = this.yargs.getOptions();
1219
+ const possibleAliases = [
1220
+ previousArgKey,
1221
+ ...this.yargs.getAliases()[previousArgKey] || []
1222
+ ];
1223
+ let choices;
1224
+ for (const possibleAlias of possibleAliases)if (Object.prototype.hasOwnProperty.call(options.key, possibleAlias) && Array.isArray(options.choices[possibleAlias])) {
1225
+ choices = options.choices[possibleAlias];
1226
+ break;
1227
+ }
1228
+ if (choices) return choices.filter((choice)=>!filter || choice.startsWith(filter));
1229
+ }
1230
+ previousArgHasChoices(args) {
1231
+ const choices = this.getPreviousArgChoices(args);
1232
+ return void 0 !== choices && choices.length > 0;
1233
+ }
1234
+ argsContainKey(args, key, negable) {
1235
+ const argsContains = (s)=>-1 !== args.indexOf((/^[^0-9]$/.test(s) ? '-' : '--') + s);
1236
+ if (argsContains(key)) return true;
1237
+ if (negable && argsContains(`no-${key}`)) return true;
1238
+ if (this.aliases) {
1239
+ for (const alias of this.aliases[key])if (argsContains(alias)) return true;
1240
+ }
1241
+ return false;
1242
+ }
1243
+ completeOptionKey(key, completions, current, negable) {
1244
+ var _a, _b, _c, _d;
1245
+ let keyWithDesc = key;
1246
+ if (this.zshShell) {
1247
+ const descs = this.usage.getDescriptions();
1248
+ const aliasKey = null == (_b = null == (_a = this === null || void 0 === this ? void 0 : this.aliases) ? void 0 : _a[key]) ? void 0 : _b.find((alias)=>{
1249
+ const desc = descs[alias];
1250
+ return 'string' == typeof desc && desc.length > 0;
1251
+ });
1252
+ const descFromAlias = aliasKey ? descs[aliasKey] : void 0;
1253
+ const desc = null != (_d = null != (_c = descs[key]) ? _c : descFromAlias) ? _d : '';
1254
+ keyWithDesc = `${key.replace(/:/g, '\\:')}:${desc.replace('__yargsString__:', '').replace(/(\r\n|\n|\r)/gm, ' ')}`;
1255
+ }
1256
+ const startsByTwoDashes = (s)=>/^--/.test(s);
1257
+ const isShortOption = (s)=>/^[^0-9]$/.test(s);
1258
+ const dashes = !startsByTwoDashes(current) && isShortOption(key) ? '-' : '--';
1259
+ completions.push(dashes + keyWithDesc);
1260
+ if (negable) completions.push(dashes + 'no-' + keyWithDesc);
1261
+ }
1262
+ customCompletion(args, argv, current, done) {
1263
+ assertNotStrictEqual(this.customCompletionFunction, null, this.shim);
1264
+ if (isSyncCompletionFunction(this.customCompletionFunction)) {
1265
+ const result = this.customCompletionFunction(current, argv);
1266
+ if (isPromise(result)) return result.then((list)=>{
1267
+ this.shim.process.nextTick(()=>{
1268
+ done(null, list);
1269
+ });
1270
+ }).catch((err)=>{
1271
+ this.shim.process.nextTick(()=>{
1272
+ done(err, void 0);
1273
+ });
1274
+ });
1275
+ return done(null, result);
1276
+ }
1277
+ if (isFallbackCompletionFunction(this.customCompletionFunction)) return this.customCompletionFunction(current, argv, (onCompleted = done)=>this.defaultCompletion(args, argv, current, onCompleted), (completions)=>{
1278
+ done(null, completions);
1279
+ });
1280
+ return this.customCompletionFunction(current, argv, (completions)=>{
1281
+ done(null, completions);
1282
+ });
1283
+ }
1284
+ getCompletion(args, done) {
1285
+ const current = args.length ? args[args.length - 1] : '';
1286
+ const argv = this.yargs.parse(args, true);
1287
+ const completionFunction = this.customCompletionFunction ? (argv)=>this.customCompletion(args, argv, current, done) : (argv)=>this.defaultCompletion(args, argv, current, done);
1288
+ return isPromise(argv) ? argv.then(completionFunction) : completionFunction(argv);
1289
+ }
1290
+ generateCompletionScript($0, cmd) {
1291
+ let script = this.zshShell ? completionZshTemplate : completionShTemplate;
1292
+ const name = this.shim.path.basename($0);
1293
+ if ($0.match(/\.js$/)) $0 = `./${$0}`;
1294
+ script = script.replace(/{{app_name}}/g, name);
1295
+ script = script.replace(/{{completion_command}}/g, cmd);
1296
+ return script.replace(/{{app_path}}/g, $0);
1297
+ }
1298
+ registerFunction(fn) {
1299
+ this.customCompletionFunction = fn;
1300
+ }
1301
+ setParsed(parsed) {
1302
+ this.aliases = parsed.aliases;
1303
+ }
1304
+ }
1305
+ function completion_completion(yargs, usage, command, shim) {
1306
+ return new Completion(yargs, usage, command, shim);
1307
+ }
1308
+ function isSyncCompletionFunction(completionFunction) {
1309
+ return completionFunction.length < 3;
1310
+ }
1311
+ function isFallbackCompletionFunction(completionFunction) {
1312
+ return completionFunction.length > 3;
1313
+ }
1314
+ function levenshtein(a, b) {
1315
+ if (0 === a.length) return b.length;
1316
+ if (0 === b.length) return a.length;
1317
+ const matrix = [];
1318
+ let i;
1319
+ for(i = 0; i <= b.length; i++)matrix[i] = [
1320
+ i
1321
+ ];
1322
+ let j;
1323
+ for(j = 0; j <= a.length; j++)matrix[0][j] = j;
1324
+ 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];
1325
+ 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;
1326
+ else matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
1327
+ return matrix[b.length][a.length];
1328
+ }
1329
+ const specialKeys = [
1330
+ '$0',
1331
+ '--',
1332
+ '_'
1333
+ ];
1334
+ function validation_validation(yargs, usage, shim) {
1335
+ const __ = shim.y18n.__;
1336
+ const __n = shim.y18n.__n;
1337
+ const self = {};
1338
+ self.nonOptionCount = function(argv) {
1339
+ const demandedCommands = yargs.getDemandedCommands();
1340
+ const positionalCount = argv._.length + (argv['--'] ? argv['--'].length : 0);
1341
+ const _s = positionalCount - yargs.getInternalMethods().getContext().commands.length;
1342
+ if (demandedCommands._ && (_s < demandedCommands._.min || _s > demandedCommands._.max)) {
1343
+ if (_s < demandedCommands._.min) if (void 0 !== demandedCommands._.minMsg) usage.fail(demandedCommands._.minMsg ? demandedCommands._.minMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.min.toString()) : null);
1344
+ else usage.fail(__n('Not enough non-option arguments: got %s, need at least %s', 'Not enough non-option arguments: got %s, need at least %s', _s, _s.toString(), demandedCommands._.min.toString()));
1345
+ else if (_s > demandedCommands._.max) if (void 0 !== demandedCommands._.maxMsg) usage.fail(demandedCommands._.maxMsg ? demandedCommands._.maxMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.max.toString()) : null);
1346
+ else usage.fail(__n('Too many non-option arguments: got %s, maximum of %s', 'Too many non-option arguments: got %s, maximum of %s', _s, _s.toString(), demandedCommands._.max.toString()));
1347
+ }
1348
+ };
1349
+ self.positionalCount = function(required, observed) {
1350
+ if (observed < required) usage.fail(__n('Not enough non-option arguments: got %s, need at least %s', 'Not enough non-option arguments: got %s, need at least %s', observed, observed + '', required + ''));
1351
+ };
1352
+ self.requiredArguments = function(argv, demandedOptions) {
1353
+ let missing = null;
1354
+ for (const key of Object.keys(demandedOptions))if (!Object.prototype.hasOwnProperty.call(argv, key) || void 0 === argv[key]) {
1355
+ missing = missing || {};
1356
+ missing[key] = demandedOptions[key];
1357
+ }
1358
+ if (missing) {
1359
+ const customMsgs = [];
1360
+ for (const key of Object.keys(missing)){
1361
+ const msg = missing[key];
1362
+ if (msg && customMsgs.indexOf(msg) < 0) customMsgs.push(msg);
1363
+ }
1364
+ const customMsg = customMsgs.length ? `\n${customMsgs.join('\n')}` : '';
1365
+ usage.fail(__n('Missing required argument: %s', 'Missing required arguments: %s', Object.keys(missing).length, Object.keys(missing).join(', ') + customMsg));
1366
+ }
1367
+ };
1368
+ self.unknownArguments = function(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
1369
+ var _a;
1370
+ const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
1371
+ const unknown = [];
1372
+ const currentContext = yargs.getInternalMethods().getContext();
1373
+ Object.keys(argv).forEach((key)=>{
1374
+ 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);
1375
+ });
1376
+ if (checkPositionals && (currentContext.commands.length > 0 || commandKeys.length > 0 || isDefaultCommand)) argv._.slice(currentContext.commands.length).forEach((key)=>{
1377
+ if (!commandKeys.includes('' + key)) unknown.push('' + key);
1378
+ });
1379
+ if (checkPositionals) {
1380
+ const demandedCommands = yargs.getDemandedCommands();
1381
+ const maxNonOptDemanded = (null == (_a = demandedCommands._) ? void 0 : _a.max) || 0;
1382
+ const expected = currentContext.commands.length + maxNonOptDemanded;
1383
+ if (expected < argv._.length) argv._.slice(expected).forEach((key)=>{
1384
+ key = String(key);
1385
+ if (!currentContext.commands.includes(key) && !unknown.includes(key)) unknown.push(key);
1386
+ });
1387
+ }
1388
+ if (unknown.length) usage.fail(__n('Unknown argument: %s', 'Unknown arguments: %s', unknown.length, unknown.map((s)=>s.trim() ? s : `"${s}"`).join(', ')));
1389
+ };
1390
+ self.unknownCommands = function(argv) {
1391
+ const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
1392
+ const unknown = [];
1393
+ const currentContext = yargs.getInternalMethods().getContext();
1394
+ if (currentContext.commands.length > 0 || commandKeys.length > 0) argv._.slice(currentContext.commands.length).forEach((key)=>{
1395
+ if (!commandKeys.includes('' + key)) unknown.push('' + key);
1396
+ });
1397
+ if (!(unknown.length > 0)) return false;
1398
+ usage.fail(__n('Unknown command: %s', 'Unknown commands: %s', unknown.length, unknown.join(', ')));
1399
+ return true;
1400
+ };
1401
+ self.isValidAndSomeAliasIsNotNew = function(key, aliases) {
1402
+ if (!Object.prototype.hasOwnProperty.call(aliases, key)) return false;
1403
+ const newAliases = yargs.parsed.newAliases;
1404
+ return [
1405
+ key,
1406
+ ...aliases[key]
1407
+ ].some((a)=>!Object.prototype.hasOwnProperty.call(newAliases, a) || !newAliases[key]);
1408
+ };
1409
+ self.limitedChoices = function(argv) {
1410
+ const options = yargs.getOptions();
1411
+ const invalid = {};
1412
+ if (!Object.keys(options.choices).length) return;
1413
+ Object.keys(argv).forEach((key)=>{
1414
+ if (-1 === specialKeys.indexOf(key) && Object.prototype.hasOwnProperty.call(options.choices, key)) [].concat(argv[key]).forEach((value)=>{
1415
+ if (-1 === options.choices[key].indexOf(value) && void 0 !== value) invalid[key] = (invalid[key] || []).concat(value);
1416
+ });
1417
+ });
1418
+ const invalidKeys = Object.keys(invalid);
1419
+ if (!invalidKeys.length) return;
1420
+ let msg = __('Invalid values:');
1421
+ invalidKeys.forEach((key)=>{
1422
+ msg += `\n ${__('Argument: %s, Given: %s, Choices: %s', key, usage.stringifiedValues(invalid[key]), usage.stringifiedValues(options.choices[key]))}`;
1423
+ });
1424
+ usage.fail(msg);
1425
+ };
1426
+ let implied = {};
1427
+ self.implies = function(key, value) {
1428
+ argsert('<string|object> [array|number|string]', [
1429
+ key,
1430
+ value
1431
+ ], arguments.length);
1432
+ if ('object' == typeof key) Object.keys(key).forEach((k)=>{
1433
+ self.implies(k, key[k]);
1434
+ });
1435
+ else {
1436
+ yargs.global(key);
1437
+ if (!implied[key]) implied[key] = [];
1438
+ if (Array.isArray(value)) value.forEach((i)=>self.implies(key, i));
1439
+ else {
1440
+ assertNotStrictEqual(value, void 0, shim);
1441
+ implied[key].push(value);
1442
+ }
1443
+ }
1444
+ };
1445
+ self.getImplied = function() {
1446
+ return implied;
1447
+ };
1448
+ function keyExists(argv, val) {
1449
+ const num = Number(val);
1450
+ val = isNaN(num) ? val : num;
1451
+ if ('number' == typeof val) val = argv._.length >= val;
1452
+ else if (val.match(/^--no-.+/)) {
1453
+ val = val.match(/^--no-(.+)/)[1];
1454
+ val = !Object.prototype.hasOwnProperty.call(argv, val);
1455
+ } else val = Object.prototype.hasOwnProperty.call(argv, val);
1456
+ return val;
1457
+ }
1458
+ self.implications = function(argv) {
1459
+ const implyFail = [];
1460
+ Object.keys(implied).forEach((key)=>{
1461
+ const origKey = key;
1462
+ (implied[key] || []).forEach((value)=>{
1463
+ let key = origKey;
1464
+ const origValue = value;
1465
+ key = keyExists(argv, key);
1466
+ value = keyExists(argv, value);
1467
+ if (key && !value) implyFail.push(` ${origKey} -> ${origValue}`);
1468
+ });
1469
+ });
1470
+ if (implyFail.length) {
1471
+ let msg = `${__('Implications failed:')}\n`;
1472
+ implyFail.forEach((value)=>{
1473
+ msg += value;
1474
+ });
1475
+ usage.fail(msg);
1476
+ }
1477
+ };
1478
+ let conflicting = {};
1479
+ self.conflicts = function(key, value) {
1480
+ argsert('<string|object> [array|string]', [
1481
+ key,
1482
+ value
1483
+ ], arguments.length);
1484
+ if ('object' == typeof key) Object.keys(key).forEach((k)=>{
1485
+ self.conflicts(k, key[k]);
1486
+ });
1487
+ else {
1488
+ yargs.global(key);
1489
+ if (!conflicting[key]) conflicting[key] = [];
1490
+ if (Array.isArray(value)) value.forEach((i)=>self.conflicts(key, i));
1491
+ else conflicting[key].push(value);
1492
+ }
1493
+ };
1494
+ self.getConflicting = ()=>conflicting;
1495
+ self.conflicting = function(argv) {
1496
+ Object.keys(argv).forEach((key)=>{
1497
+ if (conflicting[key]) conflicting[key].forEach((value)=>{
1498
+ if (value && void 0 !== argv[key] && void 0 !== argv[value]) usage.fail(__('Arguments %s and %s are mutually exclusive', key, value));
1499
+ });
1500
+ });
1501
+ if (yargs.getInternalMethods().getParserConfiguration()['strip-dashed']) Object.keys(conflicting).forEach((key)=>{
1502
+ conflicting[key].forEach((value)=>{
1503
+ if (value && void 0 !== argv[shim.Parser.camelCase(key)] && void 0 !== argv[shim.Parser.camelCase(value)]) usage.fail(__('Arguments %s and %s are mutually exclusive', key, value));
1504
+ });
1505
+ });
1506
+ };
1507
+ self.recommendCommands = function(cmd, potentialCommands) {
1508
+ const threshold = 3;
1509
+ potentialCommands = potentialCommands.sort((a, b)=>b.length - a.length);
1510
+ let recommended = null;
1511
+ let bestDistance = 1 / 0;
1512
+ for(let i = 0, candidate; void 0 !== (candidate = potentialCommands[i]); i++){
1513
+ const d = levenshtein(cmd, candidate);
1514
+ if (d <= threshold && d < bestDistance) {
1515
+ bestDistance = d;
1516
+ recommended = candidate;
1517
+ }
1518
+ }
1519
+ if (recommended) usage.fail(__('Did you mean %s?', recommended));
1520
+ };
1521
+ self.reset = function(localLookup) {
1522
+ implied = objFilter(implied, (k)=>!localLookup[k]);
1523
+ conflicting = objFilter(conflicting, (k)=>!localLookup[k]);
1524
+ return self;
1525
+ };
1526
+ const frozens = [];
1527
+ self.freeze = function() {
1528
+ frozens.push({
1529
+ implied,
1530
+ conflicting
1531
+ });
1532
+ };
1533
+ self.unfreeze = function() {
1534
+ const frozen = frozens.pop();
1535
+ assertNotStrictEqual(frozen, void 0, shim);
1536
+ ({ implied, conflicting } = frozen);
1537
+ };
1538
+ return self;
1539
+ }
1540
+ var apply_extends = __webpack_require__("../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/build/lib/utils/apply-extends.js");
1541
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
1542
+ if ("m" === kind) throw new TypeError("Private method is not writable");
1543
+ if ("a" === kind && !f) throw new TypeError("Private accessor was defined without a setter");
1544
+ if ("function" == typeof state ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1545
+ return "a" === kind ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
1546
+ };
1547
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
1548
+ if ("a" === kind && !f) throw new TypeError("Private accessor was defined without a getter");
1549
+ if ("function" == typeof state ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1550
+ return "m" === kind ? f : "a" === kind ? f.call(receiver) : f ? f.value : state.get(receiver);
1551
+ };
1552
+ 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;
1553
+ function YargsFactory(_shim) {
1554
+ return (processArgs = [], cwd = _shim.process.cwd(), parentRequire)=>{
1555
+ const yargs = new YargsInstance(processArgs, cwd, parentRequire, _shim);
1556
+ Object.defineProperty(yargs, 'argv', {
1557
+ get: ()=>yargs.parse(),
1558
+ enumerable: true
1559
+ });
1560
+ yargs.help();
1561
+ yargs.version();
1562
+ return yargs;
1563
+ };
1564
+ }
1565
+ const kCopyDoubleDash = Symbol('copyDoubleDash');
1566
+ const kCreateLogger = Symbol('copyDoubleDash');
1567
+ const kDeleteFromParserHintObject = Symbol('deleteFromParserHintObject');
1568
+ const kEmitWarning = Symbol('emitWarning');
1569
+ const kFreeze = Symbol('freeze');
1570
+ const kGetDollarZero = Symbol('getDollarZero');
1571
+ const kGetParserConfiguration = Symbol('getParserConfiguration');
1572
+ const kGetUsageConfiguration = Symbol('getUsageConfiguration');
1573
+ const kGuessLocale = Symbol('guessLocale');
1574
+ const kGuessVersion = Symbol('guessVersion');
1575
+ const kParsePositionalNumbers = Symbol('parsePositionalNumbers');
1576
+ const kPkgUp = Symbol('pkgUp');
1577
+ const kPopulateParserHintArray = Symbol('populateParserHintArray');
1578
+ const kPopulateParserHintSingleValueDictionary = Symbol('populateParserHintSingleValueDictionary');
1579
+ const kPopulateParserHintArrayDictionary = Symbol('populateParserHintArrayDictionary');
1580
+ const kPopulateParserHintDictionary = Symbol('populateParserHintDictionary');
1581
+ const kSanitizeKey = Symbol('sanitizeKey');
1582
+ const kSetKey = Symbol('setKey');
1583
+ const kUnfreeze = Symbol('unfreeze');
1584
+ const kValidateAsync = Symbol('validateAsync');
1585
+ const kGetCommandInstance = Symbol('getCommandInstance');
1586
+ const kGetContext = Symbol('getContext');
1587
+ const kGetHasOutput = Symbol('getHasOutput');
1588
+ const kGetLoggerInstance = Symbol('getLoggerInstance');
1589
+ const kGetParseContext = Symbol('getParseContext');
1590
+ const kGetUsageInstance = Symbol('getUsageInstance');
1591
+ const kGetValidationInstance = Symbol('getValidationInstance');
1592
+ const kHasParseCallback = Symbol('hasParseCallback');
1593
+ const kIsGlobalContext = Symbol('isGlobalContext');
1594
+ const kPostProcess = Symbol('postProcess');
1595
+ const kRebase = Symbol('rebase');
1596
+ const kReset = Symbol('reset');
1597
+ const kRunYargsParserAndExecuteCommands = Symbol('runYargsParserAndExecuteCommands');
1598
+ const kRunValidation = Symbol('runValidation');
1599
+ const kSetHasOutput = Symbol('setHasOutput');
1600
+ const kTrackManuallySetKeys = Symbol('kTrackManuallySetKeys');
1601
+ class YargsInstance {
1602
+ constructor(processArgs = [], cwd, parentRequire, shim){
1603
+ this.customScriptName = false;
1604
+ this.parsed = false;
1605
+ _YargsInstance_command.set(this, void 0);
1606
+ _YargsInstance_cwd.set(this, void 0);
1607
+ _YargsInstance_context.set(this, {
1608
+ commands: [],
1609
+ fullCommands: []
1610
+ });
1611
+ _YargsInstance_completion.set(this, null);
1612
+ _YargsInstance_completionCommand.set(this, null);
1613
+ _YargsInstance_defaultShowHiddenOpt.set(this, 'show-hidden');
1614
+ _YargsInstance_exitError.set(this, null);
1615
+ _YargsInstance_detectLocale.set(this, true);
1616
+ _YargsInstance_emittedWarnings.set(this, {});
1617
+ _YargsInstance_exitProcess.set(this, true);
1618
+ _YargsInstance_frozens.set(this, []);
1619
+ _YargsInstance_globalMiddleware.set(this, void 0);
1620
+ _YargsInstance_groups.set(this, {});
1621
+ _YargsInstance_hasOutput.set(this, false);
1622
+ _YargsInstance_helpOpt.set(this, null);
1623
+ _YargsInstance_isGlobalContext.set(this, true);
1624
+ _YargsInstance_logger.set(this, void 0);
1625
+ _YargsInstance_output.set(this, '');
1626
+ _YargsInstance_options.set(this, void 0);
1627
+ _YargsInstance_parentRequire.set(this, void 0);
1628
+ _YargsInstance_parserConfig.set(this, {});
1629
+ _YargsInstance_parseFn.set(this, null);
1630
+ _YargsInstance_parseContext.set(this, null);
1631
+ _YargsInstance_pkgs.set(this, {});
1632
+ _YargsInstance_preservedGroups.set(this, {});
1633
+ _YargsInstance_processArgs.set(this, void 0);
1634
+ _YargsInstance_recommendCommands.set(this, false);
1635
+ _YargsInstance_shim.set(this, void 0);
1636
+ _YargsInstance_strict.set(this, false);
1637
+ _YargsInstance_strictCommands.set(this, false);
1638
+ _YargsInstance_strictOptions.set(this, false);
1639
+ _YargsInstance_usage.set(this, void 0);
1640
+ _YargsInstance_usageConfig.set(this, {});
1641
+ _YargsInstance_versionOpt.set(this, null);
1642
+ _YargsInstance_validation.set(this, void 0);
1643
+ __classPrivateFieldSet(this, _YargsInstance_shim, shim, "f");
1644
+ __classPrivateFieldSet(this, _YargsInstance_processArgs, processArgs, "f");
1645
+ __classPrivateFieldSet(this, _YargsInstance_cwd, cwd, "f");
1646
+ __classPrivateFieldSet(this, _YargsInstance_parentRequire, parentRequire, "f");
1647
+ __classPrivateFieldSet(this, _YargsInstance_globalMiddleware, new GlobalMiddleware(this), "f");
1648
+ this.$0 = this[kGetDollarZero]();
1649
+ this[kReset]();
1650
+ __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f"), "f");
1651
+ __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), "f");
1652
+ __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f"), "f");
1653
+ __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f"), "f");
1654
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
1655
+ __classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger](), "f");
1656
+ }
1657
+ addHelpOpt(opt, msg) {
1658
+ const defaultHelpOpt = 'help';
1659
+ argsert('[string|boolean] [string]', [
1660
+ opt,
1661
+ msg
1662
+ ], arguments.length);
1663
+ if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
1664
+ this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
1665
+ __classPrivateFieldSet(this, _YargsInstance_helpOpt, null, "f");
1666
+ }
1667
+ if (false === opt && void 0 === msg) return this;
1668
+ __classPrivateFieldSet(this, _YargsInstance_helpOpt, 'string' == typeof opt ? opt : defaultHelpOpt, "f");
1669
+ this.boolean(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
1670
+ this.describe(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"), msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Show help'));
1671
+ return this;
1672
+ }
1673
+ help(opt, msg) {
1674
+ return this.addHelpOpt(opt, msg);
1675
+ }
1676
+ addShowHiddenOpt(opt, msg) {
1677
+ argsert('[string|boolean] [string]', [
1678
+ opt,
1679
+ msg
1680
+ ], arguments.length);
1681
+ if (false === opt && void 0 === msg) return this;
1682
+ const showHiddenOpt = 'string' == typeof opt ? opt : __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
1683
+ this.boolean(showHiddenOpt);
1684
+ this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Show hidden options'));
1685
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = showHiddenOpt;
1686
+ return this;
1687
+ }
1688
+ showHidden(opt, msg) {
1689
+ return this.addShowHiddenOpt(opt, msg);
1690
+ }
1691
+ alias(key, value) {
1692
+ argsert('<object|string|array> [string|array]', [
1693
+ key,
1694
+ value
1695
+ ], arguments.length);
1696
+ this[kPopulateParserHintArrayDictionary](this.alias.bind(this), 'alias', key, value);
1697
+ return this;
1698
+ }
1699
+ array(keys) {
1700
+ argsert('<array|string>', [
1701
+ keys
1702
+ ], arguments.length);
1703
+ this[kPopulateParserHintArray]('array', keys);
1704
+ this[kTrackManuallySetKeys](keys);
1705
+ return this;
1706
+ }
1707
+ boolean(keys) {
1708
+ argsert('<array|string>', [
1709
+ keys
1710
+ ], arguments.length);
1711
+ this[kPopulateParserHintArray]('boolean', keys);
1712
+ this[kTrackManuallySetKeys](keys);
1713
+ return this;
1714
+ }
1715
+ check(f, global) {
1716
+ argsert('<function> [boolean]', [
1717
+ f,
1718
+ global
1719
+ ], arguments.length);
1720
+ this.middleware((argv, _yargs)=>maybeAsyncResult(()=>f(argv, _yargs.getOptions()), (result)=>{
1721
+ if (result) {
1722
+ if ('string' == typeof result || result instanceof Error) __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(result.toString(), result);
1723
+ } else __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__('Argument check failed: %s', f.toString()));
1724
+ return argv;
1725
+ }, (err)=>{
1726
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message ? err.message : err.toString(), err);
1727
+ return argv;
1728
+ }), false, global);
1729
+ return this;
1730
+ }
1731
+ choices(key, value) {
1732
+ argsert('<object|string|array> [string|array]', [
1733
+ key,
1734
+ value
1735
+ ], arguments.length);
1736
+ this[kPopulateParserHintArrayDictionary](this.choices.bind(this), 'choices', key, value);
1737
+ return this;
1738
+ }
1739
+ coerce(keys, value) {
1740
+ argsert('<object|string|array> [function]', [
1741
+ keys,
1742
+ value
1743
+ ], arguments.length);
1744
+ if (Array.isArray(keys)) {
1745
+ if (!value) throw new yerror.s('coerce callback must be provided');
1746
+ for (const key of keys)this.coerce(key, value);
1747
+ return this;
1748
+ }
1749
+ if ('object' == typeof keys) {
1750
+ for (const key of Object.keys(keys))this.coerce(key, keys[key]);
1751
+ return this;
1752
+ }
1753
+ if (!value) throw new yerror.s('coerce callback must be provided');
1754
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
1755
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs)=>{
1756
+ let aliases;
1757
+ const shouldCoerce = Object.prototype.hasOwnProperty.call(argv, keys);
1758
+ if (!shouldCoerce) return argv;
1759
+ return maybeAsyncResult(()=>{
1760
+ aliases = yargs.getAliases();
1761
+ return value(argv[keys]);
1762
+ }, (result)=>{
1763
+ argv[keys] = result;
1764
+ const stripAliased = yargs.getInternalMethods().getParserConfiguration()['strip-aliased'];
1765
+ if (aliases[keys] && true !== stripAliased) for (const alias of aliases[keys])argv[alias] = result;
1766
+ return argv;
1767
+ }, (err)=>{
1768
+ throw new yerror.s(err.message);
1769
+ });
1770
+ }, keys);
1771
+ return this;
1772
+ }
1773
+ conflicts(key1, key2) {
1774
+ argsert('<string|object> [string|array]', [
1775
+ key1,
1776
+ key2
1777
+ ], arguments.length);
1778
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicts(key1, key2);
1779
+ return this;
1780
+ }
1781
+ config(key = 'config', msg, parseFn) {
1782
+ argsert('[object|string] [string|function] [function]', [
1783
+ key,
1784
+ msg,
1785
+ parseFn
1786
+ ], arguments.length);
1787
+ if ('object' == typeof key && !Array.isArray(key)) {
1788
+ key = (0, apply_extends.J)(key, __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()['deep-merge-config'] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
1789
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(key);
1790
+ return this;
1791
+ }
1792
+ if ('function' == typeof msg) {
1793
+ parseFn = msg;
1794
+ msg = void 0;
1795
+ }
1796
+ this.describe(key, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Path to JSON config file'));
1797
+ (Array.isArray(key) ? key : [
1798
+ key
1799
+ ]).forEach((k)=>{
1800
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").config[k] = parseFn || true;
1801
+ });
1802
+ return this;
1803
+ }
1804
+ completion(cmd, desc, fn) {
1805
+ argsert('[string] [string|boolean|function] [function]', [
1806
+ cmd,
1807
+ desc,
1808
+ fn
1809
+ ], arguments.length);
1810
+ if ('function' == typeof desc) {
1811
+ fn = desc;
1812
+ desc = void 0;
1813
+ }
1814
+ __classPrivateFieldSet(this, _YargsInstance_completionCommand, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || 'completion', "f");
1815
+ if (!desc && false !== desc) desc = "generate completion script";
1816
+ this.command(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), desc);
1817
+ if (fn) __classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn);
1818
+ return this;
1819
+ }
1820
+ command(cmd, description, builder, handler, middlewares, deprecated) {
1821
+ argsert('<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]', [
1822
+ cmd,
1823
+ description,
1824
+ builder,
1825
+ handler,
1826
+ middlewares,
1827
+ deprecated
1828
+ ], arguments.length);
1829
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description, builder, handler, middlewares, deprecated);
1830
+ return this;
1831
+ }
1832
+ commands(cmd, description, builder, handler, middlewares, deprecated) {
1833
+ return this.command(cmd, description, builder, handler, middlewares, deprecated);
1834
+ }
1835
+ commandDir(dir, opts) {
1836
+ argsert('<string> [object]', [
1837
+ dir,
1838
+ opts
1839
+ ], arguments.length);
1840
+ const req = __classPrivateFieldGet(this, _YargsInstance_parentRequire, "f") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").require;
1841
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").addDirectory(dir, req, __classPrivateFieldGet(this, _YargsInstance_shim, "f").getCallerFile(), opts);
1842
+ return this;
1843
+ }
1844
+ count(keys) {
1845
+ argsert('<array|string>', [
1846
+ keys
1847
+ ], arguments.length);
1848
+ this[kPopulateParserHintArray]('count', keys);
1849
+ this[kTrackManuallySetKeys](keys);
1850
+ return this;
1851
+ }
1852
+ default(key, value, defaultDescription) {
1853
+ argsert('<object|string|array> [*] [string]', [
1854
+ key,
1855
+ value,
1856
+ defaultDescription
1857
+ ], arguments.length);
1858
+ if (defaultDescription) {
1859
+ assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
1860
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = defaultDescription;
1861
+ }
1862
+ if ('function' == typeof value) {
1863
+ assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
1864
+ if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key]) __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = __classPrivateFieldGet(this, _YargsInstance_usage, "f").functionDescription(value);
1865
+ value = value.call();
1866
+ }
1867
+ this[kPopulateParserHintSingleValueDictionary](this.default.bind(this), 'default', key, value);
1868
+ return this;
1869
+ }
1870
+ defaults(key, value, defaultDescription) {
1871
+ return this.default(key, value, defaultDescription);
1872
+ }
1873
+ demandCommand(min = 1, max, minMsg, maxMsg) {
1874
+ argsert('[number] [number|string] [string|null|undefined] [string|null|undefined]', [
1875
+ min,
1876
+ max,
1877
+ minMsg,
1878
+ maxMsg
1879
+ ], arguments.length);
1880
+ if ('number' != typeof max) {
1881
+ minMsg = max;
1882
+ max = 1 / 0;
1883
+ }
1884
+ this.global('_', false);
1885
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands._ = {
1886
+ min,
1887
+ max,
1888
+ minMsg,
1889
+ maxMsg
1890
+ };
1891
+ return this;
1892
+ }
1893
+ demand(keys, max, msg) {
1894
+ if (Array.isArray(max)) {
1895
+ max.forEach((key)=>{
1896
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
1897
+ this.demandOption(key, msg);
1898
+ });
1899
+ max = 1 / 0;
1900
+ } else if ('number' != typeof max) {
1901
+ msg = max;
1902
+ max = 1 / 0;
1903
+ }
1904
+ if ('number' == typeof keys) {
1905
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
1906
+ this.demandCommand(keys, max, msg, msg);
1907
+ } else if (Array.isArray(keys)) keys.forEach((key)=>{
1908
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
1909
+ this.demandOption(key, msg);
1910
+ });
1911
+ else if ('string' == typeof msg) this.demandOption(keys, msg);
1912
+ else if (true === msg || void 0 === msg) this.demandOption(keys);
1913
+ return this;
1914
+ }
1915
+ demandOption(keys, msg) {
1916
+ argsert('<object|string|array> [string]', [
1917
+ keys,
1918
+ msg
1919
+ ], arguments.length);
1920
+ this[kPopulateParserHintSingleValueDictionary](this.demandOption.bind(this), 'demandedOptions', keys, msg);
1921
+ return this;
1922
+ }
1923
+ deprecateOption(option, message) {
1924
+ argsert('<string> [string|boolean]', [
1925
+ option,
1926
+ message
1927
+ ], arguments.length);
1928
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message;
1929
+ return this;
1930
+ }
1931
+ describe(keys, description) {
1932
+ argsert('<object|string|array> [string]', [
1933
+ keys,
1934
+ description
1935
+ ], arguments.length);
1936
+ this[kSetKey](keys, true);
1937
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description);
1938
+ return this;
1939
+ }
1940
+ detectLocale(detect) {
1941
+ argsert('<boolean>', [
1942
+ detect
1943
+ ], arguments.length);
1944
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, detect, "f");
1945
+ return this;
1946
+ }
1947
+ env(prefix) {
1948
+ argsert('[string|boolean]', [
1949
+ prefix
1950
+ ], arguments.length);
1951
+ if (false === prefix) delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
1952
+ else __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix || '';
1953
+ return this;
1954
+ }
1955
+ epilogue(msg) {
1956
+ argsert('<string>', [
1957
+ msg
1958
+ ], arguments.length);
1959
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").epilog(msg);
1960
+ return this;
1961
+ }
1962
+ epilog(msg) {
1963
+ return this.epilogue(msg);
1964
+ }
1965
+ example(cmd, description) {
1966
+ argsert('<string|array> [string]', [
1967
+ cmd,
1968
+ description
1969
+ ], arguments.length);
1970
+ if (Array.isArray(cmd)) cmd.forEach((exampleParams)=>this.example(...exampleParams));
1971
+ else __classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description);
1972
+ return this;
1973
+ }
1974
+ exit(code, err) {
1975
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
1976
+ __classPrivateFieldSet(this, _YargsInstance_exitError, err, "f");
1977
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.exit(code);
1978
+ }
1979
+ exitProcess(enabled = true) {
1980
+ argsert('[boolean]', [
1981
+ enabled
1982
+ ], arguments.length);
1983
+ __classPrivateFieldSet(this, _YargsInstance_exitProcess, enabled, "f");
1984
+ return this;
1985
+ }
1986
+ fail(f) {
1987
+ argsert('<function|boolean>', [
1988
+ f
1989
+ ], arguments.length);
1990
+ if ('boolean' == typeof f && false !== f) throw new yerror.s("Invalid first argument. Expected function or boolean 'false'");
1991
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").failFn(f);
1992
+ return this;
1993
+ }
1994
+ getAliases() {
1995
+ return this.parsed ? this.parsed.aliases : {};
1996
+ }
1997
+ async getCompletion(args, done) {
1998
+ argsert('<array> [function]', [
1999
+ args,
2000
+ done
2001
+ ], arguments.length);
2002
+ if (!done) return new Promise((resolve, reject)=>{
2003
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions)=>{
2004
+ if (err) reject(err);
2005
+ else resolve(completions);
2006
+ });
2007
+ });
2008
+ return __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, done);
2009
+ }
2010
+ getDemandedOptions() {
2011
+ argsert([], 0);
2012
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedOptions;
2013
+ }
2014
+ getDemandedCommands() {
2015
+ argsert([], 0);
2016
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands;
2017
+ }
2018
+ getDeprecatedOptions() {
2019
+ argsert([], 0);
2020
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions;
2021
+ }
2022
+ getDetectLocale() {
2023
+ return __classPrivateFieldGet(this, _YargsInstance_detectLocale, "f");
2024
+ }
2025
+ getExitProcess() {
2026
+ return __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f");
2027
+ }
2028
+ getGroups() {
2029
+ return Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_groups, "f"), __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"));
2030
+ }
2031
+ getHelp() {
2032
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
2033
+ if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
2034
+ if (!this.parsed) {
2035
+ const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true);
2036
+ if (isPromise(parse)) return parse.then(()=>__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
2037
+ }
2038
+ const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
2039
+ if (isPromise(builderResponse)) return builderResponse.then(()=>__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
2040
+ }
2041
+ return Promise.resolve(__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
2042
+ }
2043
+ getOptions() {
2044
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f");
2045
+ }
2046
+ getStrict() {
2047
+ return __classPrivateFieldGet(this, _YargsInstance_strict, "f");
2048
+ }
2049
+ getStrictCommands() {
2050
+ return __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f");
2051
+ }
2052
+ getStrictOptions() {
2053
+ return __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f");
2054
+ }
2055
+ global(globals, global) {
2056
+ argsert('<string|array> [boolean]', [
2057
+ globals,
2058
+ global
2059
+ ], arguments.length);
2060
+ globals = [].concat(globals);
2061
+ if (false !== global) __classPrivateFieldGet(this, _YargsInstance_options, "f").local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local.filter((l)=>-1 === globals.indexOf(l));
2062
+ else globals.forEach((g)=>{
2063
+ if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").local.includes(g)) __classPrivateFieldGet(this, _YargsInstance_options, "f").local.push(g);
2064
+ });
2065
+ return this;
2066
+ }
2067
+ group(opts, groupName) {
2068
+ argsert('<string|array> <string>', [
2069
+ opts,
2070
+ groupName
2071
+ ], arguments.length);
2072
+ const existing = __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName] || __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName];
2073
+ if (__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]) delete __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName];
2074
+ const seen = {};
2075
+ __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName] = (existing || []).concat(opts).filter((key)=>{
2076
+ if (seen[key]) return false;
2077
+ return seen[key] = true;
2078
+ });
2079
+ return this;
2080
+ }
2081
+ hide(key) {
2082
+ argsert('<string>', [
2083
+ key
2084
+ ], arguments.length);
2085
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").hiddenOptions.push(key);
2086
+ return this;
2087
+ }
2088
+ implies(key, value) {
2089
+ argsert('<string|object> [number|string|array]', [
2090
+ key,
2091
+ value
2092
+ ], arguments.length);
2093
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").implies(key, value);
2094
+ return this;
2095
+ }
2096
+ locale(locale) {
2097
+ argsert('[string]', [
2098
+ locale
2099
+ ], arguments.length);
2100
+ if (void 0 === locale) {
2101
+ this[kGuessLocale]();
2102
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
2103
+ }
2104
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
2105
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(locale);
2106
+ return this;
2107
+ }
2108
+ middleware(callback, applyBeforeValidation, global) {
2109
+ return __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addMiddleware(callback, !!applyBeforeValidation, global);
2110
+ }
2111
+ nargs(key, value) {
2112
+ argsert('<string|object|array> [number]', [
2113
+ key,
2114
+ value
2115
+ ], arguments.length);
2116
+ this[kPopulateParserHintSingleValueDictionary](this.nargs.bind(this), 'narg', key, value);
2117
+ return this;
2118
+ }
2119
+ normalize(keys) {
2120
+ argsert('<array|string>', [
2121
+ keys
2122
+ ], arguments.length);
2123
+ this[kPopulateParserHintArray]('normalize', keys);
2124
+ return this;
2125
+ }
2126
+ number(keys) {
2127
+ argsert('<array|string>', [
2128
+ keys
2129
+ ], arguments.length);
2130
+ this[kPopulateParserHintArray]('number', keys);
2131
+ this[kTrackManuallySetKeys](keys);
2132
+ return this;
2133
+ }
2134
+ option(key, opt) {
2135
+ argsert('<string|object> [object]', [
2136
+ key,
2137
+ opt
2138
+ ], arguments.length);
2139
+ if ('object' == typeof key) Object.keys(key).forEach((k)=>{
2140
+ this.options(k, key[k]);
2141
+ });
2142
+ else {
2143
+ if ('object' != typeof opt) opt = {};
2144
+ this[kTrackManuallySetKeys](key);
2145
+ if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && ('version' === key || (null == opt ? void 0 : opt.alias) === 'version')) this[kEmitWarning]('"version" is a reserved word.\nPlease do one of the following:\n- Disable version with `yargs.version(false)` if using "version" as an option\n- Use the built-in `yargs.version` method instead (if applicable)\n- Use a different option key\nhttps://yargs.js.org/docs/#api-reference-version', void 0, 'versionWarning');
2146
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[key] = true;
2147
+ if (opt.alias) this.alias(key, opt.alias);
2148
+ const deprecate = opt.deprecate || opt.deprecated;
2149
+ if (deprecate) this.deprecateOption(key, deprecate);
2150
+ const demand = opt.demand || opt.required || opt.require;
2151
+ if (demand) this.demand(key, demand);
2152
+ if (opt.demandOption) this.demandOption(key, 'string' == typeof opt.demandOption ? opt.demandOption : void 0);
2153
+ if (opt.conflicts) this.conflicts(key, opt.conflicts);
2154
+ if ('default' in opt) this.default(key, opt.default);
2155
+ if (void 0 !== opt.implies) this.implies(key, opt.implies);
2156
+ if (void 0 !== opt.nargs) this.nargs(key, opt.nargs);
2157
+ if (opt.config) this.config(key, opt.configParser);
2158
+ if (opt.normalize) this.normalize(key);
2159
+ if (opt.choices) this.choices(key, opt.choices);
2160
+ if (opt.coerce) this.coerce(key, opt.coerce);
2161
+ if (opt.group) this.group(key, opt.group);
2162
+ if (opt.boolean || 'boolean' === opt.type) {
2163
+ this.boolean(key);
2164
+ if (opt.alias) this.boolean(opt.alias);
2165
+ }
2166
+ if (opt.array || 'array' === opt.type) {
2167
+ this.array(key);
2168
+ if (opt.alias) this.array(opt.alias);
2169
+ }
2170
+ if (opt.number || 'number' === opt.type) {
2171
+ this.number(key);
2172
+ if (opt.alias) this.number(opt.alias);
2173
+ }
2174
+ if (opt.string || 'string' === opt.type) {
2175
+ this.string(key);
2176
+ if (opt.alias) this.string(opt.alias);
2177
+ }
2178
+ if (opt.count || 'count' === opt.type) this.count(key);
2179
+ if ('boolean' == typeof opt.global) this.global(key, opt.global);
2180
+ if (opt.defaultDescription) __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = opt.defaultDescription;
2181
+ if (opt.skipValidation) this.skipValidation(key);
2182
+ const desc = opt.describe || opt.description || opt.desc;
2183
+ const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions();
2184
+ if (!Object.prototype.hasOwnProperty.call(descriptions, key) || 'string' == typeof desc) this.describe(key, desc);
2185
+ if (opt.hidden) this.hide(key);
2186
+ if (opt.requiresArg) this.requiresArg(key);
2187
+ }
2188
+ return this;
2189
+ }
2190
+ options(key, opt) {
2191
+ return this.option(key, opt);
2192
+ }
2193
+ parse(args, shortCircuit, _parseFn) {
2194
+ argsert('[string|array] [function|boolean|object] [function]', [
2195
+ args,
2196
+ shortCircuit,
2197
+ _parseFn
2198
+ ], arguments.length);
2199
+ this[kFreeze]();
2200
+ if (void 0 === args) args = __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
2201
+ if ('object' == typeof shortCircuit) {
2202
+ __classPrivateFieldSet(this, _YargsInstance_parseContext, shortCircuit, "f");
2203
+ shortCircuit = _parseFn;
2204
+ }
2205
+ if ('function' == typeof shortCircuit) {
2206
+ __classPrivateFieldSet(this, _YargsInstance_parseFn, shortCircuit, "f");
2207
+ shortCircuit = false;
2208
+ }
2209
+ if (!shortCircuit) __classPrivateFieldSet(this, _YargsInstance_processArgs, args, "f");
2210
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldSet(this, _YargsInstance_exitProcess, false, "f");
2211
+ const parsed = this[kRunYargsParserAndExecuteCommands](args, !!shortCircuit);
2212
+ const tmpParsed = this.parsed;
2213
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").setParsed(this.parsed);
2214
+ if (isPromise(parsed)) return parsed.then((argv)=>{
2215
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
2216
+ return argv;
2217
+ }).catch((err)=>{
2218
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldGet(this, _YargsInstance_parseFn, "f")(err, this.parsed.argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
2219
+ throw err;
2220
+ }).finally(()=>{
2221
+ this[kUnfreeze]();
2222
+ this.parsed = tmpParsed;
2223
+ });
2224
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), parsed, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
2225
+ this[kUnfreeze]();
2226
+ this.parsed = tmpParsed;
2227
+ return parsed;
2228
+ }
2229
+ parseAsync(args, shortCircuit, _parseFn) {
2230
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
2231
+ return isPromise(maybePromise) ? maybePromise : Promise.resolve(maybePromise);
2232
+ }
2233
+ parseSync(args, shortCircuit, _parseFn) {
2234
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
2235
+ if (isPromise(maybePromise)) throw new yerror.s('.parseSync() must not be used with asynchronous builders, handlers, or middleware');
2236
+ return maybePromise;
2237
+ }
2238
+ parserConfiguration(config) {
2239
+ argsert('<object>', [
2240
+ config
2241
+ ], arguments.length);
2242
+ __classPrivateFieldSet(this, _YargsInstance_parserConfig, config, "f");
2243
+ return this;
2244
+ }
2245
+ pkgConf(key, rootPath) {
2246
+ argsert('<string> [string]', [
2247
+ key,
2248
+ rootPath
2249
+ ], arguments.length);
2250
+ let conf = null;
2251
+ const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"));
2252
+ if (obj[key] && 'object' == typeof obj[key]) {
2253
+ conf = (0, apply_extends.J)(obj[key], rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()['deep-merge-config'] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
2254
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(conf);
2255
+ }
2256
+ return this;
2257
+ }
2258
+ positional(key, opts) {
2259
+ argsert('<string> <object>', [
2260
+ key,
2261
+ opts
2262
+ ], arguments.length);
2263
+ const supportedOpts = [
2264
+ 'default',
2265
+ "defaultDescription",
2266
+ 'implies',
2267
+ 'normalize',
2268
+ 'choices',
2269
+ 'conflicts',
2270
+ 'coerce',
2271
+ 'type',
2272
+ 'describe',
2273
+ 'desc',
2274
+ "description",
2275
+ 'alias'
2276
+ ];
2277
+ opts = objFilter(opts, (k, v)=>{
2278
+ if ('type' === k && ![
2279
+ 'string',
2280
+ 'number',
2281
+ 'boolean'
2282
+ ].includes(v)) return false;
2283
+ return supportedOpts.includes(k);
2284
+ });
2285
+ const fullCommand = __classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands[__classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands.length - 1];
2286
+ const parseOptions = fullCommand ? __classPrivateFieldGet(this, _YargsInstance_command, "f").cmdToParseOptions(fullCommand) : {
2287
+ array: [],
2288
+ alias: {},
2289
+ default: {},
2290
+ demand: {}
2291
+ };
2292
+ objectKeys(parseOptions).forEach((pk)=>{
2293
+ const parseOption = parseOptions[pk];
2294
+ if (Array.isArray(parseOption)) {
2295
+ if (-1 !== parseOption.indexOf(key)) opts[pk] = true;
2296
+ } else if (parseOption[key] && !(pk in opts)) opts[pk] = parseOption[key];
2297
+ });
2298
+ this.group(key, __classPrivateFieldGet(this, _YargsInstance_usage, "f").getPositionalGroupName());
2299
+ return this.option(key, opts);
2300
+ }
2301
+ recommendCommands(recommend = true) {
2302
+ argsert('[boolean]', [
2303
+ recommend
2304
+ ], arguments.length);
2305
+ __classPrivateFieldSet(this, _YargsInstance_recommendCommands, recommend, "f");
2306
+ return this;
2307
+ }
2308
+ required(keys, max, msg) {
2309
+ return this.demand(keys, max, msg);
2310
+ }
2311
+ require(keys, max, msg) {
2312
+ return this.demand(keys, max, msg);
2313
+ }
2314
+ requiresArg(keys) {
2315
+ argsert('<array|string|object> [number]', [
2316
+ keys
2317
+ ], arguments.length);
2318
+ 'string' == typeof keys && __classPrivateFieldGet(this, _YargsInstance_options, "f").narg[keys] || this[kPopulateParserHintSingleValueDictionary](this.requiresArg.bind(this), 'narg', keys, NaN);
2319
+ return this;
2320
+ }
2321
+ showCompletionScript($0, cmd) {
2322
+ argsert('[string] [string]', [
2323
+ $0,
2324
+ cmd
2325
+ ], arguments.length);
2326
+ $0 = $0 || this.$0;
2327
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(__classPrivateFieldGet(this, _YargsInstance_completion, "f").generateCompletionScript($0, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || 'completion'));
2328
+ return this;
2329
+ }
2330
+ showHelp(level) {
2331
+ argsert('[string|function]', [
2332
+ level
2333
+ ], arguments.length);
2334
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
2335
+ if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
2336
+ if (!this.parsed) {
2337
+ const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true);
2338
+ if (isPromise(parse)) {
2339
+ parse.then(()=>{
2340
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
2341
+ });
2342
+ return this;
2343
+ }
2344
+ }
2345
+ const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
2346
+ if (isPromise(builderResponse)) {
2347
+ builderResponse.then(()=>{
2348
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
2349
+ });
2350
+ return this;
2351
+ }
2352
+ }
2353
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
2354
+ return this;
2355
+ }
2356
+ scriptName(scriptName) {
2357
+ this.customScriptName = true;
2358
+ this.$0 = scriptName;
2359
+ return this;
2360
+ }
2361
+ showHelpOnFail(enabled, message) {
2362
+ argsert('[boolean|string] [string]', [
2363
+ enabled,
2364
+ message
2365
+ ], arguments.length);
2366
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelpOnFail(enabled, message);
2367
+ return this;
2368
+ }
2369
+ showVersion(level) {
2370
+ argsert('[string|function]', [
2371
+ level
2372
+ ], arguments.length);
2373
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion(level);
2374
+ return this;
2375
+ }
2376
+ skipValidation(keys) {
2377
+ argsert('<array|string>', [
2378
+ keys
2379
+ ], arguments.length);
2380
+ this[kPopulateParserHintArray]('skipValidation', keys);
2381
+ return this;
2382
+ }
2383
+ strict(enabled) {
2384
+ argsert('[boolean]', [
2385
+ enabled
2386
+ ], arguments.length);
2387
+ __classPrivateFieldSet(this, _YargsInstance_strict, false !== enabled, "f");
2388
+ return this;
2389
+ }
2390
+ strictCommands(enabled) {
2391
+ argsert('[boolean]', [
2392
+ enabled
2393
+ ], arguments.length);
2394
+ __classPrivateFieldSet(this, _YargsInstance_strictCommands, false !== enabled, "f");
2395
+ return this;
2396
+ }
2397
+ strictOptions(enabled) {
2398
+ argsert('[boolean]', [
2399
+ enabled
2400
+ ], arguments.length);
2401
+ __classPrivateFieldSet(this, _YargsInstance_strictOptions, false !== enabled, "f");
2402
+ return this;
2403
+ }
2404
+ string(keys) {
2405
+ argsert('<array|string>', [
2406
+ keys
2407
+ ], arguments.length);
2408
+ this[kPopulateParserHintArray]('string', keys);
2409
+ this[kTrackManuallySetKeys](keys);
2410
+ return this;
2411
+ }
2412
+ terminalWidth() {
2413
+ argsert([], 0);
2414
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.stdColumns;
2415
+ }
2416
+ updateLocale(obj) {
2417
+ return this.updateStrings(obj);
2418
+ }
2419
+ updateStrings(obj) {
2420
+ argsert('<object>', [
2421
+ obj
2422
+ ], arguments.length);
2423
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
2424
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj);
2425
+ return this;
2426
+ }
2427
+ usage(msg, description, builder, handler) {
2428
+ argsert('<string|null|undefined> [string|boolean] [function|object] [function]', [
2429
+ msg,
2430
+ description,
2431
+ builder,
2432
+ handler
2433
+ ], arguments.length);
2434
+ if (void 0 !== description) {
2435
+ assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
2436
+ if ((msg || '').match(/^\$0( |$)/)) return this.command(msg, description, builder, handler);
2437
+ throw new yerror.s(".usage() description must start with $0 if being used as alias for .command()");
2438
+ }
2439
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").usage(msg);
2440
+ return this;
2441
+ }
2442
+ usageConfiguration(config) {
2443
+ argsert('<object>', [
2444
+ config
2445
+ ], arguments.length);
2446
+ __classPrivateFieldSet(this, _YargsInstance_usageConfig, config, "f");
2447
+ return this;
2448
+ }
2449
+ version(opt, msg, ver) {
2450
+ const defaultVersionOpt = 'version';
2451
+ argsert('[boolean|string] [string] [string]', [
2452
+ opt,
2453
+ msg,
2454
+ ver
2455
+ ], arguments.length);
2456
+ if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")) {
2457
+ this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
2458
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(void 0);
2459
+ __classPrivateFieldSet(this, _YargsInstance_versionOpt, null, "f");
2460
+ }
2461
+ if (0 === arguments.length) {
2462
+ ver = this[kGuessVersion]();
2463
+ opt = defaultVersionOpt;
2464
+ } else if (1 === arguments.length) {
2465
+ if (false === opt) return this;
2466
+ ver = opt;
2467
+ opt = defaultVersionOpt;
2468
+ } else if (2 === arguments.length) {
2469
+ ver = msg;
2470
+ msg = void 0;
2471
+ }
2472
+ __classPrivateFieldSet(this, _YargsInstance_versionOpt, 'string' == typeof opt ? opt : defaultVersionOpt, "f");
2473
+ msg = msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Show version number');
2474
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(ver || void 0);
2475
+ this.boolean(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
2476
+ this.describe(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"), msg);
2477
+ return this;
2478
+ }
2479
+ wrap(cols) {
2480
+ argsert('<number|null|undefined>', [
2481
+ cols
2482
+ ], arguments.length);
2483
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
2484
+ return this;
2485
+ }
2486
+ [(_YargsInstance_command = new WeakMap(), _YargsInstance_cwd = new WeakMap(), _YargsInstance_context = new WeakMap(), _YargsInstance_completion = new WeakMap(), _YargsInstance_completionCommand = new WeakMap(), _YargsInstance_defaultShowHiddenOpt = new WeakMap(), _YargsInstance_exitError = new WeakMap(), _YargsInstance_detectLocale = new WeakMap(), _YargsInstance_emittedWarnings = new WeakMap(), _YargsInstance_exitProcess = new WeakMap(), _YargsInstance_frozens = new WeakMap(), _YargsInstance_globalMiddleware = new WeakMap(), _YargsInstance_groups = new WeakMap(), _YargsInstance_hasOutput = new WeakMap(), _YargsInstance_helpOpt = new WeakMap(), _YargsInstance_isGlobalContext = new WeakMap(), _YargsInstance_logger = new WeakMap(), _YargsInstance_output = new WeakMap(), _YargsInstance_options = new WeakMap(), _YargsInstance_parentRequire = new WeakMap(), _YargsInstance_parserConfig = new WeakMap(), _YargsInstance_parseFn = new WeakMap(), _YargsInstance_parseContext = new WeakMap(), _YargsInstance_pkgs = new WeakMap(), _YargsInstance_preservedGroups = new WeakMap(), _YargsInstance_processArgs = new WeakMap(), _YargsInstance_recommendCommands = new WeakMap(), _YargsInstance_shim = new WeakMap(), _YargsInstance_strict = new WeakMap(), _YargsInstance_strictCommands = new WeakMap(), _YargsInstance_strictOptions = new WeakMap(), _YargsInstance_usage = new WeakMap(), _YargsInstance_usageConfig = new WeakMap(), _YargsInstance_versionOpt = new WeakMap(), _YargsInstance_validation = new WeakMap(), kCopyDoubleDash)](argv) {
2487
+ if (!argv._ || !argv['--']) return argv;
2488
+ argv._.push.apply(argv._, argv['--']);
2489
+ try {
2490
+ delete argv['--'];
2491
+ } catch (_err) {}
2492
+ return argv;
2493
+ }
2494
+ [kCreateLogger]() {
2495
+ return {
2496
+ log: (...args)=>{
2497
+ if (!this[kHasParseCallback]()) console.log(...args);
2498
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
2499
+ if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length) __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + '\n', "f");
2500
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(' '), "f");
2501
+ },
2502
+ error: (...args)=>{
2503
+ if (!this[kHasParseCallback]()) console.error(...args);
2504
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
2505
+ if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length) __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + '\n', "f");
2506
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(' '), "f");
2507
+ }
2508
+ };
2509
+ }
2510
+ [kDeleteFromParserHintObject](optionKey) {
2511
+ objectKeys(__classPrivateFieldGet(this, _YargsInstance_options, "f")).forEach((hintKey)=>{
2512
+ if (((key)=>'configObjects' === key)(hintKey)) return;
2513
+ const hint = __classPrivateFieldGet(this, _YargsInstance_options, "f")[hintKey];
2514
+ if (Array.isArray(hint)) {
2515
+ if (hint.includes(optionKey)) hint.splice(hint.indexOf(optionKey), 1);
2516
+ } else if ('object' == typeof hint) delete hint[optionKey];
2517
+ });
2518
+ delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
2519
+ }
2520
+ [kEmitWarning](warning, type, deduplicationId) {
2521
+ if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) {
2522
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type);
2523
+ __classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true;
2524
+ }
2525
+ }
2526
+ [kFreeze]() {
2527
+ __classPrivateFieldGet(this, _YargsInstance_frozens, "f").push({
2528
+ options: __classPrivateFieldGet(this, _YargsInstance_options, "f"),
2529
+ configObjects: __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects.slice(0),
2530
+ exitProcess: __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"),
2531
+ groups: __classPrivateFieldGet(this, _YargsInstance_groups, "f"),
2532
+ strict: __classPrivateFieldGet(this, _YargsInstance_strict, "f"),
2533
+ strictCommands: __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"),
2534
+ strictOptions: __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"),
2535
+ completionCommand: __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"),
2536
+ output: __classPrivateFieldGet(this, _YargsInstance_output, "f"),
2537
+ exitError: __classPrivateFieldGet(this, _YargsInstance_exitError, "f"),
2538
+ hasOutput: __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"),
2539
+ parsed: this.parsed,
2540
+ parseFn: __classPrivateFieldGet(this, _YargsInstance_parseFn, "f"),
2541
+ parseContext: __classPrivateFieldGet(this, _YargsInstance_parseContext, "f")
2542
+ });
2543
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").freeze();
2544
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").freeze();
2545
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").freeze();
2546
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").freeze();
2547
+ }
2548
+ [kGetDollarZero]() {
2549
+ let $0 = '';
2550
+ let default$0;
2551
+ default$0 = /\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv()[0]) ? __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(1, 2) : __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(0, 1);
2552
+ $0 = default$0.map((x)=>{
2553
+ const b = this[kRebase](__classPrivateFieldGet(this, _YargsInstance_cwd, "f"), x);
2554
+ return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x;
2555
+ }).join(' ').trim();
2556
+ 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())}/`, '');
2557
+ return $0;
2558
+ }
2559
+ [kGetParserConfiguration]() {
2560
+ return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
2561
+ }
2562
+ [kGetUsageConfiguration]() {
2563
+ return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f");
2564
+ }
2565
+ [kGuessLocale]() {
2566
+ if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f")) return;
2567
+ 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';
2568
+ this.locale(locale.replace(/[.:].*/, ''));
2569
+ }
2570
+ [kGuessVersion]() {
2571
+ const obj = this[kPkgUp]();
2572
+ return obj.version || 'unknown';
2573
+ }
2574
+ [kParsePositionalNumbers](argv) {
2575
+ const args = argv['--'] ? argv['--'] : argv._;
2576
+ for(let i = 0, arg; void 0 !== (arg = args[i]); i++)if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.looksLikeNumber(arg) && Number.isSafeInteger(Math.floor(parseFloat(`${arg}`)))) args[i] = Number(arg);
2577
+ return argv;
2578
+ }
2579
+ [kPkgUp](rootPath) {
2580
+ const npath = rootPath || '*';
2581
+ if (__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath]) return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
2582
+ let obj = {};
2583
+ try {
2584
+ let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename;
2585
+ if (!rootPath && __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir);
2586
+ const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names)=>{
2587
+ if (names.includes('package.json')) return 'package.json';
2588
+ });
2589
+ assertNotStrictEqual(pkgJsonPath, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
2590
+ obj = JSON.parse(__classPrivateFieldGet(this, _YargsInstance_shim, "f").readFileSync(pkgJsonPath, 'utf8'));
2591
+ } catch (_noop) {}
2592
+ __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
2593
+ return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
2594
+ }
2595
+ [kPopulateParserHintArray](type, keys) {
2596
+ keys = [].concat(keys);
2597
+ keys.forEach((key)=>{
2598
+ key = this[kSanitizeKey](key);
2599
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type].push(key);
2600
+ });
2601
+ }
2602
+ [kPopulateParserHintSingleValueDictionary](builder, type, key, value) {
2603
+ this[kPopulateParserHintDictionary](builder, type, key, value, (type, key, value)=>{
2604
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] = value;
2605
+ });
2606
+ }
2607
+ [kPopulateParserHintArrayDictionary](builder, type, key, value) {
2608
+ this[kPopulateParserHintDictionary](builder, type, key, value, (type, key, value)=>{
2609
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] || []).concat(value);
2610
+ });
2611
+ }
2612
+ [kPopulateParserHintDictionary](builder, type, key, value, singleKeyHandler) {
2613
+ if (Array.isArray(key)) key.forEach((k)=>{
2614
+ builder(k, value);
2615
+ });
2616
+ else if (((key)=>'object' == typeof key)(key)) for (const k of objectKeys(key))builder(k, key[k]);
2617
+ else singleKeyHandler(type, this[kSanitizeKey](key), value);
2618
+ }
2619
+ [kSanitizeKey](key) {
2620
+ if ('__proto__' === key) return '___proto___';
2621
+ return key;
2622
+ }
2623
+ [kSetKey](key, set) {
2624
+ this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), 'key', key, set);
2625
+ return this;
2626
+ }
2627
+ [kUnfreeze]() {
2628
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
2629
+ const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
2630
+ assertNotStrictEqual(frozen, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
2631
+ let configObjects;
2632
+ _a = this, _b = this, _c = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, { options: ({
2633
+ set value (_o){
2634
+ __classPrivateFieldSet(_a, _YargsInstance_options, _o, "f");
2635
+ }
2636
+ }).value, configObjects, exitProcess: ({
2637
+ set value (_o){
2638
+ __classPrivateFieldSet(_b, _YargsInstance_exitProcess, _o, "f");
2639
+ }
2640
+ }).value, groups: ({
2641
+ set value (_o){
2642
+ __classPrivateFieldSet(_c, _YargsInstance_groups, _o, "f");
2643
+ }
2644
+ }).value, output: ({
2645
+ set value (_o){
2646
+ __classPrivateFieldSet(_d, _YargsInstance_output, _o, "f");
2647
+ }
2648
+ }).value, exitError: ({
2649
+ set value (_o){
2650
+ __classPrivateFieldSet(_e, _YargsInstance_exitError, _o, "f");
2651
+ }
2652
+ }).value, hasOutput: ({
2653
+ set value (_o){
2654
+ __classPrivateFieldSet(_f, _YargsInstance_hasOutput, _o, "f");
2655
+ }
2656
+ }).value, parsed: this.parsed, strict: ({
2657
+ set value (_o){
2658
+ __classPrivateFieldSet(_g, _YargsInstance_strict, _o, "f");
2659
+ }
2660
+ }).value, strictCommands: ({
2661
+ set value (_o){
2662
+ __classPrivateFieldSet(_h, _YargsInstance_strictCommands, _o, "f");
2663
+ }
2664
+ }).value, strictOptions: ({
2665
+ set value (_o){
2666
+ __classPrivateFieldSet(_j, _YargsInstance_strictOptions, _o, "f");
2667
+ }
2668
+ }).value, completionCommand: ({
2669
+ set value (_o){
2670
+ __classPrivateFieldSet(_k, _YargsInstance_completionCommand, _o, "f");
2671
+ }
2672
+ }).value, parseFn: ({
2673
+ set value (_o){
2674
+ __classPrivateFieldSet(_l, _YargsInstance_parseFn, _o, "f");
2675
+ }
2676
+ }).value, parseContext: ({
2677
+ set value (_o){
2678
+ __classPrivateFieldSet(_m, _YargsInstance_parseContext, _o, "f");
2679
+ }
2680
+ }).value } = frozen;
2681
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = configObjects;
2682
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").unfreeze();
2683
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").unfreeze();
2684
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").unfreeze();
2685
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").unfreeze();
2686
+ }
2687
+ [kValidateAsync](validation, argv) {
2688
+ return maybeAsyncResult(argv, (result)=>{
2689
+ validation(result);
2690
+ return result;
2691
+ });
2692
+ }
2693
+ getInternalMethods() {
2694
+ return {
2695
+ getCommandInstance: this[kGetCommandInstance].bind(this),
2696
+ getContext: this[kGetContext].bind(this),
2697
+ getHasOutput: this[kGetHasOutput].bind(this),
2698
+ getLoggerInstance: this[kGetLoggerInstance].bind(this),
2699
+ getParseContext: this[kGetParseContext].bind(this),
2700
+ getParserConfiguration: this[kGetParserConfiguration].bind(this),
2701
+ getUsageConfiguration: this[kGetUsageConfiguration].bind(this),
2702
+ getUsageInstance: this[kGetUsageInstance].bind(this),
2703
+ getValidationInstance: this[kGetValidationInstance].bind(this),
2704
+ hasParseCallback: this[kHasParseCallback].bind(this),
2705
+ isGlobalContext: this[kIsGlobalContext].bind(this),
2706
+ postProcess: this[kPostProcess].bind(this),
2707
+ reset: this[kReset].bind(this),
2708
+ runValidation: this[kRunValidation].bind(this),
2709
+ runYargsParserAndExecuteCommands: this[kRunYargsParserAndExecuteCommands].bind(this),
2710
+ setHasOutput: this[kSetHasOutput].bind(this)
2711
+ };
2712
+ }
2713
+ [kGetCommandInstance]() {
2714
+ return __classPrivateFieldGet(this, _YargsInstance_command, "f");
2715
+ }
2716
+ [kGetContext]() {
2717
+ return __classPrivateFieldGet(this, _YargsInstance_context, "f");
2718
+ }
2719
+ [kGetHasOutput]() {
2720
+ return __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f");
2721
+ }
2722
+ [kGetLoggerInstance]() {
2723
+ return __classPrivateFieldGet(this, _YargsInstance_logger, "f");
2724
+ }
2725
+ [kGetParseContext]() {
2726
+ return __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") || {};
2727
+ }
2728
+ [kGetUsageInstance]() {
2729
+ return __classPrivateFieldGet(this, _YargsInstance_usage, "f");
2730
+ }
2731
+ [kGetValidationInstance]() {
2732
+ return __classPrivateFieldGet(this, _YargsInstance_validation, "f");
2733
+ }
2734
+ [kHasParseCallback]() {
2735
+ return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f");
2736
+ }
2737
+ [kIsGlobalContext]() {
2738
+ return __classPrivateFieldGet(this, _YargsInstance_isGlobalContext, "f");
2739
+ }
2740
+ [kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) {
2741
+ if (calledFromCommand) return argv;
2742
+ if (isPromise(argv)) return argv;
2743
+ if (!populateDoubleDash) argv = this[kCopyDoubleDash](argv);
2744
+ const parsePositionalNumbers = this[kGetParserConfiguration]()['parse-positional-numbers'] || void 0 === this[kGetParserConfiguration]()['parse-positional-numbers'];
2745
+ if (parsePositionalNumbers) argv = this[kParsePositionalNumbers](argv);
2746
+ if (runGlobalMiddleware) argv = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
2747
+ return argv;
2748
+ }
2749
+ [kReset](aliases = {}) {
2750
+ __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f") || {}, "f");
2751
+ const tmpOptions = {};
2752
+ tmpOptions.local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local || [];
2753
+ tmpOptions.configObjects = __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || [];
2754
+ const localLookup = {};
2755
+ tmpOptions.local.forEach((l)=>{
2756
+ localLookup[l] = true;
2757
+ (aliases[l] || []).forEach((a)=>{
2758
+ localLookup[a] = true;
2759
+ });
2760
+ });
2761
+ Object.assign(__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"), Object.keys(__classPrivateFieldGet(this, _YargsInstance_groups, "f")).reduce((acc, groupName)=>{
2762
+ const keys = __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName].filter((key)=>!(key in localLookup));
2763
+ if (keys.length > 0) acc[groupName] = keys;
2764
+ return acc;
2765
+ }, {}));
2766
+ __classPrivateFieldSet(this, _YargsInstance_groups, {}, "f");
2767
+ const arrayOptions = [
2768
+ 'array',
2769
+ 'boolean',
2770
+ 'string',
2771
+ 'skipValidation',
2772
+ 'count',
2773
+ 'normalize',
2774
+ 'number',
2775
+ 'hiddenOptions'
2776
+ ];
2777
+ const objectOptions = [
2778
+ 'narg',
2779
+ 'key',
2780
+ 'alias',
2781
+ 'default',
2782
+ "defaultDescription",
2783
+ 'config',
2784
+ 'choices',
2785
+ 'demandedOptions',
2786
+ 'demandedCommands',
2787
+ 'deprecatedOptions'
2788
+ ];
2789
+ arrayOptions.forEach((k)=>{
2790
+ tmpOptions[k] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[k] || []).filter((k)=>!localLookup[k]);
2791
+ });
2792
+ objectOptions.forEach((k)=>{
2793
+ tmpOptions[k] = objFilter(__classPrivateFieldGet(this, _YargsInstance_options, "f")[k], (k)=>!localLookup[k]);
2794
+ });
2795
+ tmpOptions.envPrefix = __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
2796
+ __classPrivateFieldSet(this, _YargsInstance_options, tmpOptions, "f");
2797
+ __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f") ? __classPrivateFieldGet(this, _YargsInstance_usage, "f").reset(localLookup) : usage_usage(this, __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
2798
+ __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f") ? __classPrivateFieldGet(this, _YargsInstance_validation, "f").reset(localLookup) : validation_validation(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
2799
+ __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f") ? __classPrivateFieldGet(this, _YargsInstance_command, "f").reset() : command_command(__classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_validation, "f"), __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
2800
+ if (!__classPrivateFieldGet(this, _YargsInstance_completion, "f")) __classPrivateFieldSet(this, _YargsInstance_completion, completion_completion(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_command, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
2801
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").reset();
2802
+ __classPrivateFieldSet(this, _YargsInstance_completionCommand, null, "f");
2803
+ __classPrivateFieldSet(this, _YargsInstance_output, '', "f");
2804
+ __classPrivateFieldSet(this, _YargsInstance_exitError, null, "f");
2805
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, false, "f");
2806
+ this.parsed = false;
2807
+ return this;
2808
+ }
2809
+ [kRebase](base, dir) {
2810
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.relative(base, dir);
2811
+ }
2812
+ [kRunYargsParserAndExecuteCommands](args, shortCircuit, calledFromCommand, commandIndex = 0, helpOnly = false) {
2813
+ let skipValidation = !!calledFromCommand || helpOnly;
2814
+ args = args || __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
2815
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__;
2816
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration]();
2817
+ const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration['populate--'];
2818
+ const config = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, {
2819
+ 'populate--': true
2820
+ });
2821
+ const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), {
2822
+ configuration: {
2823
+ 'parse-positional-numbers': false,
2824
+ ...config
2825
+ }
2826
+ }));
2827
+ const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"));
2828
+ let argvPromise;
2829
+ const aliases = parsed.aliases;
2830
+ let helpOptSet = false;
2831
+ let versionOptSet = false;
2832
+ Object.keys(argv).forEach((key)=>{
2833
+ if (key === __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f") && argv[key]) helpOptSet = true;
2834
+ else if (key === __classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && argv[key]) versionOptSet = true;
2835
+ });
2836
+ argv.$0 = this.$0;
2837
+ this.parsed = parsed;
2838
+ if (0 === commandIndex) __classPrivateFieldGet(this, _YargsInstance_usage, "f").clearCachedHelpMessage();
2839
+ try {
2840
+ this[kGuessLocale]();
2841
+ if (shortCircuit) return this[kPostProcess](argv, populateDoubleDash, !!calledFromCommand, false);
2842
+ if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
2843
+ const helpCmds = [
2844
+ __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")
2845
+ ].concat(aliases[__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")] || []).filter((k)=>k.length > 1);
2846
+ if (helpCmds.includes('' + argv._[argv._.length - 1])) {
2847
+ argv._.pop();
2848
+ helpOptSet = true;
2849
+ }
2850
+ }
2851
+ __classPrivateFieldSet(this, _YargsInstance_isGlobalContext, false, "f");
2852
+ const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands();
2853
+ const requestCompletions = __classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey in argv;
2854
+ const skipRecommendation = helpOptSet || requestCompletions || helpOnly;
2855
+ if (argv._.length) {
2856
+ if (handlerKeys.length) {
2857
+ let firstUnknownCommand;
2858
+ for(let i = commandIndex || 0, cmd; void 0 !== argv._[i]; i++){
2859
+ cmd = String(argv._[i]);
2860
+ if (handlerKeys.includes(cmd) && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
2861
+ const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(cmd, this, parsed, i + 1, helpOnly, helpOptSet || versionOptSet || helpOnly);
2862
+ return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
2863
+ }
2864
+ if (!firstUnknownCommand && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
2865
+ firstUnknownCommand = cmd;
2866
+ break;
2867
+ }
2868
+ }
2869
+ if (!__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && __classPrivateFieldGet(this, _YargsInstance_recommendCommands, "f") && firstUnknownCommand && !skipRecommendation) __classPrivateFieldGet(this, _YargsInstance_validation, "f").recommendCommands(firstUnknownCommand, handlerKeys);
2870
+ }
2871
+ if (__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") && argv._.includes(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) && !requestCompletions) {
2872
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
2873
+ this.showCompletionScript();
2874
+ this.exit(0);
2875
+ }
2876
+ }
2877
+ if (__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && !skipRecommendation) {
2878
+ const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(null, this, parsed, 0, helpOnly, helpOptSet || versionOptSet || helpOnly);
2879
+ return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
2880
+ }
2881
+ if (requestCompletions) {
2882
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
2883
+ args = [].concat(args);
2884
+ const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey}`) + 1);
2885
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(completionArgs, (err, completions)=>{
2886
+ if (err) throw new yerror.s(err.message);
2887
+ (completions || []).forEach((completion)=>{
2888
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(completion);
2889
+ });
2890
+ this.exit(0);
2891
+ });
2892
+ return this[kPostProcess](argv, !populateDoubleDash, !!calledFromCommand, false);
2893
+ }
2894
+ if (!__classPrivateFieldGet(this, _YargsInstance_hasOutput, "f")) {
2895
+ if (helpOptSet) {
2896
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
2897
+ skipValidation = true;
2898
+ this.showHelp('log');
2899
+ this.exit(0);
2900
+ } else if (versionOptSet) {
2901
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f")) setBlocking(true);
2902
+ skipValidation = true;
2903
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion('log');
2904
+ this.exit(0);
2905
+ }
2906
+ }
2907
+ 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 && true === argv[key]);
2908
+ if (!skipValidation) {
2909
+ if (parsed.error) throw new yerror.s(parsed.error.message);
2910
+ if (!requestCompletions) {
2911
+ const validation = this[kRunValidation](aliases, {}, parsed.error);
2912
+ if (!calledFromCommand) argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), true);
2913
+ argvPromise = this[kValidateAsync](validation, null != argvPromise ? argvPromise : argv);
2914
+ if (isPromise(argvPromise) && !calledFromCommand) argvPromise = argvPromise.then(()=>applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false));
2915
+ }
2916
+ }
2917
+ } catch (err) {
2918
+ if (err instanceof yerror.s) __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message, err);
2919
+ else throw err;
2920
+ }
2921
+ return this[kPostProcess](null != argvPromise ? argvPromise : argv, populateDoubleDash, !!calledFromCommand, true);
2922
+ }
2923
+ [kRunValidation](aliases, positionalMap, parseErrors, isDefaultCommand) {
2924
+ const demandedOptions = {
2925
+ ...this.getDemandedOptions()
2926
+ };
2927
+ return (argv)=>{
2928
+ if (parseErrors) throw new yerror.s(parseErrors.message);
2929
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").nonOptionCount(argv);
2930
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").requiredArguments(argv, demandedOptions);
2931
+ let failedStrictCommands = false;
2932
+ if (__classPrivateFieldGet(this, _YargsInstance_strictCommands, "f")) failedStrictCommands = __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownCommands(argv);
2933
+ if (__classPrivateFieldGet(this, _YargsInstance_strict, "f") && !failedStrictCommands) __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, positionalMap, !!isDefaultCommand);
2934
+ else if (__classPrivateFieldGet(this, _YargsInstance_strictOptions, "f")) __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, {}, false, false);
2935
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").limitedChoices(argv);
2936
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").implications(argv);
2937
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicting(argv);
2938
+ };
2939
+ }
2940
+ [kSetHasOutput]() {
2941
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
2942
+ }
2943
+ [kTrackManuallySetKeys](keys) {
2944
+ if ('string' == typeof keys) __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
2945
+ else for (const k of keys)__classPrivateFieldGet(this, _YargsInstance_options, "f").key[k] = true;
2946
+ }
2947
+ }
2948
+ function isYargsInstance(y) {
2949
+ return !!y && 'function' == typeof y.getInternalMethods;
2950
+ }
2951
+ const Yargs = YargsFactory(esm.Z);
2952
+ const node_modules_yargs = Yargs;
2953
+ }
2954
+ };
2955
+
2956
+ //# sourceMappingURL=760.mjs.map