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