source: trip-planner-front/node_modules/yargs/build/lib/yargs-factory.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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