yargs 17.0.1 → 17.1.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.
- package/CHANGELOG.md +16 -0
- package/build/index.cjs +1 -1
- package/build/lib/command.js +21 -27
- package/build/lib/completion.js +3 -2
- package/build/lib/middleware.js +9 -3
- package/build/lib/usage.js +17 -17
- package/build/lib/utils/levenshtein.js +9 -1
- package/build/lib/validation.js +21 -6
- package/build/lib/yargs-factory.js +358 -362
- package/locales/zh_TW.json +50 -46
- package/package.json +3 -3
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
2
|
-
if (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return value;
|
|
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;
|
|
7
6
|
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
9
|
-
if (!
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return privateMap.get(receiver);
|
|
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);
|
|
13
11
|
};
|
|
14
|
-
var
|
|
12
|
+
var _YargsInstance_command, _YargsInstance_cwd, _YargsInstance_context, _YargsInstance_completion, _YargsInstance_completionCommand, _YargsInstance_defaultShowHiddenOpt, _YargsInstance_exitError, _YargsInstance_detectLocale, _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;
|
|
15
13
|
import { command as Command, } from './command.js';
|
|
16
14
|
import { assertNotStrictEqual, assertSingleKey, objectKeys, } from './typings/common-types.js';
|
|
17
15
|
import { YError } from './yerror.js';
|
|
@@ -75,64 +73,64 @@ export class YargsInstance {
|
|
|
75
73
|
constructor(processArgs = [], cwd, parentRequire, shim) {
|
|
76
74
|
this.customScriptName = false;
|
|
77
75
|
this.parsed = false;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
__classPrivateFieldSet(this,
|
|
111
|
-
__classPrivateFieldSet(this,
|
|
112
|
-
__classPrivateFieldSet(this,
|
|
113
|
-
__classPrivateFieldSet(this,
|
|
114
|
-
__classPrivateFieldSet(this,
|
|
76
|
+
_YargsInstance_command.set(this, void 0);
|
|
77
|
+
_YargsInstance_cwd.set(this, void 0);
|
|
78
|
+
_YargsInstance_context.set(this, { commands: [], fullCommands: [] });
|
|
79
|
+
_YargsInstance_completion.set(this, null);
|
|
80
|
+
_YargsInstance_completionCommand.set(this, null);
|
|
81
|
+
_YargsInstance_defaultShowHiddenOpt.set(this, 'show-hidden');
|
|
82
|
+
_YargsInstance_exitError.set(this, null);
|
|
83
|
+
_YargsInstance_detectLocale.set(this, true);
|
|
84
|
+
_YargsInstance_exitProcess.set(this, true);
|
|
85
|
+
_YargsInstance_frozens.set(this, []);
|
|
86
|
+
_YargsInstance_globalMiddleware.set(this, void 0);
|
|
87
|
+
_YargsInstance_groups.set(this, {});
|
|
88
|
+
_YargsInstance_hasOutput.set(this, false);
|
|
89
|
+
_YargsInstance_helpOpt.set(this, null);
|
|
90
|
+
_YargsInstance_logger.set(this, void 0);
|
|
91
|
+
_YargsInstance_output.set(this, '');
|
|
92
|
+
_YargsInstance_options.set(this, void 0);
|
|
93
|
+
_YargsInstance_parentRequire.set(this, void 0);
|
|
94
|
+
_YargsInstance_parserConfig.set(this, {});
|
|
95
|
+
_YargsInstance_parseFn.set(this, null);
|
|
96
|
+
_YargsInstance_parseContext.set(this, null);
|
|
97
|
+
_YargsInstance_pkgs.set(this, {});
|
|
98
|
+
_YargsInstance_preservedGroups.set(this, {});
|
|
99
|
+
_YargsInstance_processArgs.set(this, void 0);
|
|
100
|
+
_YargsInstance_recommendCommands.set(this, false);
|
|
101
|
+
_YargsInstance_shim.set(this, void 0);
|
|
102
|
+
_YargsInstance_strict.set(this, false);
|
|
103
|
+
_YargsInstance_strictCommands.set(this, false);
|
|
104
|
+
_YargsInstance_strictOptions.set(this, false);
|
|
105
|
+
_YargsInstance_usage.set(this, void 0);
|
|
106
|
+
_YargsInstance_versionOpt.set(this, null);
|
|
107
|
+
_YargsInstance_validation.set(this, void 0);
|
|
108
|
+
__classPrivateFieldSet(this, _YargsInstance_shim, shim, "f");
|
|
109
|
+
__classPrivateFieldSet(this, _YargsInstance_processArgs, processArgs, "f");
|
|
110
|
+
__classPrivateFieldSet(this, _YargsInstance_cwd, cwd, "f");
|
|
111
|
+
__classPrivateFieldSet(this, _YargsInstance_parentRequire, parentRequire, "f");
|
|
112
|
+
__classPrivateFieldSet(this, _YargsInstance_globalMiddleware, new GlobalMiddleware(this), "f");
|
|
115
113
|
this.$0 = this[kGetDollarZero]();
|
|
116
114
|
this[kReset]();
|
|
117
|
-
__classPrivateFieldSet(this,
|
|
118
|
-
__classPrivateFieldSet(this,
|
|
119
|
-
__classPrivateFieldSet(this,
|
|
120
|
-
__classPrivateFieldSet(this,
|
|
121
|
-
__classPrivateFieldGet(this,
|
|
122
|
-
__classPrivateFieldSet(this,
|
|
115
|
+
__classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f"), "f");
|
|
116
|
+
__classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), "f");
|
|
117
|
+
__classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f"), "f");
|
|
118
|
+
__classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f"), "f");
|
|
119
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
|
|
120
|
+
__classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger](), "f");
|
|
123
121
|
}
|
|
124
122
|
addHelpOpt(opt, msg) {
|
|
125
123
|
const defaultHelpOpt = 'help';
|
|
126
124
|
argsert('[string|boolean] [string]', [opt, msg], arguments.length);
|
|
127
|
-
if (__classPrivateFieldGet(this,
|
|
128
|
-
this[kDeleteFromParserHintObject](__classPrivateFieldGet(this,
|
|
129
|
-
__classPrivateFieldSet(this,
|
|
125
|
+
if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
|
|
126
|
+
this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
|
|
127
|
+
__classPrivateFieldSet(this, _YargsInstance_helpOpt, null, "f");
|
|
130
128
|
}
|
|
131
129
|
if (opt === false && msg === undefined)
|
|
132
130
|
return this;
|
|
133
|
-
__classPrivateFieldSet(this,
|
|
134
|
-
this.boolean(__classPrivateFieldGet(this,
|
|
135
|
-
this.describe(__classPrivateFieldGet(this,
|
|
131
|
+
__classPrivateFieldSet(this, _YargsInstance_helpOpt, typeof opt === 'string' ? opt : defaultHelpOpt, "f");
|
|
132
|
+
this.boolean(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
|
|
133
|
+
this.describe(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"), msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Show help'));
|
|
136
134
|
return this;
|
|
137
135
|
}
|
|
138
136
|
help(opt, msg) {
|
|
@@ -142,10 +140,10 @@ export class YargsInstance {
|
|
|
142
140
|
argsert('[string|boolean] [string]', [opt, msg], arguments.length);
|
|
143
141
|
if (opt === false && msg === undefined)
|
|
144
142
|
return this;
|
|
145
|
-
const showHiddenOpt = typeof opt === 'string' ? opt : __classPrivateFieldGet(this,
|
|
143
|
+
const showHiddenOpt = typeof opt === 'string' ? opt : __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
|
|
146
144
|
this.boolean(showHiddenOpt);
|
|
147
|
-
this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this,
|
|
148
|
-
__classPrivateFieldGet(this,
|
|
145
|
+
this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Show hidden options'));
|
|
146
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = showHiddenOpt;
|
|
149
147
|
return this;
|
|
150
148
|
}
|
|
151
149
|
showHidden(opt, msg) {
|
|
@@ -173,14 +171,14 @@ export class YargsInstance {
|
|
|
173
171
|
return f(argv);
|
|
174
172
|
}, (result) => {
|
|
175
173
|
if (!result) {
|
|
176
|
-
__classPrivateFieldGet(this,
|
|
174
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__('Argument check failed: %s', f.toString()));
|
|
177
175
|
}
|
|
178
176
|
else if (typeof result === 'string' || result instanceof Error) {
|
|
179
|
-
__classPrivateFieldGet(this,
|
|
177
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(result.toString(), result);
|
|
180
178
|
}
|
|
181
179
|
return argv;
|
|
182
180
|
}, (err) => {
|
|
183
|
-
__classPrivateFieldGet(this,
|
|
181
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message ? err.message : err.toString(), err);
|
|
184
182
|
return argv;
|
|
185
183
|
});
|
|
186
184
|
}, false, global);
|
|
@@ -211,8 +209,8 @@ export class YargsInstance {
|
|
|
211
209
|
if (!value) {
|
|
212
210
|
throw new YError('coerce callback must be provided');
|
|
213
211
|
}
|
|
214
|
-
__classPrivateFieldGet(this,
|
|
215
|
-
__classPrivateFieldGet(this,
|
|
212
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
|
|
213
|
+
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
|
|
216
214
|
let aliases;
|
|
217
215
|
return maybeAsyncResult(() => {
|
|
218
216
|
aliases = yargs.getAliases();
|
|
@@ -233,23 +231,23 @@ export class YargsInstance {
|
|
|
233
231
|
}
|
|
234
232
|
conflicts(key1, key2) {
|
|
235
233
|
argsert('<string|object> [string|array]', [key1, key2], arguments.length);
|
|
236
|
-
__classPrivateFieldGet(this,
|
|
234
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicts(key1, key2);
|
|
237
235
|
return this;
|
|
238
236
|
}
|
|
239
237
|
config(key = 'config', msg, parseFn) {
|
|
240
238
|
argsert('[object|string] [string|function] [function]', [key, msg, parseFn], arguments.length);
|
|
241
239
|
if (typeof key === 'object' && !Array.isArray(key)) {
|
|
242
|
-
key = applyExtends(key, __classPrivateFieldGet(this,
|
|
243
|
-
__classPrivateFieldGet(this,
|
|
240
|
+
key = applyExtends(key, __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()['deep-merge-config'] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
241
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(key);
|
|
244
242
|
return this;
|
|
245
243
|
}
|
|
246
244
|
if (typeof msg === 'function') {
|
|
247
245
|
parseFn = msg;
|
|
248
246
|
msg = undefined;
|
|
249
247
|
}
|
|
250
|
-
this.describe(key, msg || __classPrivateFieldGet(this,
|
|
248
|
+
this.describe(key, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Path to JSON config file'));
|
|
251
249
|
(Array.isArray(key) ? key : [key]).forEach(k => {
|
|
252
|
-
__classPrivateFieldGet(this,
|
|
250
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").config[k] = parseFn || true;
|
|
253
251
|
});
|
|
254
252
|
return this;
|
|
255
253
|
}
|
|
@@ -259,18 +257,18 @@ export class YargsInstance {
|
|
|
259
257
|
fn = desc;
|
|
260
258
|
desc = undefined;
|
|
261
259
|
}
|
|
262
|
-
__classPrivateFieldSet(this,
|
|
260
|
+
__classPrivateFieldSet(this, _YargsInstance_completionCommand, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || 'completion', "f");
|
|
263
261
|
if (!desc && desc !== false) {
|
|
264
262
|
desc = 'generate completion script';
|
|
265
263
|
}
|
|
266
|
-
this.command(__classPrivateFieldGet(this,
|
|
264
|
+
this.command(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), desc);
|
|
267
265
|
if (fn)
|
|
268
|
-
__classPrivateFieldGet(this,
|
|
266
|
+
__classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn);
|
|
269
267
|
return this;
|
|
270
268
|
}
|
|
271
269
|
command(cmd, description, builder, handler, middlewares, deprecated) {
|
|
272
270
|
argsert('<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]', [cmd, description, builder, handler, middlewares, deprecated], arguments.length);
|
|
273
|
-
__classPrivateFieldGet(this,
|
|
271
|
+
__classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description, builder, handler, middlewares, deprecated);
|
|
274
272
|
return this;
|
|
275
273
|
}
|
|
276
274
|
commands(cmd, description, builder, handler, middlewares, deprecated) {
|
|
@@ -278,8 +276,8 @@ export class YargsInstance {
|
|
|
278
276
|
}
|
|
279
277
|
commandDir(dir, opts) {
|
|
280
278
|
argsert('<string> [object]', [dir, opts], arguments.length);
|
|
281
|
-
const req = __classPrivateFieldGet(this,
|
|
282
|
-
__classPrivateFieldGet(this,
|
|
279
|
+
const req = __classPrivateFieldGet(this, _YargsInstance_parentRequire, "f") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").require;
|
|
280
|
+
__classPrivateFieldGet(this, _YargsInstance_command, "f").addDirectory(dir, req, __classPrivateFieldGet(this, _YargsInstance_shim, "f").getCallerFile(), opts);
|
|
283
281
|
return this;
|
|
284
282
|
}
|
|
285
283
|
count(keys) {
|
|
@@ -290,13 +288,14 @@ export class YargsInstance {
|
|
|
290
288
|
default(key, value, defaultDescription) {
|
|
291
289
|
argsert('<object|string|array> [*] [string]', [key, value, defaultDescription], arguments.length);
|
|
292
290
|
if (defaultDescription) {
|
|
293
|
-
assertSingleKey(key, __classPrivateFieldGet(this,
|
|
294
|
-
__classPrivateFieldGet(this,
|
|
291
|
+
assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
292
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = defaultDescription;
|
|
295
293
|
}
|
|
296
294
|
if (typeof value === 'function') {
|
|
297
|
-
assertSingleKey(key, __classPrivateFieldGet(this,
|
|
298
|
-
if (!__classPrivateFieldGet(this,
|
|
299
|
-
__classPrivateFieldGet(this,
|
|
295
|
+
assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
296
|
+
if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key])
|
|
297
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] =
|
|
298
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").functionDescription(value);
|
|
300
299
|
value = value.call();
|
|
301
300
|
}
|
|
302
301
|
this[kPopulateParserHintSingleValueDictionary](this.default.bind(this), 'default', key, value);
|
|
@@ -312,7 +311,7 @@ export class YargsInstance {
|
|
|
312
311
|
max = Infinity;
|
|
313
312
|
}
|
|
314
313
|
this.global('_', false);
|
|
315
|
-
__classPrivateFieldGet(this,
|
|
314
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands._ = {
|
|
316
315
|
min,
|
|
317
316
|
max,
|
|
318
317
|
minMsg,
|
|
@@ -323,7 +322,7 @@ export class YargsInstance {
|
|
|
323
322
|
demand(keys, max, msg) {
|
|
324
323
|
if (Array.isArray(max)) {
|
|
325
324
|
max.forEach(key => {
|
|
326
|
-
assertNotStrictEqual(msg, true, __classPrivateFieldGet(this,
|
|
325
|
+
assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
327
326
|
this.demandOption(key, msg);
|
|
328
327
|
});
|
|
329
328
|
max = Infinity;
|
|
@@ -333,12 +332,12 @@ export class YargsInstance {
|
|
|
333
332
|
max = Infinity;
|
|
334
333
|
}
|
|
335
334
|
if (typeof keys === 'number') {
|
|
336
|
-
assertNotStrictEqual(msg, true, __classPrivateFieldGet(this,
|
|
335
|
+
assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
337
336
|
this.demandCommand(keys, max, msg, msg);
|
|
338
337
|
}
|
|
339
338
|
else if (Array.isArray(keys)) {
|
|
340
339
|
keys.forEach(key => {
|
|
341
|
-
assertNotStrictEqual(msg, true, __classPrivateFieldGet(this,
|
|
340
|
+
assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
342
341
|
this.demandOption(key, msg);
|
|
343
342
|
});
|
|
344
343
|
}
|
|
@@ -359,31 +358,31 @@ export class YargsInstance {
|
|
|
359
358
|
}
|
|
360
359
|
deprecateOption(option, message) {
|
|
361
360
|
argsert('<string> [string|boolean]', [option, message], arguments.length);
|
|
362
|
-
__classPrivateFieldGet(this,
|
|
361
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message;
|
|
363
362
|
return this;
|
|
364
363
|
}
|
|
365
364
|
describe(keys, description) {
|
|
366
365
|
argsert('<object|string|array> [string]', [keys, description], arguments.length);
|
|
367
366
|
this[kSetKey](keys, true);
|
|
368
|
-
__classPrivateFieldGet(this,
|
|
367
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description);
|
|
369
368
|
return this;
|
|
370
369
|
}
|
|
371
370
|
detectLocale(detect) {
|
|
372
371
|
argsert('<boolean>', [detect], arguments.length);
|
|
373
|
-
__classPrivateFieldSet(this,
|
|
372
|
+
__classPrivateFieldSet(this, _YargsInstance_detectLocale, detect, "f");
|
|
374
373
|
return this;
|
|
375
374
|
}
|
|
376
375
|
env(prefix) {
|
|
377
376
|
argsert('[string|boolean]', [prefix], arguments.length);
|
|
378
377
|
if (prefix === false)
|
|
379
|
-
delete __classPrivateFieldGet(this,
|
|
378
|
+
delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
|
|
380
379
|
else
|
|
381
|
-
__classPrivateFieldGet(this,
|
|
380
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix || '';
|
|
382
381
|
return this;
|
|
383
382
|
}
|
|
384
383
|
epilogue(msg) {
|
|
385
384
|
argsert('<string>', [msg], arguments.length);
|
|
386
|
-
__classPrivateFieldGet(this,
|
|
385
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").epilog(msg);
|
|
387
386
|
return this;
|
|
388
387
|
}
|
|
389
388
|
epilog(msg) {
|
|
@@ -395,19 +394,19 @@ export class YargsInstance {
|
|
|
395
394
|
cmd.forEach(exampleParams => this.example(...exampleParams));
|
|
396
395
|
}
|
|
397
396
|
else {
|
|
398
|
-
__classPrivateFieldGet(this,
|
|
397
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description);
|
|
399
398
|
}
|
|
400
399
|
return this;
|
|
401
400
|
}
|
|
402
401
|
exit(code, err) {
|
|
403
|
-
__classPrivateFieldSet(this,
|
|
404
|
-
__classPrivateFieldSet(this,
|
|
405
|
-
if (__classPrivateFieldGet(this,
|
|
406
|
-
__classPrivateFieldGet(this,
|
|
402
|
+
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
|
403
|
+
__classPrivateFieldSet(this, _YargsInstance_exitError, err, "f");
|
|
404
|
+
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
|
405
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.exit(code);
|
|
407
406
|
}
|
|
408
407
|
exitProcess(enabled = true) {
|
|
409
408
|
argsert('[boolean]', [enabled], arguments.length);
|
|
410
|
-
__classPrivateFieldSet(this,
|
|
409
|
+
__classPrivateFieldSet(this, _YargsInstance_exitProcess, enabled, "f");
|
|
411
410
|
return this;
|
|
412
411
|
}
|
|
413
412
|
fail(f) {
|
|
@@ -415,7 +414,7 @@ export class YargsInstance {
|
|
|
415
414
|
if (typeof f === 'boolean' && f !== false) {
|
|
416
415
|
throw new YError("Invalid first argument. Expected function or boolean 'false'");
|
|
417
416
|
}
|
|
418
|
-
__classPrivateFieldGet(this,
|
|
417
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").failFn(f);
|
|
419
418
|
return this;
|
|
420
419
|
}
|
|
421
420
|
getAliases() {
|
|
@@ -425,7 +424,7 @@ export class YargsInstance {
|
|
|
425
424
|
argsert('<array> [function]', [args, done], arguments.length);
|
|
426
425
|
if (!done) {
|
|
427
426
|
return new Promise((resolve, reject) => {
|
|
428
|
-
__classPrivateFieldGet(this,
|
|
427
|
+
__classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
|
|
429
428
|
if (err)
|
|
430
429
|
reject(err);
|
|
431
430
|
else
|
|
@@ -434,84 +433,84 @@ export class YargsInstance {
|
|
|
434
433
|
});
|
|
435
434
|
}
|
|
436
435
|
else {
|
|
437
|
-
return __classPrivateFieldGet(this,
|
|
436
|
+
return __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, done);
|
|
438
437
|
}
|
|
439
438
|
}
|
|
440
439
|
getDemandedOptions() {
|
|
441
440
|
argsert([], 0);
|
|
442
|
-
return __classPrivateFieldGet(this,
|
|
441
|
+
return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedOptions;
|
|
443
442
|
}
|
|
444
443
|
getDemandedCommands() {
|
|
445
444
|
argsert([], 0);
|
|
446
|
-
return __classPrivateFieldGet(this,
|
|
445
|
+
return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands;
|
|
447
446
|
}
|
|
448
447
|
getDeprecatedOptions() {
|
|
449
448
|
argsert([], 0);
|
|
450
|
-
return __classPrivateFieldGet(this,
|
|
449
|
+
return __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions;
|
|
451
450
|
}
|
|
452
451
|
getDetectLocale() {
|
|
453
|
-
return __classPrivateFieldGet(this,
|
|
452
|
+
return __classPrivateFieldGet(this, _YargsInstance_detectLocale, "f");
|
|
454
453
|
}
|
|
455
454
|
getExitProcess() {
|
|
456
|
-
return __classPrivateFieldGet(this,
|
|
455
|
+
return __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f");
|
|
457
456
|
}
|
|
458
457
|
getGroups() {
|
|
459
|
-
return Object.assign({}, __classPrivateFieldGet(this,
|
|
458
|
+
return Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_groups, "f"), __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"));
|
|
460
459
|
}
|
|
461
460
|
getHelp() {
|
|
462
|
-
__classPrivateFieldSet(this,
|
|
463
|
-
if (!__classPrivateFieldGet(this,
|
|
461
|
+
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
|
462
|
+
if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
|
|
464
463
|
if (!this.parsed) {
|
|
465
|
-
const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this,
|
|
464
|
+
const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), undefined, undefined, 0, true);
|
|
466
465
|
if (isPromise(parse)) {
|
|
467
466
|
return parse.then(() => {
|
|
468
|
-
return __classPrivateFieldGet(this,
|
|
467
|
+
return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
|
|
469
468
|
});
|
|
470
469
|
}
|
|
471
470
|
}
|
|
472
|
-
const builderResponse = __classPrivateFieldGet(this,
|
|
471
|
+
const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
|
|
473
472
|
if (isPromise(builderResponse)) {
|
|
474
473
|
return builderResponse.then(() => {
|
|
475
|
-
return __classPrivateFieldGet(this,
|
|
474
|
+
return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
|
|
476
475
|
});
|
|
477
476
|
}
|
|
478
477
|
}
|
|
479
|
-
return Promise.resolve(__classPrivateFieldGet(this,
|
|
478
|
+
return Promise.resolve(__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
|
|
480
479
|
}
|
|
481
480
|
getOptions() {
|
|
482
|
-
return __classPrivateFieldGet(this,
|
|
481
|
+
return __classPrivateFieldGet(this, _YargsInstance_options, "f");
|
|
483
482
|
}
|
|
484
483
|
getStrict() {
|
|
485
|
-
return __classPrivateFieldGet(this,
|
|
484
|
+
return __classPrivateFieldGet(this, _YargsInstance_strict, "f");
|
|
486
485
|
}
|
|
487
486
|
getStrictCommands() {
|
|
488
|
-
return __classPrivateFieldGet(this,
|
|
487
|
+
return __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f");
|
|
489
488
|
}
|
|
490
489
|
getStrictOptions() {
|
|
491
|
-
return __classPrivateFieldGet(this,
|
|
490
|
+
return __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f");
|
|
492
491
|
}
|
|
493
492
|
global(globals, global) {
|
|
494
493
|
argsert('<string|array> [boolean]', [globals, global], arguments.length);
|
|
495
494
|
globals = [].concat(globals);
|
|
496
495
|
if (global !== false) {
|
|
497
|
-
__classPrivateFieldGet(this,
|
|
496
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local.filter(l => globals.indexOf(l) === -1);
|
|
498
497
|
}
|
|
499
498
|
else {
|
|
500
499
|
globals.forEach(g => {
|
|
501
|
-
if (__classPrivateFieldGet(this,
|
|
502
|
-
__classPrivateFieldGet(this,
|
|
500
|
+
if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").local.includes(g))
|
|
501
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").local.push(g);
|
|
503
502
|
});
|
|
504
503
|
}
|
|
505
504
|
return this;
|
|
506
505
|
}
|
|
507
506
|
group(opts, groupName) {
|
|
508
507
|
argsert('<string|array> <string>', [opts, groupName], arguments.length);
|
|
509
|
-
const existing = __classPrivateFieldGet(this,
|
|
510
|
-
if (__classPrivateFieldGet(this,
|
|
511
|
-
delete __classPrivateFieldGet(this,
|
|
508
|
+
const existing = __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName] || __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName];
|
|
509
|
+
if (__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]) {
|
|
510
|
+
delete __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName];
|
|
512
511
|
}
|
|
513
512
|
const seen = {};
|
|
514
|
-
__classPrivateFieldGet(this,
|
|
513
|
+
__classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName] = (existing || []).concat(opts).filter(key => {
|
|
515
514
|
if (seen[key])
|
|
516
515
|
return false;
|
|
517
516
|
return (seen[key] = true);
|
|
@@ -520,26 +519,26 @@ export class YargsInstance {
|
|
|
520
519
|
}
|
|
521
520
|
hide(key) {
|
|
522
521
|
argsert('<string>', [key], arguments.length);
|
|
523
|
-
__classPrivateFieldGet(this,
|
|
522
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").hiddenOptions.push(key);
|
|
524
523
|
return this;
|
|
525
524
|
}
|
|
526
525
|
implies(key, value) {
|
|
527
526
|
argsert('<string|object> [number|string|array]', [key, value], arguments.length);
|
|
528
|
-
__classPrivateFieldGet(this,
|
|
527
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").implies(key, value);
|
|
529
528
|
return this;
|
|
530
529
|
}
|
|
531
530
|
locale(locale) {
|
|
532
531
|
argsert('[string]', [locale], arguments.length);
|
|
533
532
|
if (!locale) {
|
|
534
533
|
this[kGuessLocale]();
|
|
535
|
-
return __classPrivateFieldGet(this,
|
|
534
|
+
return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
|
|
536
535
|
}
|
|
537
|
-
__classPrivateFieldSet(this,
|
|
538
|
-
__classPrivateFieldGet(this,
|
|
536
|
+
__classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
|
|
537
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(locale);
|
|
539
538
|
return this;
|
|
540
539
|
}
|
|
541
540
|
middleware(callback, applyBeforeValidation, global) {
|
|
542
|
-
return __classPrivateFieldGet(this,
|
|
541
|
+
return __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addMiddleware(callback, !!applyBeforeValidation, global);
|
|
543
542
|
}
|
|
544
543
|
nargs(key, value) {
|
|
545
544
|
argsert('<string|object|array> [number]', [key, value], arguments.length);
|
|
@@ -567,7 +566,7 @@ export class YargsInstance {
|
|
|
567
566
|
if (typeof opt !== 'object') {
|
|
568
567
|
opt = {};
|
|
569
568
|
}
|
|
570
|
-
__classPrivateFieldGet(this,
|
|
569
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").key[key] = true;
|
|
571
570
|
if (opt.alias)
|
|
572
571
|
this.alias(key, opt.alias);
|
|
573
572
|
const deprecate = opt.deprecate || opt.deprecated;
|
|
@@ -635,7 +634,7 @@ export class YargsInstance {
|
|
|
635
634
|
this.global(key, opt.global);
|
|
636
635
|
}
|
|
637
636
|
if (opt.defaultDescription) {
|
|
638
|
-
__classPrivateFieldGet(this,
|
|
637
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = opt.defaultDescription;
|
|
639
638
|
}
|
|
640
639
|
if (opt.skipValidation) {
|
|
641
640
|
this.skipValidation(key);
|
|
@@ -658,33 +657,33 @@ export class YargsInstance {
|
|
|
658
657
|
argsert('[string|array] [function|boolean|object] [function]', [args, shortCircuit, _parseFn], arguments.length);
|
|
659
658
|
this[kFreeze]();
|
|
660
659
|
if (typeof args === 'undefined') {
|
|
661
|
-
args = __classPrivateFieldGet(this,
|
|
660
|
+
args = __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
|
|
662
661
|
}
|
|
663
662
|
if (typeof shortCircuit === 'object') {
|
|
664
|
-
__classPrivateFieldSet(this,
|
|
663
|
+
__classPrivateFieldSet(this, _YargsInstance_parseContext, shortCircuit, "f");
|
|
665
664
|
shortCircuit = _parseFn;
|
|
666
665
|
}
|
|
667
666
|
if (typeof shortCircuit === 'function') {
|
|
668
|
-
__classPrivateFieldSet(this,
|
|
667
|
+
__classPrivateFieldSet(this, _YargsInstance_parseFn, shortCircuit, "f");
|
|
669
668
|
shortCircuit = false;
|
|
670
669
|
}
|
|
671
670
|
if (!shortCircuit)
|
|
672
|
-
__classPrivateFieldSet(this,
|
|
673
|
-
if (__classPrivateFieldGet(this,
|
|
674
|
-
__classPrivateFieldSet(this,
|
|
671
|
+
__classPrivateFieldSet(this, _YargsInstance_processArgs, args, "f");
|
|
672
|
+
if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
|
|
673
|
+
__classPrivateFieldSet(this, _YargsInstance_exitProcess, false, "f");
|
|
675
674
|
const parsed = this[kRunYargsParserAndExecuteCommands](args, !!shortCircuit);
|
|
676
675
|
const tmpParsed = this.parsed;
|
|
677
|
-
__classPrivateFieldGet(this,
|
|
676
|
+
__classPrivateFieldGet(this, _YargsInstance_completion, "f").setParsed(this.parsed);
|
|
678
677
|
if (isPromise(parsed)) {
|
|
679
678
|
return parsed
|
|
680
679
|
.then(argv => {
|
|
681
|
-
if (__classPrivateFieldGet(this,
|
|
682
|
-
__classPrivateFieldGet(this,
|
|
680
|
+
if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
|
|
681
|
+
__classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
|
|
683
682
|
return argv;
|
|
684
683
|
})
|
|
685
684
|
.catch(err => {
|
|
686
|
-
if (__classPrivateFieldGet(this,
|
|
687
|
-
__classPrivateFieldGet(this,
|
|
685
|
+
if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) {
|
|
686
|
+
__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")(err, this.parsed.argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
|
|
688
687
|
}
|
|
689
688
|
throw err;
|
|
690
689
|
})
|
|
@@ -694,8 +693,8 @@ export class YargsInstance {
|
|
|
694
693
|
});
|
|
695
694
|
}
|
|
696
695
|
else {
|
|
697
|
-
if (__classPrivateFieldGet(this,
|
|
698
|
-
__classPrivateFieldGet(this,
|
|
696
|
+
if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
|
|
697
|
+
__classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), parsed, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
|
|
699
698
|
this[kUnfreeze]();
|
|
700
699
|
this.parsed = tmpParsed;
|
|
701
700
|
}
|
|
@@ -703,12 +702,9 @@ export class YargsInstance {
|
|
|
703
702
|
}
|
|
704
703
|
parseAsync(args, shortCircuit, _parseFn) {
|
|
705
704
|
const maybePromise = this.parse(args, shortCircuit, _parseFn);
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
else {
|
|
710
|
-
return maybePromise;
|
|
711
|
-
}
|
|
705
|
+
return !isPromise(maybePromise)
|
|
706
|
+
? Promise.resolve(maybePromise)
|
|
707
|
+
: maybePromise;
|
|
712
708
|
}
|
|
713
709
|
parseSync(args, shortCircuit, _parseFn) {
|
|
714
710
|
const maybePromise = this.parse(args, shortCircuit, _parseFn);
|
|
@@ -719,16 +715,16 @@ export class YargsInstance {
|
|
|
719
715
|
}
|
|
720
716
|
parserConfiguration(config) {
|
|
721
717
|
argsert('<object>', [config], arguments.length);
|
|
722
|
-
__classPrivateFieldSet(this,
|
|
718
|
+
__classPrivateFieldSet(this, _YargsInstance_parserConfig, config, "f");
|
|
723
719
|
return this;
|
|
724
720
|
}
|
|
725
721
|
pkgConf(key, rootPath) {
|
|
726
722
|
argsert('<string> [string]', [key, rootPath], arguments.length);
|
|
727
723
|
let conf = null;
|
|
728
|
-
const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this,
|
|
724
|
+
const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"));
|
|
729
725
|
if (obj[key] && typeof obj[key] === 'object') {
|
|
730
|
-
conf = applyExtends(obj[key], rootPath || __classPrivateFieldGet(this,
|
|
731
|
-
__classPrivateFieldGet(this,
|
|
726
|
+
conf = applyExtends(obj[key], rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()['deep-merge-config'] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
727
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(conf);
|
|
732
728
|
}
|
|
733
729
|
return this;
|
|
734
730
|
}
|
|
@@ -749,14 +745,13 @@ export class YargsInstance {
|
|
|
749
745
|
'alias',
|
|
750
746
|
];
|
|
751
747
|
opts = objFilter(opts, (k, v) => {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
return accept;
|
|
748
|
+
if (k === 'type' && !['string', 'number', 'boolean'].includes(v))
|
|
749
|
+
return false;
|
|
750
|
+
return supportedOpts.includes(k);
|
|
756
751
|
});
|
|
757
|
-
const fullCommand = __classPrivateFieldGet(this,
|
|
752
|
+
const fullCommand = __classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands[__classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands.length - 1];
|
|
758
753
|
const parseOptions = fullCommand
|
|
759
|
-
? __classPrivateFieldGet(this,
|
|
754
|
+
? __classPrivateFieldGet(this, _YargsInstance_command, "f").cmdToParseOptions(fullCommand)
|
|
760
755
|
: {
|
|
761
756
|
array: [],
|
|
762
757
|
alias: {},
|
|
@@ -774,12 +769,12 @@ export class YargsInstance {
|
|
|
774
769
|
opts[pk] = parseOption[key];
|
|
775
770
|
}
|
|
776
771
|
});
|
|
777
|
-
this.group(key, __classPrivateFieldGet(this,
|
|
772
|
+
this.group(key, __classPrivateFieldGet(this, _YargsInstance_usage, "f").getPositionalGroupName());
|
|
778
773
|
return this.option(key, opts);
|
|
779
774
|
}
|
|
780
775
|
recommendCommands(recommend = true) {
|
|
781
776
|
argsert('[boolean]', [recommend], arguments.length);
|
|
782
|
-
__classPrivateFieldSet(this,
|
|
777
|
+
__classPrivateFieldSet(this, _YargsInstance_recommendCommands, recommend, "f");
|
|
783
778
|
return this;
|
|
784
779
|
}
|
|
785
780
|
required(keys, max, msg) {
|
|
@@ -790,7 +785,7 @@ export class YargsInstance {
|
|
|
790
785
|
}
|
|
791
786
|
requiresArg(keys) {
|
|
792
787
|
argsert('<array|string|object> [number]', [keys], arguments.length);
|
|
793
|
-
if (typeof keys === 'string' && __classPrivateFieldGet(this,
|
|
788
|
+
if (typeof keys === 'string' && __classPrivateFieldGet(this, _YargsInstance_options, "f").narg[keys]) {
|
|
794
789
|
return this;
|
|
795
790
|
}
|
|
796
791
|
else {
|
|
@@ -801,31 +796,31 @@ export class YargsInstance {
|
|
|
801
796
|
showCompletionScript($0, cmd) {
|
|
802
797
|
argsert('[string] [string]', [$0, cmd], arguments.length);
|
|
803
798
|
$0 = $0 || this.$0;
|
|
804
|
-
__classPrivateFieldGet(this,
|
|
799
|
+
__classPrivateFieldGet(this, _YargsInstance_logger, "f").log(__classPrivateFieldGet(this, _YargsInstance_completion, "f").generateCompletionScript($0, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || 'completion'));
|
|
805
800
|
return this;
|
|
806
801
|
}
|
|
807
802
|
showHelp(level) {
|
|
808
803
|
argsert('[string|function]', [level], arguments.length);
|
|
809
|
-
__classPrivateFieldSet(this,
|
|
810
|
-
if (!__classPrivateFieldGet(this,
|
|
804
|
+
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
|
805
|
+
if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
|
|
811
806
|
if (!this.parsed) {
|
|
812
|
-
const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this,
|
|
807
|
+
const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), undefined, undefined, 0, true);
|
|
813
808
|
if (isPromise(parse)) {
|
|
814
809
|
parse.then(() => {
|
|
815
|
-
__classPrivateFieldGet(this,
|
|
810
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
|
|
816
811
|
});
|
|
817
812
|
return this;
|
|
818
813
|
}
|
|
819
814
|
}
|
|
820
|
-
const builderResponse = __classPrivateFieldGet(this,
|
|
815
|
+
const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
|
|
821
816
|
if (isPromise(builderResponse)) {
|
|
822
817
|
builderResponse.then(() => {
|
|
823
|
-
__classPrivateFieldGet(this,
|
|
818
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
|
|
824
819
|
});
|
|
825
820
|
return this;
|
|
826
821
|
}
|
|
827
822
|
}
|
|
828
|
-
__classPrivateFieldGet(this,
|
|
823
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
|
|
829
824
|
return this;
|
|
830
825
|
}
|
|
831
826
|
scriptName(scriptName) {
|
|
@@ -835,12 +830,12 @@ export class YargsInstance {
|
|
|
835
830
|
}
|
|
836
831
|
showHelpOnFail(enabled, message) {
|
|
837
832
|
argsert('[boolean|string] [string]', [enabled, message], arguments.length);
|
|
838
|
-
__classPrivateFieldGet(this,
|
|
833
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelpOnFail(enabled, message);
|
|
839
834
|
return this;
|
|
840
835
|
}
|
|
841
836
|
showVersion(level) {
|
|
842
837
|
argsert('[string|function]', [level], arguments.length);
|
|
843
|
-
__classPrivateFieldGet(this,
|
|
838
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion(level);
|
|
844
839
|
return this;
|
|
845
840
|
}
|
|
846
841
|
skipValidation(keys) {
|
|
@@ -850,17 +845,17 @@ export class YargsInstance {
|
|
|
850
845
|
}
|
|
851
846
|
strict(enabled) {
|
|
852
847
|
argsert('[boolean]', [enabled], arguments.length);
|
|
853
|
-
__classPrivateFieldSet(this,
|
|
848
|
+
__classPrivateFieldSet(this, _YargsInstance_strict, enabled !== false, "f");
|
|
854
849
|
return this;
|
|
855
850
|
}
|
|
856
851
|
strictCommands(enabled) {
|
|
857
852
|
argsert('[boolean]', [enabled], arguments.length);
|
|
858
|
-
__classPrivateFieldSet(this,
|
|
853
|
+
__classPrivateFieldSet(this, _YargsInstance_strictCommands, enabled !== false, "f");
|
|
859
854
|
return this;
|
|
860
855
|
}
|
|
861
856
|
strictOptions(enabled) {
|
|
862
857
|
argsert('[boolean]', [enabled], arguments.length);
|
|
863
|
-
__classPrivateFieldSet(this,
|
|
858
|
+
__classPrivateFieldSet(this, _YargsInstance_strictOptions, enabled !== false, "f");
|
|
864
859
|
return this;
|
|
865
860
|
}
|
|
866
861
|
string(key) {
|
|
@@ -870,21 +865,21 @@ export class YargsInstance {
|
|
|
870
865
|
}
|
|
871
866
|
terminalWidth() {
|
|
872
867
|
argsert([], 0);
|
|
873
|
-
return __classPrivateFieldGet(this,
|
|
868
|
+
return __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.stdColumns;
|
|
874
869
|
}
|
|
875
870
|
updateLocale(obj) {
|
|
876
871
|
return this.updateStrings(obj);
|
|
877
872
|
}
|
|
878
873
|
updateStrings(obj) {
|
|
879
874
|
argsert('<object>', [obj], arguments.length);
|
|
880
|
-
__classPrivateFieldSet(this,
|
|
881
|
-
__classPrivateFieldGet(this,
|
|
875
|
+
__classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
|
|
876
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj);
|
|
882
877
|
return this;
|
|
883
878
|
}
|
|
884
879
|
usage(msg, description, builder, handler) {
|
|
885
880
|
argsert('<string|null|undefined> [string|boolean] [function|object] [function]', [msg, description, builder, handler], arguments.length);
|
|
886
881
|
if (description !== undefined) {
|
|
887
|
-
assertNotStrictEqual(msg, null, __classPrivateFieldGet(this,
|
|
882
|
+
assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
888
883
|
if ((msg || '').match(/^\$0( |$)/)) {
|
|
889
884
|
return this.command(msg, description, builder, handler);
|
|
890
885
|
}
|
|
@@ -893,17 +888,17 @@ export class YargsInstance {
|
|
|
893
888
|
}
|
|
894
889
|
}
|
|
895
890
|
else {
|
|
896
|
-
__classPrivateFieldGet(this,
|
|
891
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").usage(msg);
|
|
897
892
|
return this;
|
|
898
893
|
}
|
|
899
894
|
}
|
|
900
895
|
version(opt, msg, ver) {
|
|
901
896
|
const defaultVersionOpt = 'version';
|
|
902
897
|
argsert('[boolean|string] [string] [string]', [opt, msg, ver], arguments.length);
|
|
903
|
-
if (__classPrivateFieldGet(this,
|
|
904
|
-
this[kDeleteFromParserHintObject](__classPrivateFieldGet(this,
|
|
905
|
-
__classPrivateFieldGet(this,
|
|
906
|
-
__classPrivateFieldSet(this,
|
|
898
|
+
if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")) {
|
|
899
|
+
this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
|
|
900
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").version(undefined);
|
|
901
|
+
__classPrivateFieldSet(this, _YargsInstance_versionOpt, null, "f");
|
|
907
902
|
}
|
|
908
903
|
if (arguments.length === 0) {
|
|
909
904
|
ver = this[kGuessVersion]();
|
|
@@ -920,19 +915,19 @@ export class YargsInstance {
|
|
|
920
915
|
ver = msg;
|
|
921
916
|
msg = undefined;
|
|
922
917
|
}
|
|
923
|
-
__classPrivateFieldSet(this,
|
|
924
|
-
msg = msg || __classPrivateFieldGet(this,
|
|
925
|
-
__classPrivateFieldGet(this,
|
|
926
|
-
this.boolean(__classPrivateFieldGet(this,
|
|
927
|
-
this.describe(__classPrivateFieldGet(this,
|
|
918
|
+
__classPrivateFieldSet(this, _YargsInstance_versionOpt, typeof opt === 'string' ? opt : defaultVersionOpt, "f");
|
|
919
|
+
msg = msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup('Show version number');
|
|
920
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").version(ver || undefined);
|
|
921
|
+
this.boolean(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
|
|
922
|
+
this.describe(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"), msg);
|
|
928
923
|
return this;
|
|
929
924
|
}
|
|
930
925
|
wrap(cols) {
|
|
931
926
|
argsert('<number|null|undefined>', [cols], arguments.length);
|
|
932
|
-
__classPrivateFieldGet(this,
|
|
927
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
|
|
933
928
|
return this;
|
|
934
929
|
}
|
|
935
|
-
[(
|
|
930
|
+
[(_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_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) {
|
|
936
931
|
if (!argv._ || !argv['--'])
|
|
937
932
|
return argv;
|
|
938
933
|
argv._.push.apply(argv._, argv['--']);
|
|
@@ -947,91 +942,92 @@ export class YargsInstance {
|
|
|
947
942
|
log: (...args) => {
|
|
948
943
|
if (!this[kHasParseCallback]())
|
|
949
944
|
console.log(...args);
|
|
950
|
-
__classPrivateFieldSet(this,
|
|
951
|
-
if (__classPrivateFieldGet(this,
|
|
952
|
-
__classPrivateFieldSet(this,
|
|
953
|
-
__classPrivateFieldSet(this,
|
|
945
|
+
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
|
946
|
+
if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
|
|
947
|
+
__classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + '\n', "f");
|
|
948
|
+
__classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(' '), "f");
|
|
954
949
|
},
|
|
955
950
|
error: (...args) => {
|
|
956
951
|
if (!this[kHasParseCallback]())
|
|
957
952
|
console.error(...args);
|
|
958
|
-
__classPrivateFieldSet(this,
|
|
959
|
-
if (__classPrivateFieldGet(this,
|
|
960
|
-
__classPrivateFieldSet(this,
|
|
961
|
-
__classPrivateFieldSet(this,
|
|
953
|
+
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
|
954
|
+
if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
|
|
955
|
+
__classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + '\n', "f");
|
|
956
|
+
__classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(' '), "f");
|
|
962
957
|
},
|
|
963
958
|
};
|
|
964
959
|
}
|
|
965
960
|
[kDeleteFromParserHintObject](optionKey) {
|
|
966
|
-
objectKeys(__classPrivateFieldGet(this,
|
|
961
|
+
objectKeys(__classPrivateFieldGet(this, _YargsInstance_options, "f")).forEach((hintKey) => {
|
|
967
962
|
if (((key) => key === 'configObjects')(hintKey))
|
|
968
963
|
return;
|
|
969
|
-
const hint = __classPrivateFieldGet(this,
|
|
964
|
+
const hint = __classPrivateFieldGet(this, _YargsInstance_options, "f")[hintKey];
|
|
970
965
|
if (Array.isArray(hint)) {
|
|
971
|
-
if (
|
|
966
|
+
if (hint.includes(optionKey))
|
|
972
967
|
hint.splice(hint.indexOf(optionKey), 1);
|
|
973
968
|
}
|
|
974
969
|
else if (typeof hint === 'object') {
|
|
975
970
|
delete hint[optionKey];
|
|
976
971
|
}
|
|
977
972
|
});
|
|
978
|
-
delete __classPrivateFieldGet(this,
|
|
973
|
+
delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
|
|
979
974
|
}
|
|
980
975
|
[kFreeze]() {
|
|
981
|
-
__classPrivateFieldGet(this,
|
|
982
|
-
options: __classPrivateFieldGet(this,
|
|
983
|
-
configObjects: __classPrivateFieldGet(this,
|
|
984
|
-
exitProcess: __classPrivateFieldGet(this,
|
|
985
|
-
groups: __classPrivateFieldGet(this,
|
|
986
|
-
strict: __classPrivateFieldGet(this,
|
|
987
|
-
strictCommands: __classPrivateFieldGet(this,
|
|
988
|
-
strictOptions: __classPrivateFieldGet(this,
|
|
989
|
-
completionCommand: __classPrivateFieldGet(this,
|
|
990
|
-
output: __classPrivateFieldGet(this,
|
|
991
|
-
exitError: __classPrivateFieldGet(this,
|
|
992
|
-
hasOutput: __classPrivateFieldGet(this,
|
|
976
|
+
__classPrivateFieldGet(this, _YargsInstance_frozens, "f").push({
|
|
977
|
+
options: __classPrivateFieldGet(this, _YargsInstance_options, "f"),
|
|
978
|
+
configObjects: __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects.slice(0),
|
|
979
|
+
exitProcess: __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"),
|
|
980
|
+
groups: __classPrivateFieldGet(this, _YargsInstance_groups, "f"),
|
|
981
|
+
strict: __classPrivateFieldGet(this, _YargsInstance_strict, "f"),
|
|
982
|
+
strictCommands: __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"),
|
|
983
|
+
strictOptions: __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"),
|
|
984
|
+
completionCommand: __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"),
|
|
985
|
+
output: __classPrivateFieldGet(this, _YargsInstance_output, "f"),
|
|
986
|
+
exitError: __classPrivateFieldGet(this, _YargsInstance_exitError, "f"),
|
|
987
|
+
hasOutput: __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"),
|
|
993
988
|
parsed: this.parsed,
|
|
994
|
-
parseFn: __classPrivateFieldGet(this,
|
|
995
|
-
parseContext: __classPrivateFieldGet(this,
|
|
989
|
+
parseFn: __classPrivateFieldGet(this, _YargsInstance_parseFn, "f"),
|
|
990
|
+
parseContext: __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"),
|
|
996
991
|
});
|
|
997
|
-
__classPrivateFieldGet(this,
|
|
998
|
-
__classPrivateFieldGet(this,
|
|
999
|
-
__classPrivateFieldGet(this,
|
|
1000
|
-
__classPrivateFieldGet(this,
|
|
992
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").freeze();
|
|
993
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").freeze();
|
|
994
|
+
__classPrivateFieldGet(this, _YargsInstance_command, "f").freeze();
|
|
995
|
+
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").freeze();
|
|
1001
996
|
}
|
|
1002
997
|
[kGetDollarZero]() {
|
|
1003
998
|
let $0 = '';
|
|
1004
999
|
let default$0;
|
|
1005
|
-
if (/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,
|
|
1006
|
-
default$0 = __classPrivateFieldGet(this,
|
|
1000
|
+
if (/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv()[0])) {
|
|
1001
|
+
default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(1, 2);
|
|
1007
1002
|
}
|
|
1008
1003
|
else {
|
|
1009
|
-
default$0 = __classPrivateFieldGet(this,
|
|
1004
|
+
default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(0, 1);
|
|
1010
1005
|
}
|
|
1011
1006
|
$0 = default$0
|
|
1012
1007
|
.map(x => {
|
|
1013
|
-
const b = this[kRebase](__classPrivateFieldGet(this,
|
|
1008
|
+
const b = this[kRebase](__classPrivateFieldGet(this, _YargsInstance_cwd, "f"), x);
|
|
1014
1009
|
return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x;
|
|
1015
1010
|
})
|
|
1016
1011
|
.join(' ')
|
|
1017
1012
|
.trim();
|
|
1018
|
-
if (__classPrivateFieldGet(this,
|
|
1019
|
-
__classPrivateFieldGet(this,
|
|
1020
|
-
$0 = __classPrivateFieldGet(this,
|
|
1021
|
-
.
|
|
1013
|
+
if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('_') &&
|
|
1014
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").getProcessArgvBin() === __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('_')) {
|
|
1015
|
+
$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f")
|
|
1016
|
+
.getEnv('_')
|
|
1017
|
+
.replace(`${__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.execPath())}/`, '');
|
|
1022
1018
|
}
|
|
1023
1019
|
return $0;
|
|
1024
1020
|
}
|
|
1025
1021
|
[kGetParserConfiguration]() {
|
|
1026
|
-
return __classPrivateFieldGet(this,
|
|
1022
|
+
return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
|
|
1027
1023
|
}
|
|
1028
1024
|
[kGuessLocale]() {
|
|
1029
|
-
if (!__classPrivateFieldGet(this,
|
|
1025
|
+
if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f"))
|
|
1030
1026
|
return;
|
|
1031
|
-
const locale = __classPrivateFieldGet(this,
|
|
1032
|
-
__classPrivateFieldGet(this,
|
|
1033
|
-
__classPrivateFieldGet(this,
|
|
1034
|
-
__classPrivateFieldGet(this,
|
|
1027
|
+
const locale = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('LC_ALL') ||
|
|
1028
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('LC_MESSAGES') ||
|
|
1029
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('LANG') ||
|
|
1030
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv('LANGUAGE') ||
|
|
1035
1031
|
'en_US';
|
|
1036
1032
|
this.locale(locale.replace(/[.:].*/, ''));
|
|
1037
1033
|
}
|
|
@@ -1042,7 +1038,7 @@ export class YargsInstance {
|
|
|
1042
1038
|
[kParsePositionalNumbers](argv) {
|
|
1043
1039
|
const args = argv['--'] ? argv['--'] : argv._;
|
|
1044
1040
|
for (let i = 0, arg; (arg = args[i]) !== undefined; i++) {
|
|
1045
|
-
if (__classPrivateFieldGet(this,
|
|
1041
|
+
if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.looksLikeNumber(arg) &&
|
|
1046
1042
|
Number.isSafeInteger(Math.floor(parseFloat(`${arg}`)))) {
|
|
1047
1043
|
args[i] = Number(arg);
|
|
1048
1044
|
}
|
|
@@ -1051,15 +1047,15 @@ export class YargsInstance {
|
|
|
1051
1047
|
}
|
|
1052
1048
|
[kPkgUp](rootPath) {
|
|
1053
1049
|
const npath = rootPath || '*';
|
|
1054
|
-
if (__classPrivateFieldGet(this,
|
|
1055
|
-
return __classPrivateFieldGet(this,
|
|
1050
|
+
if (__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath])
|
|
1051
|
+
return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
|
|
1056
1052
|
let obj = {};
|
|
1057
1053
|
try {
|
|
1058
|
-
let startDir = rootPath || __classPrivateFieldGet(this,
|
|
1059
|
-
if (!rootPath && __classPrivateFieldGet(this,
|
|
1060
|
-
startDir = __classPrivateFieldGet(this,
|
|
1054
|
+
let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename;
|
|
1055
|
+
if (!rootPath && __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) {
|
|
1056
|
+
startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir);
|
|
1061
1057
|
}
|
|
1062
|
-
const pkgJsonPath = __classPrivateFieldGet(this,
|
|
1058
|
+
const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names) => {
|
|
1063
1059
|
if (names.includes('package.json')) {
|
|
1064
1060
|
return 'package.json';
|
|
1065
1061
|
}
|
|
@@ -1067,28 +1063,28 @@ export class YargsInstance {
|
|
|
1067
1063
|
return undefined;
|
|
1068
1064
|
}
|
|
1069
1065
|
});
|
|
1070
|
-
assertNotStrictEqual(pkgJsonPath, undefined, __classPrivateFieldGet(this,
|
|
1071
|
-
obj = JSON.parse(__classPrivateFieldGet(this,
|
|
1066
|
+
assertNotStrictEqual(pkgJsonPath, undefined, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
1067
|
+
obj = JSON.parse(__classPrivateFieldGet(this, _YargsInstance_shim, "f").readFileSync(pkgJsonPath, 'utf8'));
|
|
1072
1068
|
}
|
|
1073
1069
|
catch (_noop) { }
|
|
1074
|
-
__classPrivateFieldGet(this,
|
|
1075
|
-
return __classPrivateFieldGet(this,
|
|
1070
|
+
__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
|
|
1071
|
+
return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
|
|
1076
1072
|
}
|
|
1077
1073
|
[kPopulateParserHintArray](type, keys) {
|
|
1078
1074
|
keys = [].concat(keys);
|
|
1079
1075
|
keys.forEach(key => {
|
|
1080
1076
|
key = this[kSanitizeKey](key);
|
|
1081
|
-
__classPrivateFieldGet(this,
|
|
1077
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type].push(key);
|
|
1082
1078
|
});
|
|
1083
1079
|
}
|
|
1084
1080
|
[kPopulateParserHintSingleValueDictionary](builder, type, key, value) {
|
|
1085
1081
|
this[kPopulateParserHintDictionary](builder, type, key, value, (type, key, value) => {
|
|
1086
|
-
__classPrivateFieldGet(this,
|
|
1082
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] = value;
|
|
1087
1083
|
});
|
|
1088
1084
|
}
|
|
1089
1085
|
[kPopulateParserHintArrayDictionary](builder, type, key, value) {
|
|
1090
1086
|
this[kPopulateParserHintDictionary](builder, type, key, value, (type, key, value) => {
|
|
1091
|
-
__classPrivateFieldGet(this,
|
|
1087
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type][key] || []).concat(value);
|
|
1092
1088
|
});
|
|
1093
1089
|
}
|
|
1094
1090
|
[kPopulateParserHintDictionary](builder, type, key, value, singleKeyHandler) {
|
|
@@ -1117,30 +1113,30 @@ export class YargsInstance {
|
|
|
1117
1113
|
}
|
|
1118
1114
|
[kUnfreeze]() {
|
|
1119
1115
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1120
|
-
const frozen = __classPrivateFieldGet(this,
|
|
1121
|
-
assertNotStrictEqual(frozen, undefined, __classPrivateFieldGet(this,
|
|
1116
|
+
const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
|
|
1117
|
+
assertNotStrictEqual(frozen, undefined, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
1122
1118
|
let configObjects;
|
|
1123
1119
|
(_a = this, _b = this, _c = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
|
|
1124
|
-
options: ({ set value(_o) { __classPrivateFieldSet(_a,
|
|
1120
|
+
options: ({ set value(_o) { __classPrivateFieldSet(_a, _YargsInstance_options, _o, "f"); } }).value,
|
|
1125
1121
|
configObjects,
|
|
1126
|
-
exitProcess: ({ set value(_o) { __classPrivateFieldSet(_b,
|
|
1127
|
-
groups: ({ set value(_o) { __classPrivateFieldSet(_c,
|
|
1128
|
-
output: ({ set value(_o) { __classPrivateFieldSet(_d,
|
|
1129
|
-
exitError: ({ set value(_o) { __classPrivateFieldSet(_e,
|
|
1130
|
-
hasOutput: ({ set value(_o) { __classPrivateFieldSet(_f,
|
|
1122
|
+
exitProcess: ({ set value(_o) { __classPrivateFieldSet(_b, _YargsInstance_exitProcess, _o, "f"); } }).value,
|
|
1123
|
+
groups: ({ set value(_o) { __classPrivateFieldSet(_c, _YargsInstance_groups, _o, "f"); } }).value,
|
|
1124
|
+
output: ({ set value(_o) { __classPrivateFieldSet(_d, _YargsInstance_output, _o, "f"); } }).value,
|
|
1125
|
+
exitError: ({ set value(_o) { __classPrivateFieldSet(_e, _YargsInstance_exitError, _o, "f"); } }).value,
|
|
1126
|
+
hasOutput: ({ set value(_o) { __classPrivateFieldSet(_f, _YargsInstance_hasOutput, _o, "f"); } }).value,
|
|
1131
1127
|
parsed: this.parsed,
|
|
1132
|
-
strict: ({ set value(_o) { __classPrivateFieldSet(_g,
|
|
1133
|
-
strictCommands: ({ set value(_o) { __classPrivateFieldSet(_h,
|
|
1134
|
-
strictOptions: ({ set value(_o) { __classPrivateFieldSet(_j,
|
|
1135
|
-
completionCommand: ({ set value(_o) { __classPrivateFieldSet(_k,
|
|
1136
|
-
parseFn: ({ set value(_o) { __classPrivateFieldSet(_l,
|
|
1137
|
-
parseContext: ({ set value(_o) { __classPrivateFieldSet(_m,
|
|
1128
|
+
strict: ({ set value(_o) { __classPrivateFieldSet(_g, _YargsInstance_strict, _o, "f"); } }).value,
|
|
1129
|
+
strictCommands: ({ set value(_o) { __classPrivateFieldSet(_h, _YargsInstance_strictCommands, _o, "f"); } }).value,
|
|
1130
|
+
strictOptions: ({ set value(_o) { __classPrivateFieldSet(_j, _YargsInstance_strictOptions, _o, "f"); } }).value,
|
|
1131
|
+
completionCommand: ({ set value(_o) { __classPrivateFieldSet(_k, _YargsInstance_completionCommand, _o, "f"); } }).value,
|
|
1132
|
+
parseFn: ({ set value(_o) { __classPrivateFieldSet(_l, _YargsInstance_parseFn, _o, "f"); } }).value,
|
|
1133
|
+
parseContext: ({ set value(_o) { __classPrivateFieldSet(_m, _YargsInstance_parseContext, _o, "f"); } }).value,
|
|
1138
1134
|
} = frozen);
|
|
1139
|
-
__classPrivateFieldGet(this,
|
|
1140
|
-
__classPrivateFieldGet(this,
|
|
1141
|
-
__classPrivateFieldGet(this,
|
|
1142
|
-
__classPrivateFieldGet(this,
|
|
1143
|
-
__classPrivateFieldGet(this,
|
|
1135
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = configObjects;
|
|
1136
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").unfreeze();
|
|
1137
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").unfreeze();
|
|
1138
|
+
__classPrivateFieldGet(this, _YargsInstance_command, "f").unfreeze();
|
|
1139
|
+
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").unfreeze();
|
|
1144
1140
|
}
|
|
1145
1141
|
[kValidateAsync](validation, argv) {
|
|
1146
1142
|
return maybeAsyncResult(argv, result => {
|
|
@@ -1167,28 +1163,28 @@ export class YargsInstance {
|
|
|
1167
1163
|
};
|
|
1168
1164
|
}
|
|
1169
1165
|
[kGetCommandInstance]() {
|
|
1170
|
-
return __classPrivateFieldGet(this,
|
|
1166
|
+
return __classPrivateFieldGet(this, _YargsInstance_command, "f");
|
|
1171
1167
|
}
|
|
1172
1168
|
[kGetContext]() {
|
|
1173
|
-
return __classPrivateFieldGet(this,
|
|
1169
|
+
return __classPrivateFieldGet(this, _YargsInstance_context, "f");
|
|
1174
1170
|
}
|
|
1175
1171
|
[kGetHasOutput]() {
|
|
1176
|
-
return __classPrivateFieldGet(this,
|
|
1172
|
+
return __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f");
|
|
1177
1173
|
}
|
|
1178
1174
|
[kGetLoggerInstance]() {
|
|
1179
|
-
return __classPrivateFieldGet(this,
|
|
1175
|
+
return __classPrivateFieldGet(this, _YargsInstance_logger, "f");
|
|
1180
1176
|
}
|
|
1181
1177
|
[kGetParseContext]() {
|
|
1182
|
-
return __classPrivateFieldGet(this,
|
|
1178
|
+
return __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") || {};
|
|
1183
1179
|
}
|
|
1184
1180
|
[kGetUsageInstance]() {
|
|
1185
|
-
return __classPrivateFieldGet(this,
|
|
1181
|
+
return __classPrivateFieldGet(this, _YargsInstance_usage, "f");
|
|
1186
1182
|
}
|
|
1187
1183
|
[kGetValidationInstance]() {
|
|
1188
|
-
return __classPrivateFieldGet(this,
|
|
1184
|
+
return __classPrivateFieldGet(this, _YargsInstance_validation, "f");
|
|
1189
1185
|
}
|
|
1190
1186
|
[kHasParseCallback]() {
|
|
1191
|
-
return !!__classPrivateFieldGet(this,
|
|
1187
|
+
return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f");
|
|
1192
1188
|
}
|
|
1193
1189
|
[kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) {
|
|
1194
1190
|
if (calledFromCommand)
|
|
@@ -1204,17 +1200,15 @@ export class YargsInstance {
|
|
|
1204
1200
|
argv = this[kParsePositionalNumbers](argv);
|
|
1205
1201
|
}
|
|
1206
1202
|
if (runGlobalMiddleware) {
|
|
1207
|
-
argv = applyMiddleware(argv, this, __classPrivateFieldGet(this,
|
|
1203
|
+
argv = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
|
|
1208
1204
|
}
|
|
1209
1205
|
return argv;
|
|
1210
1206
|
}
|
|
1211
1207
|
[kReset](aliases = {}) {
|
|
1212
|
-
__classPrivateFieldSet(this,
|
|
1208
|
+
__classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f") || {}, "f");
|
|
1213
1209
|
const tmpOptions = {};
|
|
1214
|
-
tmpOptions.local = __classPrivateFieldGet(this,
|
|
1215
|
-
tmpOptions.configObjects = __classPrivateFieldGet(this,
|
|
1216
|
-
? __classPrivateFieldGet(this, _options).configObjects
|
|
1217
|
-
: [];
|
|
1210
|
+
tmpOptions.local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local || [];
|
|
1211
|
+
tmpOptions.configObjects = __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || [];
|
|
1218
1212
|
const localLookup = {};
|
|
1219
1213
|
tmpOptions.local.forEach(l => {
|
|
1220
1214
|
localLookup[l] = true;
|
|
@@ -1222,14 +1216,14 @@ export class YargsInstance {
|
|
|
1222
1216
|
localLookup[a] = true;
|
|
1223
1217
|
});
|
|
1224
1218
|
});
|
|
1225
|
-
Object.assign(__classPrivateFieldGet(this,
|
|
1226
|
-
const keys = __classPrivateFieldGet(this,
|
|
1219
|
+
Object.assign(__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"), Object.keys(__classPrivateFieldGet(this, _YargsInstance_groups, "f")).reduce((acc, groupName) => {
|
|
1220
|
+
const keys = __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName].filter(key => !(key in localLookup));
|
|
1227
1221
|
if (keys.length > 0) {
|
|
1228
1222
|
acc[groupName] = keys;
|
|
1229
1223
|
}
|
|
1230
1224
|
return acc;
|
|
1231
1225
|
}, {}));
|
|
1232
|
-
__classPrivateFieldSet(this,
|
|
1226
|
+
__classPrivateFieldSet(this, _YargsInstance_groups, {}, "f");
|
|
1233
1227
|
const arrayOptions = [
|
|
1234
1228
|
'array',
|
|
1235
1229
|
'boolean',
|
|
@@ -1253,146 +1247,150 @@ export class YargsInstance {
|
|
|
1253
1247
|
'deprecatedOptions',
|
|
1254
1248
|
];
|
|
1255
1249
|
arrayOptions.forEach(k => {
|
|
1256
|
-
tmpOptions[k] = (__classPrivateFieldGet(this,
|
|
1250
|
+
tmpOptions[k] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[k] || []).filter((k) => !localLookup[k]);
|
|
1257
1251
|
});
|
|
1258
1252
|
objectOptions.forEach((k) => {
|
|
1259
|
-
tmpOptions[k] = objFilter(__classPrivateFieldGet(this,
|
|
1253
|
+
tmpOptions[k] = objFilter(__classPrivateFieldGet(this, _YargsInstance_options, "f")[k], k => !localLookup[k]);
|
|
1260
1254
|
});
|
|
1261
|
-
tmpOptions.envPrefix = __classPrivateFieldGet(this,
|
|
1262
|
-
__classPrivateFieldSet(this,
|
|
1263
|
-
__classPrivateFieldSet(this,
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
:
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
__classPrivateFieldSet(this,
|
|
1255
|
+
tmpOptions.envPrefix = __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
|
|
1256
|
+
__classPrivateFieldSet(this, _YargsInstance_options, tmpOptions, "f");
|
|
1257
|
+
__classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f")
|
|
1258
|
+
? __classPrivateFieldGet(this, _YargsInstance_usage, "f").reset(localLookup)
|
|
1259
|
+
: Usage(this, __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
|
|
1260
|
+
__classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f")
|
|
1261
|
+
? __classPrivateFieldGet(this, _YargsInstance_validation, "f").reset(localLookup)
|
|
1262
|
+
: Validation(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
|
|
1263
|
+
__classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f")
|
|
1264
|
+
? __classPrivateFieldGet(this, _YargsInstance_command, "f").reset()
|
|
1265
|
+
: Command(__classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_validation, "f"), __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
|
|
1266
|
+
if (!__classPrivateFieldGet(this, _YargsInstance_completion, "f"))
|
|
1267
|
+
__classPrivateFieldSet(this, _YargsInstance_completion, Completion(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_command, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
|
|
1268
|
+
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").reset();
|
|
1269
|
+
__classPrivateFieldSet(this, _YargsInstance_completionCommand, null, "f");
|
|
1270
|
+
__classPrivateFieldSet(this, _YargsInstance_output, '', "f");
|
|
1271
|
+
__classPrivateFieldSet(this, _YargsInstance_exitError, null, "f");
|
|
1272
|
+
__classPrivateFieldSet(this, _YargsInstance_hasOutput, false, "f");
|
|
1276
1273
|
this.parsed = false;
|
|
1277
1274
|
return this;
|
|
1278
1275
|
}
|
|
1279
1276
|
[kRebase](base, dir) {
|
|
1280
|
-
return __classPrivateFieldGet(this,
|
|
1277
|
+
return __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.relative(base, dir);
|
|
1281
1278
|
}
|
|
1282
1279
|
[kRunYargsParserAndExecuteCommands](args, shortCircuit, calledFromCommand, commandIndex = 0, helpOnly = false) {
|
|
1283
1280
|
let skipValidation = !!calledFromCommand || helpOnly;
|
|
1284
|
-
args = args || __classPrivateFieldGet(this,
|
|
1285
|
-
__classPrivateFieldGet(this,
|
|
1286
|
-
__classPrivateFieldGet(this,
|
|
1287
|
-
const populateDoubleDash = !!__classPrivateFieldGet(this,
|
|
1288
|
-
const config = Object.assign({}, __classPrivateFieldGet(this,
|
|
1281
|
+
args = args || __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
|
|
1282
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__;
|
|
1283
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration]();
|
|
1284
|
+
const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration['populate--'];
|
|
1285
|
+
const config = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, {
|
|
1289
1286
|
'populate--': true,
|
|
1290
1287
|
});
|
|
1291
|
-
const parsed = __classPrivateFieldGet(this,
|
|
1288
|
+
const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), {
|
|
1292
1289
|
configuration: { 'parse-positional-numbers': false, ...config },
|
|
1293
1290
|
}));
|
|
1294
|
-
const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this,
|
|
1291
|
+
const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"));
|
|
1295
1292
|
let argvPromise = undefined;
|
|
1296
1293
|
const aliases = parsed.aliases;
|
|
1297
1294
|
let helpOptSet = false;
|
|
1298
1295
|
let versionOptSet = false;
|
|
1299
1296
|
Object.keys(argv).forEach(key => {
|
|
1300
|
-
if (key === __classPrivateFieldGet(this,
|
|
1297
|
+
if (key === __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f") && argv[key]) {
|
|
1301
1298
|
helpOptSet = true;
|
|
1302
1299
|
}
|
|
1303
|
-
else if (key === __classPrivateFieldGet(this,
|
|
1300
|
+
else if (key === __classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && argv[key]) {
|
|
1304
1301
|
versionOptSet = true;
|
|
1305
1302
|
}
|
|
1306
1303
|
});
|
|
1307
1304
|
argv.$0 = this.$0;
|
|
1308
1305
|
this.parsed = parsed;
|
|
1309
1306
|
if (commandIndex === 0) {
|
|
1310
|
-
__classPrivateFieldGet(this,
|
|
1307
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").clearCachedHelpMessage();
|
|
1311
1308
|
}
|
|
1312
1309
|
try {
|
|
1313
1310
|
this[kGuessLocale]();
|
|
1314
1311
|
if (shortCircuit) {
|
|
1315
1312
|
return this[kPostProcess](argv, populateDoubleDash, !!calledFromCommand, false);
|
|
1316
1313
|
}
|
|
1317
|
-
if (__classPrivateFieldGet(this,
|
|
1318
|
-
const helpCmds = [__classPrivateFieldGet(this,
|
|
1319
|
-
.concat(aliases[__classPrivateFieldGet(this,
|
|
1314
|
+
if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
|
|
1315
|
+
const helpCmds = [__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")]
|
|
1316
|
+
.concat(aliases[__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")] || [])
|
|
1320
1317
|
.filter(k => k.length > 1);
|
|
1321
|
-
if (
|
|
1318
|
+
if (helpCmds.includes('' + argv._[argv._.length - 1])) {
|
|
1322
1319
|
argv._.pop();
|
|
1323
1320
|
helpOptSet = true;
|
|
1324
1321
|
}
|
|
1325
1322
|
}
|
|
1326
|
-
const handlerKeys = __classPrivateFieldGet(this,
|
|
1327
|
-
const requestCompletions = __classPrivateFieldGet(this,
|
|
1323
|
+
const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands();
|
|
1324
|
+
const requestCompletions = __classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey in argv;
|
|
1328
1325
|
const skipRecommendation = helpOptSet || requestCompletions || helpOnly;
|
|
1329
1326
|
if (argv._.length) {
|
|
1330
1327
|
if (handlerKeys.length) {
|
|
1331
1328
|
let firstUnknownCommand;
|
|
1332
1329
|
for (let i = commandIndex || 0, cmd; argv._[i] !== undefined; i++) {
|
|
1333
1330
|
cmd = String(argv._[i]);
|
|
1334
|
-
if (
|
|
1335
|
-
const innerArgv = __classPrivateFieldGet(this,
|
|
1331
|
+
if (handlerKeys.includes(cmd) && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
|
|
1332
|
+
const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(cmd, this, parsed, i + 1, helpOnly, helpOptSet || versionOptSet || helpOnly);
|
|
1336
1333
|
return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
|
|
1337
1334
|
}
|
|
1338
1335
|
else if (!firstUnknownCommand &&
|
|
1339
|
-
cmd !== __classPrivateFieldGet(this,
|
|
1336
|
+
cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
|
|
1340
1337
|
firstUnknownCommand = cmd;
|
|
1341
1338
|
break;
|
|
1342
1339
|
}
|
|
1343
1340
|
}
|
|
1344
|
-
if (!__classPrivateFieldGet(this,
|
|
1341
|
+
if (!__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() &&
|
|
1342
|
+
__classPrivateFieldGet(this, _YargsInstance_recommendCommands, "f") &&
|
|
1345
1343
|
firstUnknownCommand &&
|
|
1346
1344
|
!skipRecommendation) {
|
|
1347
|
-
__classPrivateFieldGet(this,
|
|
1345
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").recommendCommands(firstUnknownCommand, handlerKeys);
|
|
1348
1346
|
}
|
|
1349
1347
|
}
|
|
1350
|
-
if (__classPrivateFieldGet(this,
|
|
1351
|
-
|
|
1348
|
+
if (__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") &&
|
|
1349
|
+
argv._.includes(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) &&
|
|
1352
1350
|
!requestCompletions) {
|
|
1353
|
-
if (__classPrivateFieldGet(this,
|
|
1351
|
+
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
|
1354
1352
|
setBlocking(true);
|
|
1355
1353
|
this.showCompletionScript();
|
|
1356
1354
|
this.exit(0);
|
|
1357
1355
|
}
|
|
1358
1356
|
}
|
|
1359
|
-
if (__classPrivateFieldGet(this,
|
|
1360
|
-
const innerArgv = __classPrivateFieldGet(this,
|
|
1357
|
+
if (__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && !skipRecommendation) {
|
|
1358
|
+
const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(null, this, parsed, 0, helpOnly, helpOptSet || versionOptSet || helpOnly);
|
|
1361
1359
|
return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
|
|
1362
1360
|
}
|
|
1363
1361
|
if (requestCompletions) {
|
|
1364
|
-
if (__classPrivateFieldGet(this,
|
|
1362
|
+
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
|
1365
1363
|
setBlocking(true);
|
|
1366
1364
|
args = [].concat(args);
|
|
1367
|
-
const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this,
|
|
1368
|
-
__classPrivateFieldGet(this,
|
|
1365
|
+
const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey}`) + 1);
|
|
1366
|
+
__classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(completionArgs, (err, completions) => {
|
|
1369
1367
|
if (err)
|
|
1370
1368
|
throw new YError(err.message);
|
|
1371
1369
|
(completions || []).forEach(completion => {
|
|
1372
|
-
__classPrivateFieldGet(this,
|
|
1370
|
+
__classPrivateFieldGet(this, _YargsInstance_logger, "f").log(completion);
|
|
1373
1371
|
});
|
|
1374
1372
|
this.exit(0);
|
|
1375
1373
|
});
|
|
1376
1374
|
return this[kPostProcess](argv, !populateDoubleDash, !!calledFromCommand, false);
|
|
1377
1375
|
}
|
|
1378
|
-
if (!__classPrivateFieldGet(this,
|
|
1376
|
+
if (!__classPrivateFieldGet(this, _YargsInstance_hasOutput, "f")) {
|
|
1379
1377
|
if (helpOptSet) {
|
|
1380
|
-
if (__classPrivateFieldGet(this,
|
|
1378
|
+
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
|
1381
1379
|
setBlocking(true);
|
|
1382
1380
|
skipValidation = true;
|
|
1383
1381
|
this.showHelp('log');
|
|
1384
1382
|
this.exit(0);
|
|
1385
1383
|
}
|
|
1386
1384
|
else if (versionOptSet) {
|
|
1387
|
-
if (__classPrivateFieldGet(this,
|
|
1385
|
+
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
|
1388
1386
|
setBlocking(true);
|
|
1389
1387
|
skipValidation = true;
|
|
1390
|
-
__classPrivateFieldGet(this,
|
|
1388
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion('log');
|
|
1391
1389
|
this.exit(0);
|
|
1392
1390
|
}
|
|
1393
1391
|
}
|
|
1394
|
-
if (!skipValidation && __classPrivateFieldGet(this,
|
|
1395
|
-
skipValidation = Object.keys(argv).some(key => __classPrivateFieldGet(this,
|
|
1392
|
+
if (!skipValidation && __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.length > 0) {
|
|
1393
|
+
skipValidation = Object.keys(argv).some(key => __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.indexOf(key) >= 0 && argv[key] === true);
|
|
1396
1394
|
}
|
|
1397
1395
|
if (!skipValidation) {
|
|
1398
1396
|
if (parsed.error)
|
|
@@ -1400,12 +1398,12 @@ export class YargsInstance {
|
|
|
1400
1398
|
if (!requestCompletions) {
|
|
1401
1399
|
const validation = this[kRunValidation](aliases, {}, parsed.error);
|
|
1402
1400
|
if (!calledFromCommand) {
|
|
1403
|
-
argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this,
|
|
1401
|
+
argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), true);
|
|
1404
1402
|
}
|
|
1405
1403
|
argvPromise = this[kValidateAsync](validation, argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv);
|
|
1406
1404
|
if (isPromise(argvPromise) && !calledFromCommand) {
|
|
1407
1405
|
argvPromise = argvPromise.then(() => {
|
|
1408
|
-
return applyMiddleware(argv, this, __classPrivateFieldGet(this,
|
|
1406
|
+
return applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
|
|
1409
1407
|
});
|
|
1410
1408
|
}
|
|
1411
1409
|
}
|
|
@@ -1413,38 +1411,36 @@ export class YargsInstance {
|
|
|
1413
1411
|
}
|
|
1414
1412
|
catch (err) {
|
|
1415
1413
|
if (err instanceof YError)
|
|
1416
|
-
__classPrivateFieldGet(this,
|
|
1414
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message, err);
|
|
1417
1415
|
else
|
|
1418
1416
|
throw err;
|
|
1419
1417
|
}
|
|
1420
1418
|
return this[kPostProcess](argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv, populateDoubleDash, !!calledFromCommand, true);
|
|
1421
1419
|
}
|
|
1422
1420
|
[kRunValidation](aliases, positionalMap, parseErrors, isDefaultCommand) {
|
|
1423
|
-
aliases = { ...aliases };
|
|
1424
|
-
positionalMap = { ...positionalMap };
|
|
1425
1421
|
const demandedOptions = { ...this.getDemandedOptions() };
|
|
1426
1422
|
return (argv) => {
|
|
1427
1423
|
if (parseErrors)
|
|
1428
1424
|
throw new YError(parseErrors.message);
|
|
1429
|
-
__classPrivateFieldGet(this,
|
|
1430
|
-
__classPrivateFieldGet(this,
|
|
1425
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").nonOptionCount(argv);
|
|
1426
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").requiredArguments(argv, demandedOptions);
|
|
1431
1427
|
let failedStrictCommands = false;
|
|
1432
|
-
if (__classPrivateFieldGet(this,
|
|
1433
|
-
failedStrictCommands = __classPrivateFieldGet(this,
|
|
1428
|
+
if (__classPrivateFieldGet(this, _YargsInstance_strictCommands, "f")) {
|
|
1429
|
+
failedStrictCommands = __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownCommands(argv);
|
|
1434
1430
|
}
|
|
1435
|
-
if (__classPrivateFieldGet(this,
|
|
1436
|
-
__classPrivateFieldGet(this,
|
|
1431
|
+
if (__classPrivateFieldGet(this, _YargsInstance_strict, "f") && !failedStrictCommands) {
|
|
1432
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, positionalMap, !!isDefaultCommand);
|
|
1437
1433
|
}
|
|
1438
|
-
else if (__classPrivateFieldGet(this,
|
|
1439
|
-
__classPrivateFieldGet(this,
|
|
1434
|
+
else if (__classPrivateFieldGet(this, _YargsInstance_strictOptions, "f")) {
|
|
1435
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, {}, false, false);
|
|
1440
1436
|
}
|
|
1441
|
-
__classPrivateFieldGet(this,
|
|
1442
|
-
__classPrivateFieldGet(this,
|
|
1443
|
-
__classPrivateFieldGet(this,
|
|
1437
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").limitedChoices(argv);
|
|
1438
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").implications(argv);
|
|
1439
|
+
__classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicting(argv);
|
|
1444
1440
|
};
|
|
1445
1441
|
}
|
|
1446
1442
|
[kSetHasOutput]() {
|
|
1447
|
-
__classPrivateFieldSet(this,
|
|
1443
|
+
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
|
1448
1444
|
}
|
|
1449
1445
|
}
|
|
1450
1446
|
export function isYargsInstance(y) {
|