yarsg 18.0.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.

Potentially problematic release.


This version of yarsg might be problematic. Click here for more details.

Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -0
  3. package/browser.d.ts +5 -0
  4. package/browser.mjs +7 -0
  5. package/build/lib/argsert.js +62 -0
  6. package/build/lib/command.js +479 -0
  7. package/build/lib/completion-templates.js +57 -0
  8. package/build/lib/completion.js +243 -0
  9. package/build/lib/middleware.js +88 -0
  10. package/build/lib/parse-command.js +32 -0
  11. package/build/lib/typings/common-types.js +9 -0
  12. package/build/lib/typings/yargs-parser-types.js +1 -0
  13. package/build/lib/usage.js +584 -0
  14. package/build/lib/utils/apply-extends.js +59 -0
  15. package/build/lib/utils/is-promise.js +5 -0
  16. package/build/lib/utils/levenshtein.js +34 -0
  17. package/build/lib/utils/maybe-async-result.js +17 -0
  18. package/build/lib/utils/obj-filter.js +10 -0
  19. package/build/lib/utils/process-argv.js +17 -0
  20. package/build/lib/utils/set-blocking.js +12 -0
  21. package/build/lib/utils/which-module.js +10 -0
  22. package/build/lib/validation.js +305 -0
  23. package/build/lib/yargs-factory.js +1517 -0
  24. package/build/lib/yerror.js +9 -0
  25. package/helpers/helpers.mjs +10 -0
  26. package/helpers/package.json +3 -0
  27. package/index.mjs +10 -0
  28. package/lib/platform-shims/browser.mjs +99 -0
  29. package/lib/platform-shims/esm.mjs +67 -0
  30. package/locales/be.json +46 -0
  31. package/locales/cs.json +51 -0
  32. package/locales/de.json +46 -0
  33. package/locales/en.json +55 -0
  34. package/locales/es.json +46 -0
  35. package/locales/fi.json +49 -0
  36. package/locales/fr.json +53 -0
  37. package/locales/he.json +55 -0
  38. package/locales/hi.json +49 -0
  39. package/locales/hu.json +46 -0
  40. package/locales/id.json +50 -0
  41. package/locales/it.json +46 -0
  42. package/locales/ja.json +51 -0
  43. package/locales/ko.json +49 -0
  44. package/locales/nb.json +44 -0
  45. package/locales/nl.json +49 -0
  46. package/locales/nn.json +44 -0
  47. package/locales/pirate.json +13 -0
  48. package/locales/pl.json +49 -0
  49. package/locales/pt.json +45 -0
  50. package/locales/pt_BR.json +48 -0
  51. package/locales/ru.json +51 -0
  52. package/locales/th.json +46 -0
  53. package/locales/tr.json +48 -0
  54. package/locales/uk_UA.json +51 -0
  55. package/locales/uz.json +52 -0
  56. package/locales/zh_CN.json +48 -0
  57. package/locales/zh_TW.json +51 -0
  58. package/package.json +102 -0
@@ -0,0 +1,1517 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ 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;
13
+ import { command as Command, } from './command.js';
14
+ import { assertNotStrictEqual, assertSingleKey, objectKeys, } from './typings/common-types.js';
15
+ import { YError } from './yerror.js';
16
+ import { usage as Usage } from './usage.js';
17
+ import { argsert } from './argsert.js';
18
+ import { completion as Completion, } from './completion.js';
19
+ import { validation as Validation, } from './validation.js';
20
+ import { objFilter } from './utils/obj-filter.js';
21
+ import { applyExtends } from './utils/apply-extends.js';
22
+ import { applyMiddleware, GlobalMiddleware, } from './middleware.js';
23
+ import { isPromise } from './utils/is-promise.js';
24
+ import { maybeAsyncResult } from './utils/maybe-async-result.js';
25
+ import setBlocking from './utils/set-blocking.js';
26
+ export function YargsFactory(_shim) {
27
+ return (processArgs = [], cwd = _shim.process.cwd(), parentRequire) => {
28
+ const yargs = new YargsInstance(processArgs, cwd, parentRequire, _shim);
29
+ Object.defineProperty(yargs, 'argv', {
30
+ get: () => {
31
+ return yargs.parse();
32
+ },
33
+ enumerable: true,
34
+ });
35
+ yargs.help();
36
+ yargs.version();
37
+ return yargs;
38
+ };
39
+ }
40
+ const kCopyDoubleDash = Symbol('copyDoubleDash');
41
+ const kCreateLogger = Symbol('copyDoubleDash');
42
+ const kDeleteFromParserHintObject = Symbol('deleteFromParserHintObject');
43
+ const kEmitWarning = Symbol('emitWarning');
44
+ const kFreeze = Symbol('freeze');
45
+ const kGetDollarZero = Symbol('getDollarZero');
46
+ const kGetParserConfiguration = Symbol('getParserConfiguration');
47
+ const kGetUsageConfiguration = Symbol('getUsageConfiguration');
48
+ const kGuessLocale = Symbol('guessLocale');
49
+ const kGuessVersion = Symbol('guessVersion');
50
+ const kParsePositionalNumbers = Symbol('parsePositionalNumbers');
51
+ const kPkgUp = Symbol('pkgUp');
52
+ const kPopulateParserHintArray = Symbol('populateParserHintArray');
53
+ const kPopulateParserHintSingleValueDictionary = Symbol('populateParserHintSingleValueDictionary');
54
+ const kPopulateParserHintArrayDictionary = Symbol('populateParserHintArrayDictionary');
55
+ const kPopulateParserHintDictionary = Symbol('populateParserHintDictionary');
56
+ const kSanitizeKey = Symbol('sanitizeKey');
57
+ const kSetKey = Symbol('setKey');
58
+ const kUnfreeze = Symbol('unfreeze');
59
+ const kValidateAsync = Symbol('validateAsync');
60
+ const kGetCommandInstance = Symbol('getCommandInstance');
61
+ const kGetContext = Symbol('getContext');
62
+ const kGetHasOutput = Symbol('getHasOutput');
63
+ const kGetLoggerInstance = Symbol('getLoggerInstance');
64
+ const kGetParseContext = Symbol('getParseContext');
65
+ const kGetUsageInstance = Symbol('getUsageInstance');
66
+ const kGetValidationInstance = Symbol('getValidationInstance');
67
+ const kHasParseCallback = Symbol('hasParseCallback');
68
+ const kIsGlobalContext = Symbol('isGlobalContext');
69
+ const kPostProcess = Symbol('postProcess');
70
+ const kRebase = Symbol('rebase');
71
+ const kReset = Symbol('reset');
72
+ const kRunYargsParserAndExecuteCommands = Symbol('runYargsParserAndExecuteCommands');
73
+ const kRunValidation = Symbol('runValidation');
74
+ const kSetHasOutput = Symbol('setHasOutput');
75
+ const kTrackManuallySetKeys = Symbol('kTrackManuallySetKeys');
76
+ const DEFAULT_LOCALE = 'en_US';
77
+ export class YargsInstance {
78
+ constructor(processArgs = [], cwd, parentRequire, shim) {
79
+ this.customScriptName = false;
80
+ this.parsed = false;
81
+ _YargsInstance_command.set(this, void 0);
82
+ _YargsInstance_cwd.set(this, void 0);
83
+ _YargsInstance_context.set(this, { commands: [], fullCommands: [] });
84
+ _YargsInstance_completion.set(this, null);
85
+ _YargsInstance_completionCommand.set(this, null);
86
+ _YargsInstance_defaultShowHiddenOpt.set(this, 'show-hidden');
87
+ _YargsInstance_exitError.set(this, null);
88
+ _YargsInstance_detectLocale.set(this, true);
89
+ _YargsInstance_emittedWarnings.set(this, {});
90
+ _YargsInstance_exitProcess.set(this, true);
91
+ _YargsInstance_frozens.set(this, []);
92
+ _YargsInstance_globalMiddleware.set(this, void 0);
93
+ _YargsInstance_groups.set(this, {});
94
+ _YargsInstance_hasOutput.set(this, false);
95
+ _YargsInstance_helpOpt.set(this, null);
96
+ _YargsInstance_isGlobalContext.set(this, true);
97
+ _YargsInstance_logger.set(this, void 0);
98
+ _YargsInstance_output.set(this, '');
99
+ _YargsInstance_options.set(this, void 0);
100
+ _YargsInstance_parentRequire.set(this, void 0);
101
+ _YargsInstance_parserConfig.set(this, {});
102
+ _YargsInstance_parseFn.set(this, null);
103
+ _YargsInstance_parseContext.set(this, null);
104
+ _YargsInstance_pkgs.set(this, {});
105
+ _YargsInstance_preservedGroups.set(this, {});
106
+ _YargsInstance_processArgs.set(this, void 0);
107
+ _YargsInstance_recommendCommands.set(this, false);
108
+ _YargsInstance_shim.set(this, void 0);
109
+ _YargsInstance_strict.set(this, false);
110
+ _YargsInstance_strictCommands.set(this, false);
111
+ _YargsInstance_strictOptions.set(this, false);
112
+ _YargsInstance_usage.set(this, void 0);
113
+ _YargsInstance_usageConfig.set(this, {});
114
+ _YargsInstance_versionOpt.set(this, null);
115
+ _YargsInstance_validation.set(this, void 0);
116
+ __classPrivateFieldSet(this, _YargsInstance_shim, shim, "f");
117
+ __classPrivateFieldSet(this, _YargsInstance_processArgs, processArgs, "f");
118
+ __classPrivateFieldSet(this, _YargsInstance_cwd, cwd, "f");
119
+ __classPrivateFieldSet(this, _YargsInstance_parentRequire, parentRequire, "f");
120
+ __classPrivateFieldSet(this, _YargsInstance_globalMiddleware, new GlobalMiddleware(this), "f");
121
+ this.$0 = this[kGetDollarZero]();
122
+ this[kReset]();
123
+ __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f"), "f");
124
+ __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), "f");
125
+ __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f"), "f");
126
+ __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f"), "f");
127
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
128
+ __classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger](), "f");
129
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(DEFAULT_LOCALE);
130
+ }
131
+ addHelpOpt(opt, msg) {
132
+ const defaultHelpOpt = 'help';
133
+ argsert('[string|boolean] [string]', [opt, msg], arguments.length);
134
+ if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
135
+ this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
136
+ __classPrivateFieldSet(this, _YargsInstance_helpOpt, null, "f");
137
+ }
138
+ if (opt === false && msg === undefined)
139
+ return this;
140
+ __classPrivateFieldSet(this, _YargsInstance_helpOpt, typeof opt === 'string' ? opt : defaultHelpOpt, "f");
141
+ this.boolean(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
142
+ this.describe(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"), msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Show help'));
143
+ return this;
144
+ }
145
+ help(opt, msg) {
146
+ return this.addHelpOpt(opt, msg);
147
+ }
148
+ addShowHiddenOpt(opt, msg) {
149
+ argsert('[string|boolean] [string]', [opt, msg], arguments.length);
150
+ if (opt === false && msg === undefined)
151
+ return this;
152
+ const showHiddenOpt = typeof opt === 'string' ? opt : __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
153
+ this.boolean(showHiddenOpt);
154
+ this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Show hidden options'));
155
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = showHiddenOpt;
156
+ return this;
157
+ }
158
+ showHidden(opt, msg) {
159
+ return this.addShowHiddenOpt(opt, msg);
160
+ }
161
+ alias(key, value) {
162
+ argsert('<object|string|array> [string|array]', [key, value], arguments.length);
163
+ this[kPopulateParserHintArrayDictionary](this.alias.bind(this), 'alias', key, value);
164
+ return this;
165
+ }
166
+ array(keys) {
167
+ argsert('<array|string>', [keys], arguments.length);
168
+ this[kPopulateParserHintArray]('array', keys);
169
+ this[kTrackManuallySetKeys](keys);
170
+ return this;
171
+ }
172
+ boolean(keys) {
173
+ argsert('<array|string>', [keys], arguments.length);
174
+ this[kPopulateParserHintArray]('boolean', keys);
175
+ this[kTrackManuallySetKeys](keys);
176
+ return this;
177
+ }
178
+ check(f, global) {
179
+ argsert('<function> [boolean]', [f, global], arguments.length);
180
+ this.middleware((argv, _yargs) => {
181
+ return maybeAsyncResult(() => {
182
+ return f(argv, _yargs.getOptions());
183
+ }, (result) => {
184
+ if (!result) {
185
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__('Argument check failed: %s', f.toString()));
186
+ }
187
+ else if (typeof result === 'string' || result instanceof Error) {
188
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(result.toString(), result);
189
+ }
190
+ return argv;
191
+ }, (err) => {
192
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message ? err.message : err.toString(), err);
193
+ return argv;
194
+ });
195
+ }, false, global);
196
+ return this;
197
+ }
198
+ choices(key, value) {
199
+ argsert('<object|string|array> [string|array]', [key, value], arguments.length);
200
+ this[kPopulateParserHintArrayDictionary](this.choices.bind(this), 'choices', key, value);
201
+ return this;
202
+ }
203
+ coerce(keys, value) {
204
+ argsert('<object|string|array> [function]', [keys, value], arguments.length);
205
+ if (Array.isArray(keys)) {
206
+ if (!value) {
207
+ throw new YError('coerce callback must be provided');
208
+ }
209
+ for (const key of keys) {
210
+ this.coerce(key, value);
211
+ }
212
+ return this;
213
+ }
214
+ else if (typeof keys === 'object') {
215
+ for (const key of Object.keys(keys)) {
216
+ this.coerce(key, keys[key]);
217
+ }
218
+ return this;
219
+ }
220
+ if (!value) {
221
+ throw new YError('coerce callback must be provided');
222
+ }
223
+ const coerceKey = keys;
224
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[coerceKey] = true;
225
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
226
+ var _a;
227
+ const coerceKeyAliases = (_a = yargs.getAliases()[coerceKey]) !== null && _a !== void 0 ? _a : [];
228
+ const argvKeys = [coerceKey, ...coerceKeyAliases].filter(key => Object.prototype.hasOwnProperty.call(argv, key));
229
+ if (argvKeys.length === 0) {
230
+ return argv;
231
+ }
232
+ return maybeAsyncResult(() => {
233
+ return value(argv[argvKeys[0]]);
234
+ }, (result) => {
235
+ argvKeys.forEach(key => {
236
+ argv[key] = result;
237
+ });
238
+ return argv;
239
+ }, (err) => {
240
+ throw new YError(err.message);
241
+ });
242
+ }, coerceKey);
243
+ return this;
244
+ }
245
+ conflicts(key1, key2) {
246
+ argsert('<string|object> [string|array]', [key1, key2], arguments.length);
247
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicts(key1, key2);
248
+ return this;
249
+ }
250
+ config(key = 'config', msg, parseFn) {
251
+ argsert('[object|string] [string|function] [function]', [key, msg, parseFn], arguments.length);
252
+ if (typeof key === 'object' && !Array.isArray(key)) {
253
+ key = applyExtends(key, __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()['deep-merge-config'] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
254
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(key);
255
+ return this;
256
+ }
257
+ if (typeof msg === 'function') {
258
+ parseFn = msg;
259
+ msg = undefined;
260
+ }
261
+ this.describe(key, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Path to JSON config file'));
262
+ (Array.isArray(key) ? key : [key]).forEach(k => {
263
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").config[k] = parseFn || true;
264
+ });
265
+ return this;
266
+ }
267
+ completion(cmd, desc, fn) {
268
+ argsert('[string] [string|boolean|function] [function]', [cmd, desc, fn], arguments.length);
269
+ if (typeof desc === 'function') {
270
+ fn = desc;
271
+ desc = undefined;
272
+ }
273
+ __classPrivateFieldSet(this, _YargsInstance_completionCommand, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || 'completion', "f");
274
+ if (!desc && desc !== false) {
275
+ desc = 'generate completion script';
276
+ }
277
+ this.command(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), desc);
278
+ if (fn)
279
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn);
280
+ return this;
281
+ }
282
+ command(cmd, description, builder, handler, middlewares, deprecated) {
283
+ argsert('<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]', [cmd, description, builder, handler, middlewares, deprecated], arguments.length);
284
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description, builder, handler, middlewares, deprecated);
285
+ return this;
286
+ }
287
+ commands(cmd, description, builder, handler, middlewares, deprecated) {
288
+ return this.command(cmd, description, builder, handler, middlewares, deprecated);
289
+ }
290
+ commandDir(dir, opts) {
291
+ argsert('<string> [object]', [dir, opts], arguments.length);
292
+ const req = __classPrivateFieldGet(this, _YargsInstance_parentRequire, "f") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").require;
293
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").addDirectory(dir, req, __classPrivateFieldGet(this, _YargsInstance_shim, "f").getCallerFile(), opts);
294
+ return this;
295
+ }
296
+ count(keys) {
297
+ argsert('<array|string>', [keys], arguments.length);
298
+ this[kPopulateParserHintArray]('count', keys);
299
+ this[kTrackManuallySetKeys](keys);
300
+ return this;
301
+ }
302
+ default(key, value, defaultDescription) {
303
+ argsert('<object|string|array> [*] [string]', [key, value, defaultDescription], arguments.length);
304
+ if (defaultDescription) {
305
+ assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
306
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = defaultDescription;
307
+ }
308
+ if (typeof value === 'function') {
309
+ assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
310
+ if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key])
311
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] =
312
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").functionDescription(value);
313
+ value = value.call();
314
+ }
315
+ this[kPopulateParserHintSingleValueDictionary](this.default.bind(this), 'default', key, value);
316
+ return this;
317
+ }
318
+ defaults(key, value, defaultDescription) {
319
+ return this.default(key, value, defaultDescription);
320
+ }
321
+ demandCommand(min = 1, max, minMsg, maxMsg) {
322
+ argsert('[number] [number|string] [string|null|undefined] [string|null|undefined]', [min, max, minMsg, maxMsg], arguments.length);
323
+ if (typeof max !== 'number') {
324
+ minMsg = max;
325
+ max = Infinity;
326
+ }
327
+ this.global('_', false);
328
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands._ = {
329
+ min,
330
+ max,
331
+ minMsg,
332
+ maxMsg,
333
+ };
334
+ return this;
335
+ }
336
+ demand(keys, max, msg) {
337
+ if (Array.isArray(max)) {
338
+ max.forEach(key => {
339
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
340
+ this.demandOption(key, msg);
341
+ });
342
+ max = Infinity;
343
+ }
344
+ else if (typeof max !== 'number') {
345
+ msg = max;
346
+ max = Infinity;
347
+ }
348
+ if (typeof keys === 'number') {
349
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
350
+ this.demandCommand(keys, max, msg, msg);
351
+ }
352
+ else if (Array.isArray(keys)) {
353
+ keys.forEach(key => {
354
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
355
+ this.demandOption(key, msg);
356
+ });
357
+ }
358
+ else {
359
+ if (typeof msg === 'string') {
360
+ this.demandOption(keys, msg);
361
+ }
362
+ else if (msg === true || typeof msg === 'undefined') {
363
+ this.demandOption(keys);
364
+ }
365
+ }
366
+ return this;
367
+ }
368
+ demandOption(keys, msg) {
369
+ argsert('<object|string|array> [string]', [keys, msg], arguments.length);
370
+ this[kPopulateParserHintSingleValueDictionary](this.demandOption.bind(this), 'demandedOptions', keys, msg);
371
+ return this;
372
+ }
373
+ deprecateOption(option, message) {
374
+ argsert('<string> [string|boolean]', [option, message], arguments.length);
375
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message;
376
+ return this;
377
+ }
378
+ describe(keys, description) {
379
+ argsert('<object|string|array> [string]', [keys, description], arguments.length);
380
+ this[kSetKey](keys, true);
381
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description);
382
+ return this;
383
+ }
384
+ detectLocale(detect) {
385
+ argsert('<boolean>', [detect], arguments.length);
386
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, detect, "f");
387
+ return this;
388
+ }
389
+ env(prefix) {
390
+ argsert('[string|boolean]', [prefix], arguments.length);
391
+ if (prefix === false)
392
+ delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
393
+ else
394
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix || '';
395
+ return this;
396
+ }
397
+ epilogue(msg) {
398
+ argsert('<string>', [msg], arguments.length);
399
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").epilog(msg);
400
+ return this;
401
+ }
402
+ epilog(msg) {
403
+ return this.epilogue(msg);
404
+ }
405
+ example(cmd, description) {
406
+ argsert('<string|array> [string]', [cmd, description], arguments.length);
407
+ if (Array.isArray(cmd)) {
408
+ cmd.forEach(exampleParams => this.example(...exampleParams));
409
+ }
410
+ else {
411
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description);
412
+ }
413
+ return this;
414
+ }
415
+ exit(code, err) {
416
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
417
+ __classPrivateFieldSet(this, _YargsInstance_exitError, err, "f");
418
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
419
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.exit(code);
420
+ }
421
+ exitProcess(enabled = true) {
422
+ argsert('[boolean]', [enabled], arguments.length);
423
+ __classPrivateFieldSet(this, _YargsInstance_exitProcess, enabled, "f");
424
+ return this;
425
+ }
426
+ fail(f) {
427
+ argsert('<function|boolean>', [f], arguments.length);
428
+ if (typeof f === 'boolean' && f !== false) {
429
+ throw new YError("Invalid first argument. Expected function or boolean 'false'");
430
+ }
431
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").failFn(f);
432
+ return this;
433
+ }
434
+ getAliases() {
435
+ return this.parsed ? this.parsed.aliases : {};
436
+ }
437
+ async getCompletion(args, done) {
438
+ argsert('<array> [function]', [args, done], arguments.length);
439
+ if (!done) {
440
+ return new Promise((resolve, reject) => {
441
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
442
+ if (err)
443
+ reject(err);
444
+ else
445
+ resolve(completions);
446
+ });
447
+ });
448
+ }
449
+ else {
450
+ return __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, done);
451
+ }
452
+ }
453
+ getDemandedOptions() {
454
+ argsert([], 0);
455
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedOptions;
456
+ }
457
+ getDemandedCommands() {
458
+ argsert([], 0);
459
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands;
460
+ }
461
+ getDeprecatedOptions() {
462
+ argsert([], 0);
463
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions;
464
+ }
465
+ getDetectLocale() {
466
+ return __classPrivateFieldGet(this, _YargsInstance_detectLocale, "f");
467
+ }
468
+ getExitProcess() {
469
+ return __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f");
470
+ }
471
+ getGroups() {
472
+ return Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_groups, "f"), __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"));
473
+ }
474
+ getHelp() {
475
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
476
+ if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
477
+ if (!this.parsed) {
478
+ const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), undefined, undefined, 0, true);
479
+ if (isPromise(parse)) {
480
+ return parse.then(() => {
481
+ return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
482
+ });
483
+ }
484
+ }
485
+ const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
486
+ if (isPromise(builderResponse)) {
487
+ return builderResponse.then(() => {
488
+ return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
489
+ });
490
+ }
491
+ }
492
+ return Promise.resolve(__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
493
+ }
494
+ getOptions() {
495
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f");
496
+ }
497
+ getStrict() {
498
+ return __classPrivateFieldGet(this, _YargsInstance_strict, "f");
499
+ }
500
+ getStrictCommands() {
501
+ return __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f");
502
+ }
503
+ getStrictOptions() {
504
+ return __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f");
505
+ }
506
+ global(globals, global) {
507
+ argsert('<string|array> [boolean]', [globals, global], arguments.length);
508
+ globals = [].concat(globals);
509
+ if (global !== false) {
510
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local.filter(l => globals.indexOf(l) === -1);
511
+ }
512
+ else {
513
+ globals.forEach(g => {
514
+ if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").local.includes(g))
515
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").local.push(g);
516
+ });
517
+ }
518
+ return this;
519
+ }
520
+ group(opts, groupName) {
521
+ argsert('<string|array> <string>', [opts, groupName], arguments.length);
522
+ const existing = __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName] || __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName];
523
+ if (__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]) {
524
+ delete __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName];
525
+ }
526
+ const seen = {};
527
+ __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName] = (existing || []).concat(opts).filter(key => {
528
+ if (seen[key])
529
+ return false;
530
+ return (seen[key] = true);
531
+ });
532
+ return this;
533
+ }
534
+ hide(key) {
535
+ argsert('<string>', [key], arguments.length);
536
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").hiddenOptions.push(key);
537
+ return this;
538
+ }
539
+ implies(key, value) {
540
+ argsert('<string|object> [number|string|array]', [key, value], arguments.length);
541
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").implies(key, value);
542
+ return this;
543
+ }
544
+ locale(locale) {
545
+ argsert('[string]', [locale], arguments.length);
546
+ if (locale === undefined) {
547
+ this[kGuessLocale]();
548
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
549
+ }
550
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
551
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(locale);
552
+ return this;
553
+ }
554
+ middleware(callback, applyBeforeValidation, global) {
555
+ return __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addMiddleware(callback, !!applyBeforeValidation, global);
556
+ }
557
+ nargs(key, value) {
558
+ argsert('<string|object|array> [number]', [key, value], arguments.length);
559
+ this[kPopulateParserHintSingleValueDictionary](this.nargs.bind(this), 'narg', key, value);
560
+ return this;
561
+ }
562
+ normalize(keys) {
563
+ argsert('<array|string>', [keys], arguments.length);
564
+ this[kPopulateParserHintArray]('normalize', keys);
565
+ return this;
566
+ }
567
+ number(keys) {
568
+ argsert('<array|string>', [keys], arguments.length);
569
+ this[kPopulateParserHintArray]('number', keys);
570
+ this[kTrackManuallySetKeys](keys);
571
+ return this;
572
+ }
573
+ option(key, opt) {
574
+ argsert('<string|object> [object]', [key, opt], arguments.length);
575
+ if (typeof key === 'object') {
576
+ Object.keys(key).forEach(k => {
577
+ this.options(k, key[k]);
578
+ });
579
+ }
580
+ else {
581
+ if (typeof opt !== 'object') {
582
+ opt = {};
583
+ }
584
+ this[kTrackManuallySetKeys](key);
585
+ if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && (key === 'version' || (opt === null || opt === void 0 ? void 0 : opt.alias) === 'version')) {
586
+ this[kEmitWarning]([
587
+ '"version" is a reserved word.',
588
+ 'Please do one of the following:',
589
+ '- Disable version with `yargs.version(false)` if using "version" as an option',
590
+ '- Use the built-in `yargs.version` method instead (if applicable)',
591
+ '- Use a different option key',
592
+ 'https://yargs.js.org/docs/#api-reference-version',
593
+ ].join('\n'), undefined, 'versionWarning');
594
+ }
595
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[key] = true;
596
+ if (opt.alias)
597
+ this.alias(key, opt.alias);
598
+ const deprecate = opt.deprecate || opt.deprecated;
599
+ if (deprecate) {
600
+ this.deprecateOption(key, deprecate);
601
+ }
602
+ const demand = opt.demand || opt.required || opt.require;
603
+ if (demand) {
604
+ this.demand(key, demand);
605
+ }
606
+ if (opt.demandOption) {
607
+ this.demandOption(key, typeof opt.demandOption === 'string' ? opt.demandOption : undefined);
608
+ }
609
+ if (opt.conflicts) {
610
+ this.conflicts(key, opt.conflicts);
611
+ }
612
+ if ('default' in opt) {
613
+ this.default(key, opt.default);
614
+ }
615
+ if (opt.implies !== undefined) {
616
+ this.implies(key, opt.implies);
617
+ }
618
+ if (opt.nargs !== undefined) {
619
+ this.nargs(key, opt.nargs);
620
+ }
621
+ if (opt.config) {
622
+ this.config(key, opt.configParser);
623
+ }
624
+ if (opt.normalize) {
625
+ this.normalize(key);
626
+ }
627
+ if (opt.choices) {
628
+ this.choices(key, opt.choices);
629
+ }
630
+ if (opt.coerce) {
631
+ this.coerce(key, opt.coerce);
632
+ }
633
+ if (opt.group) {
634
+ this.group(key, opt.group);
635
+ }
636
+ if (opt.boolean || opt.type === 'boolean') {
637
+ this.boolean(key);
638
+ if (opt.alias)
639
+ this.boolean(opt.alias);
640
+ }
641
+ if (opt.array || opt.type === 'array') {
642
+ this.array(key);
643
+ if (opt.alias)
644
+ this.array(opt.alias);
645
+ }
646
+ if (opt.number || opt.type === 'number') {
647
+ this.number(key);
648
+ if (opt.alias)
649
+ this.number(opt.alias);
650
+ }
651
+ if (opt.string || opt.type === 'string') {
652
+ this.string(key);
653
+ if (opt.alias)
654
+ this.string(opt.alias);
655
+ }
656
+ if (opt.count || opt.type === 'count') {
657
+ this.count(key);
658
+ }
659
+ if (typeof opt.global === 'boolean') {
660
+ this.global(key, opt.global);
661
+ }
662
+ if (opt.defaultDescription) {
663
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = opt.defaultDescription;
664
+ }
665
+ if (opt.skipValidation) {
666
+ this.skipValidation(key);
667
+ }
668
+ const desc = opt.describe || opt.description || opt.desc;
669
+ const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions();
670
+ if (!Object.prototype.hasOwnProperty.call(descriptions, key) ||
671
+ typeof desc === 'string') {
672
+ this.describe(key, desc);
673
+ }
674
+ if (opt.hidden) {
675
+ this.hide(key);
676
+ }
677
+ if (opt.requiresArg) {
678
+ this.requiresArg(key);
679
+ }
680
+ }
681
+ return this;
682
+ }
683
+ options(key, opt) {
684
+ return this.option(key, opt);
685
+ }
686
+ parse(args, shortCircuit, _parseFn) {
687
+ argsert('[string|array] [function|boolean|object] [function]', [args, shortCircuit, _parseFn], arguments.length);
688
+ this[kFreeze]();
689
+ if (typeof args === 'undefined') {
690
+ args = __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
691
+ }
692
+ if (typeof shortCircuit === 'object') {
693
+ __classPrivateFieldSet(this, _YargsInstance_parseContext, shortCircuit, "f");
694
+ shortCircuit = _parseFn;
695
+ }
696
+ if (typeof shortCircuit === 'function') {
697
+ __classPrivateFieldSet(this, _YargsInstance_parseFn, shortCircuit, "f");
698
+ shortCircuit = false;
699
+ }
700
+ if (!shortCircuit)
701
+ __classPrivateFieldSet(this, _YargsInstance_processArgs, args, "f");
702
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
703
+ __classPrivateFieldSet(this, _YargsInstance_exitProcess, false, "f");
704
+ const parsed = this[kRunYargsParserAndExecuteCommands](args, !!shortCircuit);
705
+ const tmpParsed = this.parsed;
706
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").setParsed(this.parsed);
707
+ if (isPromise(parsed)) {
708
+ return parsed
709
+ .then(argv => {
710
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
711
+ __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
712
+ return argv;
713
+ })
714
+ .catch(err => {
715
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) {
716
+ __classPrivateFieldGet(this, _YargsInstance_parseFn, "f")(err, this.parsed.argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
717
+ }
718
+ throw err;
719
+ })
720
+ .finally(() => {
721
+ this[kUnfreeze]();
722
+ this.parsed = tmpParsed;
723
+ });
724
+ }
725
+ else {
726
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
727
+ __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), parsed, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
728
+ this[kUnfreeze]();
729
+ this.parsed = tmpParsed;
730
+ }
731
+ return parsed;
732
+ }
733
+ parseAsync(args, shortCircuit, _parseFn) {
734
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
735
+ return !isPromise(maybePromise)
736
+ ? Promise.resolve(maybePromise)
737
+ : maybePromise;
738
+ }
739
+ parseSync(args, shortCircuit, _parseFn) {
740
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
741
+ if (isPromise(maybePromise)) {
742
+ throw new YError('.parseSync() must not be used with asynchronous builders, handlers, or middleware');
743
+ }
744
+ return maybePromise;
745
+ }
746
+ parserConfiguration(config) {
747
+ argsert('<object>', [config], arguments.length);
748
+ __classPrivateFieldSet(this, _YargsInstance_parserConfig, config, "f");
749
+ return this;
750
+ }
751
+ pkgConf(key, rootPath) {
752
+ argsert('<string> [string]', [key, rootPath], arguments.length);
753
+ let conf = null;
754
+ const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"));
755
+ if (obj[key] && typeof obj[key] === 'object') {
756
+ conf = applyExtends(obj[key], rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()['deep-merge-config'] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
757
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(conf);
758
+ }
759
+ return this;
760
+ }
761
+ positional(key, opts) {
762
+ argsert('<string> <object>', [key, opts], arguments.length);
763
+ const supportedOpts = [
764
+ 'default',
765
+ 'defaultDescription',
766
+ 'implies',
767
+ 'normalize',
768
+ 'choices',
769
+ 'conflicts',
770
+ 'coerce',
771
+ 'type',
772
+ 'describe',
773
+ 'desc',
774
+ 'description',
775
+ 'alias',
776
+ ];
777
+ opts = objFilter(opts, (k, v) => {
778
+ if (k === 'type' && !['string', 'number', 'boolean'].includes(v))
779
+ return false;
780
+ return supportedOpts.includes(k);
781
+ });
782
+ const fullCommand = __classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands[__classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands.length - 1];
783
+ const parseOptions = fullCommand
784
+ ? __classPrivateFieldGet(this, _YargsInstance_command, "f").cmdToParseOptions(fullCommand)
785
+ : {
786
+ array: [],
787
+ alias: {},
788
+ default: {},
789
+ demand: {},
790
+ };
791
+ objectKeys(parseOptions).forEach(pk => {
792
+ const parseOption = parseOptions[pk];
793
+ if (Array.isArray(parseOption)) {
794
+ if (parseOption.indexOf(key) !== -1)
795
+ opts[pk] = true;
796
+ }
797
+ else {
798
+ if (parseOption[key] && !(pk in opts))
799
+ opts[pk] = parseOption[key];
800
+ }
801
+ });
802
+ this.group(key, __classPrivateFieldGet(this, _YargsInstance_usage, "f").getPositionalGroupName());
803
+ return this.option(key, opts);
804
+ }
805
+ recommendCommands(recommend = true) {
806
+ argsert('[boolean]', [recommend], arguments.length);
807
+ __classPrivateFieldSet(this, _YargsInstance_recommendCommands, recommend, "f");
808
+ return this;
809
+ }
810
+ required(keys, max, msg) {
811
+ return this.demand(keys, max, msg);
812
+ }
813
+ require(keys, max, msg) {
814
+ return this.demand(keys, max, msg);
815
+ }
816
+ requiresArg(keys) {
817
+ argsert('<array|string|object> [number]', [keys], arguments.length);
818
+ if (typeof keys === 'string' && __classPrivateFieldGet(this, _YargsInstance_options, "f").narg[keys]) {
819
+ return this;
820
+ }
821
+ else {
822
+ this[kPopulateParserHintSingleValueDictionary](this.requiresArg.bind(this), 'narg', keys, NaN);
823
+ }
824
+ return this;
825
+ }
826
+ showCompletionScript($0, cmd) {
827
+ argsert('[string] [string]', [$0, cmd], arguments.length);
828
+ $0 = $0 || this.$0;
829
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(__classPrivateFieldGet(this, _YargsInstance_completion, "f").generateCompletionScript($0, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || 'completion'));
830
+ return this;
831
+ }
832
+ showHelp(level) {
833
+ argsert('[string|function]', [level], arguments.length);
834
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
835
+ if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
836
+ if (!this.parsed) {
837
+ const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), undefined, undefined, 0, true);
838
+ if (isPromise(parse)) {
839
+ parse.then(() => {
840
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
841
+ });
842
+ return this;
843
+ }
844
+ }
845
+ const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
846
+ if (isPromise(builderResponse)) {
847
+ builderResponse.then(() => {
848
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
849
+ });
850
+ return this;
851
+ }
852
+ }
853
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
854
+ return this;
855
+ }
856
+ scriptName(scriptName) {
857
+ this.customScriptName = true;
858
+ this.$0 = scriptName;
859
+ return this;
860
+ }
861
+ showHelpOnFail(enabled, message) {
862
+ argsert('[boolean|string] [string]', [enabled, message], arguments.length);
863
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelpOnFail(enabled, message);
864
+ return this;
865
+ }
866
+ showVersion(level) {
867
+ argsert('[string|function]', [level], arguments.length);
868
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion(level);
869
+ return this;
870
+ }
871
+ skipValidation(keys) {
872
+ argsert('<array|string>', [keys], arguments.length);
873
+ this[kPopulateParserHintArray]('skipValidation', keys);
874
+ return this;
875
+ }
876
+ strict(enabled) {
877
+ argsert('[boolean]', [enabled], arguments.length);
878
+ __classPrivateFieldSet(this, _YargsInstance_strict, enabled !== false, "f");
879
+ return this;
880
+ }
881
+ strictCommands(enabled) {
882
+ argsert('[boolean]', [enabled], arguments.length);
883
+ __classPrivateFieldSet(this, _YargsInstance_strictCommands, enabled !== false, "f");
884
+ return this;
885
+ }
886
+ strictOptions(enabled) {
887
+ argsert('[boolean]', [enabled], arguments.length);
888
+ __classPrivateFieldSet(this, _YargsInstance_strictOptions, enabled !== false, "f");
889
+ return this;
890
+ }
891
+ string(keys) {
892
+ argsert('<array|string>', [keys], arguments.length);
893
+ this[kPopulateParserHintArray]('string', keys);
894
+ this[kTrackManuallySetKeys](keys);
895
+ return this;
896
+ }
897
+ terminalWidth() {
898
+ argsert([], 0);
899
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.stdColumns;
900
+ }
901
+ updateLocale(obj) {
902
+ return this.updateStrings(obj);
903
+ }
904
+ updateStrings(obj) {
905
+ argsert('<object>', [obj], arguments.length);
906
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
907
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj);
908
+ return this;
909
+ }
910
+ usage(msg, description, builder, handler) {
911
+ argsert('<string|null|undefined> [string|boolean] [function|object] [function]', [msg, description, builder, handler], arguments.length);
912
+ if (description !== undefined) {
913
+ assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
914
+ if ((msg || '').match(/^\$0( |$)/)) {
915
+ return this.command(msg, description, builder, handler);
916
+ }
917
+ else {
918
+ throw new YError('.usage() description must start with $0 if being used as alias for .command()');
919
+ }
920
+ }
921
+ else {
922
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").usage(msg);
923
+ return this;
924
+ }
925
+ }
926
+ usageConfiguration(config) {
927
+ argsert('<object>', [config], arguments.length);
928
+ __classPrivateFieldSet(this, _YargsInstance_usageConfig, config, "f");
929
+ return this;
930
+ }
931
+ version(opt, msg, ver) {
932
+ const defaultVersionOpt = 'version';
933
+ argsert('[boolean|string] [string] [string]', [opt, msg, ver], arguments.length);
934
+ if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")) {
935
+ this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
936
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(undefined);
937
+ __classPrivateFieldSet(this, _YargsInstance_versionOpt, null, "f");
938
+ }
939
+ if (arguments.length === 0) {
940
+ ver = this[kGuessVersion]();
941
+ opt = defaultVersionOpt;
942
+ }
943
+ else if (arguments.length === 1) {
944
+ if (opt === false) {
945
+ return this;
946
+ }
947
+ ver = opt;
948
+ opt = defaultVersionOpt;
949
+ }
950
+ else if (arguments.length === 2) {
951
+ ver = msg;
952
+ msg = undefined;
953
+ }
954
+ __classPrivateFieldSet(this, _YargsInstance_versionOpt, typeof opt === 'string' ? opt : defaultVersionOpt, "f");
955
+ msg = msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Show version number');
956
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(ver || undefined);
957
+ this.boolean(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
958
+ this.describe(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"), msg);
959
+ return this;
960
+ }
961
+ wrap(cols) {
962
+ argsert('<number|null|undefined>', [cols], arguments.length);
963
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
964
+ return this;
965
+ }
966
+ [(_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) {
967
+ if (!argv._ || !argv['--'])
968
+ return argv;
969
+ argv._.push.apply(argv._, argv['--']);
970
+ try {
971
+ delete argv['--'];
972
+ }
973
+ catch (_err) { }
974
+ return argv;
975
+ }
976
+ [kCreateLogger]() {
977
+ return {
978
+ log: (...args) => {
979
+ if (!this[kHasParseCallback]())
980
+ console.log(...args);
981
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
982
+ if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
983
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + '\n', "f");
984
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(' '), "f");
985
+ },
986
+ error: (...args) => {
987
+ if (!this[kHasParseCallback]())
988
+ console.error(...args);
989
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
990
+ if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
991
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + '\n', "f");
992
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(' '), "f");
993
+ },
994
+ };
995
+ }
996
+ [kDeleteFromParserHintObject](optionKey) {
997
+ objectKeys(__classPrivateFieldGet(this, _YargsInstance_options, "f")).forEach((hintKey) => {
998
+ if (((key) => key === 'configObjects')(hintKey))
999
+ return;
1000
+ const hint = __classPrivateFieldGet(this, _YargsInstance_options, "f")[hintKey];
1001
+ if (Array.isArray(hint)) {
1002
+ if (hint.includes(optionKey))
1003
+ hint.splice(hint.indexOf(optionKey), 1);
1004
+ }
1005
+ else if (typeof hint === 'object') {
1006
+ delete hint[optionKey];
1007
+ }
1008
+ });
1009
+ delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
1010
+ }
1011
+ [kEmitWarning](warning, type, deduplicationId) {
1012
+ if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) {
1013
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type);
1014
+ __classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true;
1015
+ }
1016
+ }
1017
+ [kFreeze]() {
1018
+ __classPrivateFieldGet(this, _YargsInstance_frozens, "f").push({
1019
+ options: __classPrivateFieldGet(this, _YargsInstance_options, "f"),
1020
+ configObjects: __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects.slice(0),
1021
+ exitProcess: __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"),
1022
+ groups: __classPrivateFieldGet(this, _YargsInstance_groups, "f"),
1023
+ strict: __classPrivateFieldGet(this, _YargsInstance_strict, "f"),
1024
+ strictCommands: __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"),
1025
+ strictOptions: __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"),
1026
+ completionCommand: __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"),
1027
+ output: __classPrivateFieldGet(this, _YargsInstance_output, "f"),
1028
+ exitError: __classPrivateFieldGet(this, _YargsInstance_exitError, "f"),
1029
+ hasOutput: __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"),
1030
+ parsed: this.parsed,
1031
+ parseFn: __classPrivateFieldGet(this, _YargsInstance_parseFn, "f"),
1032
+ parseContext: __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"),
1033
+ });
1034
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").freeze();
1035
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").freeze();
1036
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").freeze();
1037
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").freeze();
1038
+ }
1039
+ [kGetDollarZero]() {
1040
+ let $0 = '';
1041
+ let default$0;
1042
+ if (/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv()[0])) {
1043
+ default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(1, 2);
1044
+ }
1045
+ else {
1046
+ default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(0, 1);
1047
+ }
1048
+ $0 = default$0
1049
+ .map(x => {
1050
+ const b = this[kRebase](__classPrivateFieldGet(this, _YargsInstance_cwd, "f"), x);
1051
+ return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x;
1052
+ })
1053
+ .join(' ')
1054
+ .trim();
1055
+ if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('_') &&
1056
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").getProcessArgvBin() === __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('_')) {
1057
+ $0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f")
1058
+ .getEnv('_')
1059
+ .replace(`${__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.execPath())}/`, '');
1060
+ }
1061
+ return $0;
1062
+ }
1063
+ [kGetParserConfiguration]() {
1064
+ return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
1065
+ }
1066
+ [kGetUsageConfiguration]() {
1067
+ return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f");
1068
+ }
1069
+ [kGuessLocale]() {
1070
+ if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f"))
1071
+ return;
1072
+ const locale = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('LC_ALL') ||
1073
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('LC_MESSAGES') ||
1074
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('LANG') ||
1075
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('LANGUAGE') ||
1076
+ 'en_US';
1077
+ this.locale(locale.replace(/[.:].*/, ''));
1078
+ }
1079
+ [kGuessVersion]() {
1080
+ const obj = this[kPkgUp]();
1081
+ return obj.version || 'unknown';
1082
+ }
1083
+ [kParsePositionalNumbers](argv) {
1084
+ const args = argv['--'] ? argv['--'] : argv._;
1085
+ for (let i = 0, arg; (arg = args[i]) !== undefined; i++) {
1086
+ if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.looksLikeNumber(arg) &&
1087
+ Number.isSafeInteger(Math.floor(parseFloat(`${arg}`)))) {
1088
+ args[i] = Number(arg);
1089
+ }
1090
+ }
1091
+ return argv;
1092
+ }
1093
+ [kPkgUp](rootPath) {
1094
+ const npath = rootPath || '*';
1095
+ if (__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath])
1096
+ return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
1097
+ let obj = {};
1098
+ try {
1099
+ let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename;
1100
+ if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) {
1101
+ startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir);
1102
+ }
1103
+ const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names) => {
1104
+ if (names.includes('package.json')) {
1105
+ return 'package.json';
1106
+ }
1107
+ else {
1108
+ return undefined;
1109
+ }
1110
+ });
1111
+ assertNotStrictEqual(pkgJsonPath, undefined, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
1112
+ obj = JSON.parse(__classPrivateFieldGet(this, _YargsInstance_shim, "f").readFileSync(pkgJsonPath, 'utf8'));
1113
+ }
1114
+ catch (_noop) { }
1115
+ __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
1116
+ return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
1117
+ }
1118
+ [kPopulateParserHintArray](type, keys) {
1119
+ keys = [].concat(keys);
1120
+ keys.forEach(key => {
1121
+ key = this[kSanitizeKey](key);
1122
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type].push(key);
1123
+ });
1124
+ }
1125
+ [kPopulateParserHintSingleValueDictionary](builder, type, key, value) {
1126
+ this[kPopulateParserHintDictionary](builder, type, key, value, (type, key, value) => {
1127
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] = value;
1128
+ });
1129
+ }
1130
+ [kPopulateParserHintArrayDictionary](builder, type, key, value) {
1131
+ this[kPopulateParserHintDictionary](builder, type, key, value, (type, key, value) => {
1132
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] || []).concat(value);
1133
+ });
1134
+ }
1135
+ [kPopulateParserHintDictionary](builder, type, key, value, singleKeyHandler) {
1136
+ if (Array.isArray(key)) {
1137
+ key.forEach(k => {
1138
+ builder(k, value);
1139
+ });
1140
+ }
1141
+ else if (((key) => typeof key === 'object')(key)) {
1142
+ for (const k of objectKeys(key)) {
1143
+ builder(k, key[k]);
1144
+ }
1145
+ }
1146
+ else {
1147
+ singleKeyHandler(type, this[kSanitizeKey](key), value);
1148
+ }
1149
+ }
1150
+ [kSanitizeKey](key) {
1151
+ if (key === '__proto__')
1152
+ return '___proto___';
1153
+ return key;
1154
+ }
1155
+ [kSetKey](key, set) {
1156
+ this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), 'key', key, set);
1157
+ return this;
1158
+ }
1159
+ [kUnfreeze]() {
1160
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1161
+ const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
1162
+ assertNotStrictEqual(frozen, undefined, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
1163
+ let configObjects;
1164
+ (_a = this, _b = this, _c = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
1165
+ options: ({ set value(_o) { __classPrivateFieldSet(_a, _YargsInstance_options, _o, "f"); } }).value,
1166
+ configObjects,
1167
+ exitProcess: ({ set value(_o) { __classPrivateFieldSet(_b, _YargsInstance_exitProcess, _o, "f"); } }).value,
1168
+ groups: ({ set value(_o) { __classPrivateFieldSet(_c, _YargsInstance_groups, _o, "f"); } }).value,
1169
+ output: ({ set value(_o) { __classPrivateFieldSet(_d, _YargsInstance_output, _o, "f"); } }).value,
1170
+ exitError: ({ set value(_o) { __classPrivateFieldSet(_e, _YargsInstance_exitError, _o, "f"); } }).value,
1171
+ hasOutput: ({ set value(_o) { __classPrivateFieldSet(_f, _YargsInstance_hasOutput, _o, "f"); } }).value,
1172
+ parsed: this.parsed,
1173
+ strict: ({ set value(_o) { __classPrivateFieldSet(_g, _YargsInstance_strict, _o, "f"); } }).value,
1174
+ strictCommands: ({ set value(_o) { __classPrivateFieldSet(_h, _YargsInstance_strictCommands, _o, "f"); } }).value,
1175
+ strictOptions: ({ set value(_o) { __classPrivateFieldSet(_j, _YargsInstance_strictOptions, _o, "f"); } }).value,
1176
+ completionCommand: ({ set value(_o) { __classPrivateFieldSet(_k, _YargsInstance_completionCommand, _o, "f"); } }).value,
1177
+ parseFn: ({ set value(_o) { __classPrivateFieldSet(_l, _YargsInstance_parseFn, _o, "f"); } }).value,
1178
+ parseContext: ({ set value(_o) { __classPrivateFieldSet(_m, _YargsInstance_parseContext, _o, "f"); } }).value,
1179
+ } = frozen);
1180
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = configObjects;
1181
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").unfreeze();
1182
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").unfreeze();
1183
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").unfreeze();
1184
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").unfreeze();
1185
+ }
1186
+ [kValidateAsync](validation, argv) {
1187
+ return maybeAsyncResult(argv, result => {
1188
+ validation(result);
1189
+ return result;
1190
+ });
1191
+ }
1192
+ getInternalMethods() {
1193
+ return {
1194
+ getCommandInstance: this[kGetCommandInstance].bind(this),
1195
+ getContext: this[kGetContext].bind(this),
1196
+ getHasOutput: this[kGetHasOutput].bind(this),
1197
+ getLoggerInstance: this[kGetLoggerInstance].bind(this),
1198
+ getParseContext: this[kGetParseContext].bind(this),
1199
+ getParserConfiguration: this[kGetParserConfiguration].bind(this),
1200
+ getUsageConfiguration: this[kGetUsageConfiguration].bind(this),
1201
+ getUsageInstance: this[kGetUsageInstance].bind(this),
1202
+ getValidationInstance: this[kGetValidationInstance].bind(this),
1203
+ hasParseCallback: this[kHasParseCallback].bind(this),
1204
+ isGlobalContext: this[kIsGlobalContext].bind(this),
1205
+ postProcess: this[kPostProcess].bind(this),
1206
+ reset: this[kReset].bind(this),
1207
+ runValidation: this[kRunValidation].bind(this),
1208
+ runYargsParserAndExecuteCommands: this[kRunYargsParserAndExecuteCommands].bind(this),
1209
+ setHasOutput: this[kSetHasOutput].bind(this),
1210
+ };
1211
+ }
1212
+ [kGetCommandInstance]() {
1213
+ return __classPrivateFieldGet(this, _YargsInstance_command, "f");
1214
+ }
1215
+ [kGetContext]() {
1216
+ return __classPrivateFieldGet(this, _YargsInstance_context, "f");
1217
+ }
1218
+ [kGetHasOutput]() {
1219
+ return __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f");
1220
+ }
1221
+ [kGetLoggerInstance]() {
1222
+ return __classPrivateFieldGet(this, _YargsInstance_logger, "f");
1223
+ }
1224
+ [kGetParseContext]() {
1225
+ return __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") || {};
1226
+ }
1227
+ [kGetUsageInstance]() {
1228
+ return __classPrivateFieldGet(this, _YargsInstance_usage, "f");
1229
+ }
1230
+ [kGetValidationInstance]() {
1231
+ return __classPrivateFieldGet(this, _YargsInstance_validation, "f");
1232
+ }
1233
+ [kHasParseCallback]() {
1234
+ return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f");
1235
+ }
1236
+ [kIsGlobalContext]() {
1237
+ return __classPrivateFieldGet(this, _YargsInstance_isGlobalContext, "f");
1238
+ }
1239
+ [kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) {
1240
+ if (calledFromCommand)
1241
+ return argv;
1242
+ if (isPromise(argv))
1243
+ return argv;
1244
+ if (!populateDoubleDash) {
1245
+ argv = this[kCopyDoubleDash](argv);
1246
+ }
1247
+ const parsePositionalNumbers = this[kGetParserConfiguration]()['parse-positional-numbers'] ||
1248
+ this[kGetParserConfiguration]()['parse-positional-numbers'] === undefined;
1249
+ if (parsePositionalNumbers) {
1250
+ argv = this[kParsePositionalNumbers](argv);
1251
+ }
1252
+ if (runGlobalMiddleware) {
1253
+ argv = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
1254
+ }
1255
+ return argv;
1256
+ }
1257
+ [kReset](aliases = {}) {
1258
+ __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f") || {}, "f");
1259
+ const tmpOptions = {};
1260
+ tmpOptions.local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local || [];
1261
+ tmpOptions.configObjects = __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || [];
1262
+ const localLookup = {};
1263
+ tmpOptions.local.forEach(l => {
1264
+ localLookup[l] = true;
1265
+ (aliases[l] || []).forEach(a => {
1266
+ localLookup[a] = true;
1267
+ });
1268
+ });
1269
+ Object.assign(__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"), Object.keys(__classPrivateFieldGet(this, _YargsInstance_groups, "f")).reduce((acc, groupName) => {
1270
+ const keys = __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName].filter(key => !(key in localLookup));
1271
+ if (keys.length > 0) {
1272
+ acc[groupName] = keys;
1273
+ }
1274
+ return acc;
1275
+ }, {}));
1276
+ __classPrivateFieldSet(this, _YargsInstance_groups, {}, "f");
1277
+ const arrayOptions = [
1278
+ 'array',
1279
+ 'boolean',
1280
+ 'string',
1281
+ 'skipValidation',
1282
+ 'count',
1283
+ 'normalize',
1284
+ 'number',
1285
+ 'hiddenOptions',
1286
+ ];
1287
+ const objectOptions = [
1288
+ 'narg',
1289
+ 'key',
1290
+ 'alias',
1291
+ 'default',
1292
+ 'defaultDescription',
1293
+ 'config',
1294
+ 'choices',
1295
+ 'demandedOptions',
1296
+ 'demandedCommands',
1297
+ 'deprecatedOptions',
1298
+ ];
1299
+ arrayOptions.forEach(k => {
1300
+ tmpOptions[k] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[k] || []).filter((k) => !localLookup[k]);
1301
+ });
1302
+ objectOptions.forEach((k) => {
1303
+ tmpOptions[k] = objFilter(__classPrivateFieldGet(this, _YargsInstance_options, "f")[k], k => !localLookup[k]);
1304
+ });
1305
+ tmpOptions.envPrefix = __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
1306
+ __classPrivateFieldSet(this, _YargsInstance_options, tmpOptions, "f");
1307
+ __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f")
1308
+ ? __classPrivateFieldGet(this, _YargsInstance_usage, "f").reset(localLookup)
1309
+ : Usage(this, __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
1310
+ __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f")
1311
+ ? __classPrivateFieldGet(this, _YargsInstance_validation, "f").reset(localLookup)
1312
+ : Validation(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
1313
+ __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f")
1314
+ ? __classPrivateFieldGet(this, _YargsInstance_command, "f").reset()
1315
+ : Command(__classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_validation, "f"), __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
1316
+ if (!__classPrivateFieldGet(this, _YargsInstance_completion, "f"))
1317
+ __classPrivateFieldSet(this, _YargsInstance_completion, Completion(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_command, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
1318
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").reset();
1319
+ __classPrivateFieldSet(this, _YargsInstance_completionCommand, null, "f");
1320
+ __classPrivateFieldSet(this, _YargsInstance_output, '', "f");
1321
+ __classPrivateFieldSet(this, _YargsInstance_exitError, null, "f");
1322
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, false, "f");
1323
+ this.parsed = false;
1324
+ return this;
1325
+ }
1326
+ [kRebase](base, dir) {
1327
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.relative(base, dir);
1328
+ }
1329
+ [kRunYargsParserAndExecuteCommands](args, shortCircuit, calledFromCommand, commandIndex = 0, helpOnly = false) {
1330
+ var _a, _b, _c, _d;
1331
+ let skipValidation = !!calledFromCommand || helpOnly;
1332
+ args = args || __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
1333
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__;
1334
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration]();
1335
+ const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration['populate--'];
1336
+ const config = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, {
1337
+ 'populate--': true,
1338
+ });
1339
+ const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), {
1340
+ configuration: { 'parse-positional-numbers': false, ...config },
1341
+ }));
1342
+ const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"));
1343
+ let argvPromise = undefined;
1344
+ const aliases = parsed.aliases;
1345
+ let helpOptSet = false;
1346
+ let versionOptSet = false;
1347
+ Object.keys(argv).forEach(key => {
1348
+ if (key === __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f") && argv[key]) {
1349
+ helpOptSet = true;
1350
+ }
1351
+ else if (key === __classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && argv[key]) {
1352
+ versionOptSet = true;
1353
+ }
1354
+ });
1355
+ argv.$0 = this.$0;
1356
+ this.parsed = parsed;
1357
+ if (commandIndex === 0) {
1358
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").clearCachedHelpMessage();
1359
+ }
1360
+ try {
1361
+ this[kGuessLocale]();
1362
+ if (shortCircuit) {
1363
+ return this[kPostProcess](argv, populateDoubleDash, !!calledFromCommand, false);
1364
+ }
1365
+ if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
1366
+ const helpCmds = [__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")]
1367
+ .concat(aliases[__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")] || [])
1368
+ .filter(k => k.length > 1);
1369
+ if (helpCmds.includes('' + argv._[argv._.length - 1])) {
1370
+ argv._.pop();
1371
+ helpOptSet = true;
1372
+ }
1373
+ }
1374
+ __classPrivateFieldSet(this, _YargsInstance_isGlobalContext, false, "f");
1375
+ const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands();
1376
+ const requestCompletions = ((_a = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _a === void 0 ? void 0 : _a.completionKey)
1377
+ ? [
1378
+ (_b = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _b === void 0 ? void 0 : _b.completionKey,
1379
+ ...((_d = this.getAliases()[(_c = __classPrivateFieldGet(this, _YargsInstance_completion, "f")) === null || _c === void 0 ? void 0 : _c.completionKey]) !== null && _d !== void 0 ? _d : []),
1380
+ ].some((key) => Object.prototype.hasOwnProperty.call(argv, key))
1381
+ : false;
1382
+ const skipRecommendation = helpOptSet || requestCompletions || helpOnly;
1383
+ if (argv._.length) {
1384
+ if (handlerKeys.length) {
1385
+ let firstUnknownCommand;
1386
+ for (let i = commandIndex || 0, cmd; argv._[i] !== undefined; i++) {
1387
+ cmd = String(argv._[i]);
1388
+ if (handlerKeys.includes(cmd) && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
1389
+ const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(cmd, this, parsed, i + 1, helpOnly, helpOptSet || versionOptSet || helpOnly);
1390
+ return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
1391
+ }
1392
+ else if (!firstUnknownCommand &&
1393
+ cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
1394
+ firstUnknownCommand = cmd;
1395
+ break;
1396
+ }
1397
+ }
1398
+ if (!__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() &&
1399
+ __classPrivateFieldGet(this, _YargsInstance_recommendCommands, "f") &&
1400
+ firstUnknownCommand &&
1401
+ !skipRecommendation) {
1402
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").recommendCommands(firstUnknownCommand, handlerKeys);
1403
+ }
1404
+ }
1405
+ if (__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") &&
1406
+ argv._.includes(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) &&
1407
+ !requestCompletions) {
1408
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
1409
+ setBlocking(true);
1410
+ this.showCompletionScript();
1411
+ this.exit(0);
1412
+ }
1413
+ }
1414
+ if (__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && !skipRecommendation) {
1415
+ const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(null, this, parsed, 0, helpOnly, helpOptSet || versionOptSet || helpOnly);
1416
+ return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
1417
+ }
1418
+ if (requestCompletions) {
1419
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
1420
+ setBlocking(true);
1421
+ args = [].concat(args);
1422
+ const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey}`) + 1);
1423
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(completionArgs, (err, completions) => {
1424
+ if (err)
1425
+ throw new YError(err.message);
1426
+ (completions || []).forEach(completion => {
1427
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(completion);
1428
+ });
1429
+ this.exit(0);
1430
+ });
1431
+ return this[kPostProcess](argv, !populateDoubleDash, !!calledFromCommand, false);
1432
+ }
1433
+ if (!__classPrivateFieldGet(this, _YargsInstance_hasOutput, "f")) {
1434
+ if (helpOptSet) {
1435
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
1436
+ setBlocking(true);
1437
+ skipValidation = true;
1438
+ this.showHelp(message => {
1439
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(message);
1440
+ this.exit(0);
1441
+ });
1442
+ }
1443
+ else if (versionOptSet) {
1444
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
1445
+ setBlocking(true);
1446
+ skipValidation = true;
1447
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion('log');
1448
+ this.exit(0);
1449
+ }
1450
+ }
1451
+ if (!skipValidation && __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.length > 0) {
1452
+ skipValidation = Object.keys(argv).some(key => __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.indexOf(key) >= 0 && argv[key] === true);
1453
+ }
1454
+ if (!skipValidation) {
1455
+ if (parsed.error)
1456
+ throw new YError(parsed.error.message);
1457
+ if (!requestCompletions) {
1458
+ const validation = this[kRunValidation](aliases, {}, parsed.error);
1459
+ if (!calledFromCommand) {
1460
+ argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), true);
1461
+ }
1462
+ argvPromise = this[kValidateAsync](validation, argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv);
1463
+ if (isPromise(argvPromise) && !calledFromCommand) {
1464
+ argvPromise = argvPromise.then(() => {
1465
+ return applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
1466
+ });
1467
+ }
1468
+ }
1469
+ }
1470
+ }
1471
+ catch (err) {
1472
+ if (err instanceof YError)
1473
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message, err);
1474
+ else
1475
+ throw err;
1476
+ }
1477
+ return this[kPostProcess](argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv, populateDoubleDash, !!calledFromCommand, true);
1478
+ }
1479
+ [kRunValidation](aliases, positionalMap, parseErrors, isDefaultCommand) {
1480
+ const demandedOptions = { ...this.getDemandedOptions() };
1481
+ return (argv) => {
1482
+ if (parseErrors)
1483
+ throw new YError(parseErrors.message);
1484
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").nonOptionCount(argv);
1485
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").requiredArguments(argv, demandedOptions);
1486
+ let failedStrictCommands = false;
1487
+ if (__classPrivateFieldGet(this, _YargsInstance_strictCommands, "f")) {
1488
+ failedStrictCommands = __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownCommands(argv);
1489
+ }
1490
+ if (__classPrivateFieldGet(this, _YargsInstance_strict, "f") && !failedStrictCommands) {
1491
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, positionalMap, !!isDefaultCommand);
1492
+ }
1493
+ else if (__classPrivateFieldGet(this, _YargsInstance_strictOptions, "f")) {
1494
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, {}, false, false);
1495
+ }
1496
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").limitedChoices(argv);
1497
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").implications(argv);
1498
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicting(argv);
1499
+ };
1500
+ }
1501
+ [kSetHasOutput]() {
1502
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
1503
+ }
1504
+ [kTrackManuallySetKeys](keys) {
1505
+ if (typeof keys === 'string') {
1506
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
1507
+ }
1508
+ else {
1509
+ for (const k of keys) {
1510
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[k] = true;
1511
+ }
1512
+ }
1513
+ }
1514
+ }
1515
+ export function isYargsInstance(y) {
1516
+ return !!y && typeof y.getInternalMethods === 'function';
1517
+ }