yargs 17.7.1 → 18.0.0-browser.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/README.md +8 -23
- package/build/lib/command.js +55 -25
- package/build/lib/completion-templates.js +4 -3
- package/build/lib/completion.js +18 -19
- package/build/lib/utils/apply-extends.js +3 -1
- package/build/lib/yargs-factory.js +18 -19
- package/index.mjs +2 -0
- package/lib/platform-shims/browser.mjs +5 -2
- package/lib/platform-shims/esm.mjs +16 -23
- package/locales/he.json +55 -0
- package/package.json +29 -49
- package/build/index.cjs +0 -1
- package/helpers/index.js +0 -14
- package/index.cjs +0 -53
- package/yargs +0 -9
- package/yargs.mjs +0 -10
package/README.md
CHANGED
|
@@ -59,9 +59,9 @@ npm i yargs@next
|
|
|
59
59
|
|
|
60
60
|
```javascript
|
|
61
61
|
#!/usr/bin/env node
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const argv = yargs(hideBin(process.argv)).
|
|
62
|
+
import yargs from 'yargs';
|
|
63
|
+
import { hideBin } from 'yargs/helpers';
|
|
64
|
+
const argv = yargs(hideBin(process.argv)).parse()
|
|
65
65
|
|
|
66
66
|
if (argv.ships > 3 && argv.distance < 53.5) {
|
|
67
67
|
console.log('Plunder more riffiwobbles!')
|
|
@@ -84,8 +84,8 @@ Retreat from the xupptumblers!
|
|
|
84
84
|
|
|
85
85
|
```javascript
|
|
86
86
|
#!/usr/bin/env node
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
import yargs from 'yargs';
|
|
88
|
+
import { hideBin } from 'yargs/helpers';
|
|
89
89
|
|
|
90
90
|
yargs(hideBin(process.argv))
|
|
91
91
|
.command('serve [port]', 'start the server', (yargs) => {
|
|
@@ -125,8 +125,8 @@ See usage examples in [docs](/docs/typescript.md).
|
|
|
125
125
|
As of `v16`, `yargs` supports [Deno](https://github.com/denoland/deno):
|
|
126
126
|
|
|
127
127
|
```typescript
|
|
128
|
-
import yargs from 'https://deno.land/x/yargs/deno.ts'
|
|
129
|
-
import { Arguments } from 'https://deno.land/x/yargs/deno-types.ts'
|
|
128
|
+
import yargs from 'https://deno.land/x/yargs@v17.7.2-deno/deno.ts'
|
|
129
|
+
import { Arguments } from 'https://deno.land/x/yargs@v17.7.2-deno/deno-types.ts'
|
|
130
130
|
|
|
131
131
|
yargs(Deno.args)
|
|
132
132
|
.command('download <files...>', 'download a list of files', (yargs: any) => {
|
|
@@ -141,21 +141,7 @@ yargs(Deno.args)
|
|
|
141
141
|
.parse()
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
As of `v16`,`yargs` supports ESM imports:
|
|
147
|
-
|
|
148
|
-
```js
|
|
149
|
-
import yargs from 'yargs'
|
|
150
|
-
import { hideBin } from 'yargs/helpers'
|
|
151
|
-
|
|
152
|
-
yargs(hideBin(process.argv))
|
|
153
|
-
.command('curl <url>', 'fetch the contents of the URL', () => {}, (argv) => {
|
|
154
|
-
console.info(argv)
|
|
155
|
-
})
|
|
156
|
-
.demandCommand(1)
|
|
157
|
-
.parse()
|
|
158
|
-
```
|
|
144
|
+
> Note: If you use version tags in url then you also have to add `-deno` flag on the end, like `@17.7.2-deno`
|
|
159
145
|
|
|
160
146
|
### Usage in Browser
|
|
161
147
|
|
|
@@ -182,7 +168,6 @@ Having problems? want to contribute? join our [community slack](http://devtoolsc
|
|
|
182
168
|
* [Composing Your App Using Commands](/docs/advanced.md#commands)
|
|
183
169
|
* [Building Configurable CLI Apps](/docs/advanced.md#configuration)
|
|
184
170
|
* [Customizing Yargs' Parser](/docs/advanced.md#customizing)
|
|
185
|
-
* [Bundling yargs](/docs/bundling.md)
|
|
186
171
|
* [Contributing](/contributing.md)
|
|
187
172
|
|
|
188
173
|
## Supported Node.js Versions
|
package/build/lib/command.js
CHANGED
|
@@ -4,7 +4,7 @@ import { applyMiddleware, commandMiddlewareFactory, } from './middleware.js';
|
|
|
4
4
|
import { parseCommand } from './parse-command.js';
|
|
5
5
|
import { isYargsInstance, } from './yargs-factory.js';
|
|
6
6
|
import { maybeAsyncResult } from './utils/maybe-async-result.js';
|
|
7
|
-
import
|
|
7
|
+
import { join, dirname } from 'node:path';
|
|
8
8
|
const DEFAULT_MARKER = /(^\*)|(^\$0)/;
|
|
9
9
|
export class CommandInstance {
|
|
10
10
|
constructor(usage, validation, globalMiddleware, shim) {
|
|
@@ -19,23 +19,59 @@ export class CommandInstance {
|
|
|
19
19
|
}
|
|
20
20
|
addDirectory(dir, req, callerFile, opts) {
|
|
21
21
|
opts = opts || {};
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
this.requireCache.add(callerFile);
|
|
23
|
+
const fullDirPath = join(dirname(callerFile), dir);
|
|
24
|
+
const files = this.shim.readdirSync(fullDirPath, {
|
|
25
|
+
recursive: opts.recurse ? true : false,
|
|
26
|
+
});
|
|
24
27
|
if (!Array.isArray(opts.extensions))
|
|
25
28
|
opts.extensions = ['js'];
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const visit = typeof opts.visit === 'function' ? opts.visit : (o) => o;
|
|
30
|
+
for (const fileb of files) {
|
|
31
|
+
const file = fileb.toString();
|
|
32
|
+
if (opts.exclude) {
|
|
33
|
+
let exclude = false;
|
|
34
|
+
if (typeof opts.exclude === 'function') {
|
|
35
|
+
exclude = opts.exclude(file);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
exclude = opts.exclude.test(file);
|
|
39
|
+
}
|
|
40
|
+
if (exclude)
|
|
41
|
+
continue;
|
|
35
42
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
if (opts.include) {
|
|
44
|
+
let include = false;
|
|
45
|
+
if (typeof opts.include === 'function') {
|
|
46
|
+
include = opts.include(file);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
include = opts.include.test(file);
|
|
50
|
+
}
|
|
51
|
+
if (!include)
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
let supportedExtension = false;
|
|
55
|
+
for (const ext of opts.extensions) {
|
|
56
|
+
if (file.endsWith(ext))
|
|
57
|
+
supportedExtension = true;
|
|
58
|
+
}
|
|
59
|
+
if (supportedExtension) {
|
|
60
|
+
const joined = join(fullDirPath, file);
|
|
61
|
+
const module = req(joined);
|
|
62
|
+
const visited = visit(module, joined, file);
|
|
63
|
+
if (visited) {
|
|
64
|
+
if (this.requireCache.has(joined))
|
|
65
|
+
continue;
|
|
66
|
+
else
|
|
67
|
+
this.requireCache.add(joined);
|
|
68
|
+
if (!module.command) {
|
|
69
|
+
module.command = this.shim.path.basename(joined, this.shim.path.extname(joined));
|
|
70
|
+
}
|
|
71
|
+
this.addHandler(module);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
39
75
|
}
|
|
40
76
|
addHandler(cmd, description, builder, handler, commandMiddleware, deprecated) {
|
|
41
77
|
let aliases = [];
|
|
@@ -54,7 +90,10 @@ export class CommandInstance {
|
|
|
54
90
|
else if (isCommandHandlerDefinition(cmd)) {
|
|
55
91
|
let command = Array.isArray(cmd.command) || typeof cmd.command === 'string'
|
|
56
92
|
? cmd.command
|
|
57
|
-
:
|
|
93
|
+
: null;
|
|
94
|
+
if (command === null) {
|
|
95
|
+
throw new Error(`No command name given for module: ${this.shim.inspect(cmd)}`);
|
|
96
|
+
}
|
|
58
97
|
if (cmd.aliases)
|
|
59
98
|
command = [].concat(command).concat(cmd.aliases);
|
|
60
99
|
this.addHandler(command, this.extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
|
|
@@ -386,15 +425,6 @@ export class CommandInstance {
|
|
|
386
425
|
}
|
|
387
426
|
return undefined;
|
|
388
427
|
}
|
|
389
|
-
moduleName(obj) {
|
|
390
|
-
const mod = whichModule(obj);
|
|
391
|
-
if (!mod)
|
|
392
|
-
throw new Error(`No command name given for module: ${this.shim.inspect(obj)}`);
|
|
393
|
-
return this.commandFromFilename(mod.filename);
|
|
394
|
-
}
|
|
395
|
-
commandFromFilename(filename) {
|
|
396
|
-
return this.shim.path.basename(filename, this.shim.path.extname(filename));
|
|
397
|
-
}
|
|
398
428
|
extractDesc({ describe, description, desc }) {
|
|
399
429
|
for (const test of [describe, description, desc]) {
|
|
400
430
|
if (typeof test === 'string' || test === false)
|
|
@@ -13,9 +13,10 @@ _{{app_name}}_yargs_completions()
|
|
|
13
13
|
args=("\${COMP_WORDS[@]}")
|
|
14
14
|
|
|
15
15
|
# ask yargs to generate completions.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
COMPREPLY
|
|
16
|
+
# see https://stackoverflow.com/a/40944195/7080036 for the spaces-handling awk
|
|
17
|
+
mapfile -t type_list < <({{app_path}} --get-yargs-completions "\${args[@]}")
|
|
18
|
+
mapfile -t COMPREPLY < <(compgen -W "$( printf '%q ' "\${type_list[@]}" )" -- "\${cur_word}" |
|
|
19
|
+
awk '/ / { print "\\""$0"\\"" } /^[^ ]+$/ { print $0 }')
|
|
19
20
|
|
|
20
21
|
# if no match was found, fall back to filename completion
|
|
21
22
|
if [ \${#COMPREPLY[@]} -eq 0 ]; then
|
package/build/lib/completion.js
CHANGED
|
@@ -71,9 +71,7 @@ export class Completion {
|
|
|
71
71
|
if (!isPositionalKey &&
|
|
72
72
|
!options.hiddenOptions.includes(key) &&
|
|
73
73
|
!this.argsContainKey(args, key, negable)) {
|
|
74
|
-
this.completeOptionKey(key, completions, current);
|
|
75
|
-
if (negable && !!options.default[key])
|
|
76
|
-
this.completeOptionKey(`no-${key}`, completions, current);
|
|
74
|
+
this.completeOptionKey(key, completions, current, negable && !!options.default[key]);
|
|
77
75
|
}
|
|
78
76
|
});
|
|
79
77
|
}
|
|
@@ -153,26 +151,27 @@ export class Completion {
|
|
|
153
151
|
}
|
|
154
152
|
return false;
|
|
155
153
|
}
|
|
156
|
-
completeOptionKey(key, completions, current) {
|
|
157
|
-
var _a, _b, _c;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (!this.zshShell) {
|
|
163
|
-
completions.push(dashes + key);
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
const aliasKey = (_a = this === null || this === void 0 ? void 0 : this.aliases) === null || _a === void 0 ? void 0 : _a[key].find(alias => {
|
|
154
|
+
completeOptionKey(key, completions, current, negable) {
|
|
155
|
+
var _a, _b, _c, _d;
|
|
156
|
+
let keyWithDesc = key;
|
|
157
|
+
if (this.zshShell) {
|
|
158
|
+
const descs = this.usage.getDescriptions();
|
|
159
|
+
const aliasKey = (_b = (_a = this === null || this === void 0 ? void 0 : this.aliases) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.find(alias => {
|
|
167
160
|
const desc = descs[alias];
|
|
168
161
|
return typeof desc === 'string' && desc.length > 0;
|
|
169
162
|
});
|
|
170
163
|
const descFromAlias = aliasKey ? descs[aliasKey] : undefined;
|
|
171
|
-
const desc = (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
164
|
+
const desc = (_d = (_c = descs[key]) !== null && _c !== void 0 ? _c : descFromAlias) !== null && _d !== void 0 ? _d : '';
|
|
165
|
+
keyWithDesc = `${key.replace(/:/g, '\\:')}:${desc
|
|
166
|
+
.replace('__yargsString__:', '')
|
|
167
|
+
.replace(/(\r\n|\n|\r)/gm, ' ')}`;
|
|
168
|
+
}
|
|
169
|
+
const startsByTwoDashes = (s) => /^--/.test(s);
|
|
170
|
+
const isShortOption = (s) => /^[^0-9]$/.test(s);
|
|
171
|
+
const dashes = !startsByTwoDashes(current) && isShortOption(key) ? '-' : '--';
|
|
172
|
+
completions.push(dashes + keyWithDesc);
|
|
173
|
+
if (negable) {
|
|
174
|
+
completions.push(dashes + 'no-' + keyWithDesc);
|
|
176
175
|
}
|
|
177
176
|
}
|
|
178
177
|
customCompletion(args, argv, current, done) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { YError } from '../yerror.js';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
2
4
|
let previouslyVisitedConfigs = [];
|
|
3
5
|
let shim;
|
|
4
6
|
export function applyExtends(config, cwd, mergeExtends, _shim) {
|
|
@@ -11,7 +13,7 @@ export function applyExtends(config, cwd, mergeExtends, _shim) {
|
|
|
11
13
|
let pathToDefault = null;
|
|
12
14
|
if (!isPath) {
|
|
13
15
|
try {
|
|
14
|
-
pathToDefault =
|
|
16
|
+
pathToDefault = import.meta.resolve(config.extends);
|
|
15
17
|
}
|
|
16
18
|
catch (_err) {
|
|
17
19
|
return config;
|
|
@@ -73,6 +73,7 @@ const kRunYargsParserAndExecuteCommands = Symbol('runYargsParserAndExecuteComman
|
|
|
73
73
|
const kRunValidation = Symbol('runValidation');
|
|
74
74
|
const kSetHasOutput = Symbol('setHasOutput');
|
|
75
75
|
const kTrackManuallySetKeys = Symbol('kTrackManuallySetKeys');
|
|
76
|
+
const DEFAULT_LOCALE = 'en_US';
|
|
76
77
|
export class YargsInstance {
|
|
77
78
|
constructor(processArgs = [], cwd, parentRequire, shim) {
|
|
78
79
|
this.customScriptName = false;
|
|
@@ -125,6 +126,7 @@ export class YargsInstance {
|
|
|
125
126
|
__classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f"), "f");
|
|
126
127
|
__classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
|
|
127
128
|
__classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger](), "f");
|
|
129
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(DEFAULT_LOCALE);
|
|
128
130
|
}
|
|
129
131
|
addHelpOpt(opt, msg) {
|
|
130
132
|
const defaultHelpOpt = 'help';
|
|
@@ -218,31 +220,26 @@ export class YargsInstance {
|
|
|
218
220
|
if (!value) {
|
|
219
221
|
throw new YError('coerce callback must be provided');
|
|
220
222
|
}
|
|
221
|
-
|
|
223
|
+
const coerceKey = keys;
|
|
224
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").key[coerceKey] = true;
|
|
222
225
|
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
+
var _a;
|
|
227
|
+
const coerceKeyAliases = (_a = yargs.getAliases()[coerceKey]) !== null && _a !== void 0 ? _a : [];
|
|
228
|
+
const argvKeys = [coerceKey, ...coerceKeyAliases].filter(key => Object.prototype.hasOwnProperty.call(argv, key));
|
|
229
|
+
if (argvKeys.length === 0) {
|
|
226
230
|
return argv;
|
|
227
231
|
}
|
|
228
232
|
return maybeAsyncResult(() => {
|
|
229
|
-
|
|
230
|
-
return value(argv[keys]);
|
|
233
|
+
return value(argv[argvKeys[0]]);
|
|
231
234
|
}, (result) => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
.getParserConfiguration()['strip-aliased'];
|
|
236
|
-
if (aliases[keys] && stripAliased !== true) {
|
|
237
|
-
for (const alias of aliases[keys]) {
|
|
238
|
-
argv[alias] = result;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
235
|
+
argvKeys.forEach(key => {
|
|
236
|
+
argv[key] = result;
|
|
237
|
+
});
|
|
241
238
|
return argv;
|
|
242
239
|
}, (err) => {
|
|
243
240
|
throw new YError(err.message);
|
|
244
241
|
});
|
|
245
|
-
},
|
|
242
|
+
}, coerceKey);
|
|
246
243
|
return this;
|
|
247
244
|
}
|
|
248
245
|
conflicts(key1, key2) {
|
|
@@ -1100,7 +1097,7 @@ export class YargsInstance {
|
|
|
1100
1097
|
let obj = {};
|
|
1101
1098
|
try {
|
|
1102
1099
|
let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename;
|
|
1103
|
-
if (
|
|
1100
|
+
if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) {
|
|
1104
1101
|
startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir);
|
|
1105
1102
|
}
|
|
1106
1103
|
const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names) => {
|
|
@@ -1432,8 +1429,10 @@ export class YargsInstance {
|
|
|
1432
1429
|
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
|
1433
1430
|
setBlocking(true);
|
|
1434
1431
|
skipValidation = true;
|
|
1435
|
-
this.showHelp(
|
|
1436
|
-
|
|
1432
|
+
this.showHelp(message => {
|
|
1433
|
+
__classPrivateFieldGet(this, _YargsInstance_logger, "f").log(message);
|
|
1434
|
+
this.exit(0);
|
|
1435
|
+
});
|
|
1437
1436
|
}
|
|
1438
1437
|
else if (versionOptSet) {
|
|
1439
1438
|
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
package/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
import cliui from 'https://unpkg.com/cliui@
|
|
5
|
-
import Parser from 'https://unpkg.com/yargs-parser@
|
|
4
|
+
import cliui from 'https://unpkg.com/cliui@8.0.1/index.mjs'; // eslint-disable-line
|
|
5
|
+
import Parser from 'https://unpkg.com/yargs-parser@21.1.1/browser.js'; // eslint-disable-line
|
|
6
6
|
import {getProcessArgvBin} from '../../build/lib/utils/process-argv.js';
|
|
7
7
|
import {YError} from '../../build/lib/yerror.js';
|
|
8
8
|
|
|
@@ -54,6 +54,9 @@ export default {
|
|
|
54
54
|
readFileSync: () => {
|
|
55
55
|
return '';
|
|
56
56
|
},
|
|
57
|
+
readdirSync: () => {
|
|
58
|
+
return [];
|
|
59
|
+
},
|
|
57
60
|
require: () => {
|
|
58
61
|
throw new YError(REQUIRE_ERROR);
|
|
59
62
|
},
|
|
@@ -4,24 +4,19 @@ import { notStrictEqual, strictEqual } from 'assert'
|
|
|
4
4
|
import cliui from 'cliui'
|
|
5
5
|
import escalade from 'escalade/sync'
|
|
6
6
|
import { inspect } from 'util'
|
|
7
|
-
import { readFileSync } from 'fs'
|
|
8
7
|
import { fileURLToPath } from 'url';
|
|
9
8
|
import Parser from 'yargs-parser'
|
|
10
9
|
import { basename, dirname, extname, relative, resolve } from 'path'
|
|
11
10
|
import { getProcessArgvBin } from '../../build/lib/utils/process-argv.js'
|
|
12
|
-
import
|
|
11
|
+
import stringWidth from 'string-width';
|
|
13
12
|
import y18n from 'y18n'
|
|
13
|
+
import { createRequire } from 'node:module';
|
|
14
|
+
import getCallerFile from 'get-caller-file';
|
|
15
|
+
import { readFileSync, readdirSync } from 'node:fs'
|
|
14
16
|
|
|
15
|
-
const
|
|
16
|
-
const REQUIRE_DIRECTORY_ERROR = 'loading a directory of commands is not supported yet for ESM'
|
|
17
|
-
|
|
18
|
-
let __dirname;
|
|
19
|
-
try {
|
|
20
|
-
__dirname = fileURLToPath(import.meta.url);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
__dirname = process.cwd();
|
|
23
|
-
}
|
|
17
|
+
const __dirname = fileURLToPath(import.meta.url);
|
|
24
18
|
const mainFilename = __dirname.substring(0, __dirname.lastIndexOf('node_modules'));
|
|
19
|
+
const require = createRequire(import.meta.url);
|
|
25
20
|
|
|
26
21
|
export default {
|
|
27
22
|
assert: {
|
|
@@ -34,9 +29,6 @@ export default {
|
|
|
34
29
|
return process.env[key]
|
|
35
30
|
},
|
|
36
31
|
inspect,
|
|
37
|
-
getCallerFile: () => {
|
|
38
|
-
throw new YError(REQUIRE_DIRECTORY_ERROR)
|
|
39
|
-
},
|
|
40
32
|
getProcessArgvBin,
|
|
41
33
|
mainFilename: mainFilename || process.cwd(),
|
|
42
34
|
Parser,
|
|
@@ -52,20 +44,21 @@ export default {
|
|
|
52
44
|
cwd: process.cwd,
|
|
53
45
|
emitWarning: (warning, type) => process.emitWarning(warning, type),
|
|
54
46
|
execPath: () => process.execPath,
|
|
55
|
-
exit:
|
|
47
|
+
exit: (code) => {
|
|
48
|
+
// eslint-disable-next-line n/no-process-exit
|
|
49
|
+
process.exit(code);
|
|
50
|
+
},
|
|
56
51
|
nextTick: process.nextTick,
|
|
57
52
|
stdColumns: typeof process.stdout.columns !== 'undefined' ? process.stdout.columns : null
|
|
58
53
|
},
|
|
59
54
|
readFileSync,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
stringWidth: (str) => {
|
|
67
|
-
return [...str].length
|
|
55
|
+
readdirSync,
|
|
56
|
+
require,
|
|
57
|
+
getCallerFile: () => {
|
|
58
|
+
const callerFile = getCallerFile(3);
|
|
59
|
+
return callerFile.match(/^file:\/\//) ? fileURLToPath(callerFile) : callerFile;
|
|
68
60
|
},
|
|
61
|
+
stringWidth,
|
|
69
62
|
y18n: y18n({
|
|
70
63
|
directory: resolve(__dirname, '../../../locales'),
|
|
71
64
|
updateFiles: false
|
package/locales/he.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Commands:": "פקודות:",
|
|
3
|
+
"Options:": "אופציות:",
|
|
4
|
+
"Examples:": "דוגמות:",
|
|
5
|
+
"boolean": "בוליאני",
|
|
6
|
+
"count": "ספירה",
|
|
7
|
+
"string": "מחרוזת",
|
|
8
|
+
"number": "מספר",
|
|
9
|
+
"array": "מערך",
|
|
10
|
+
"required": "דרוש",
|
|
11
|
+
"default": "ברירת מחדל",
|
|
12
|
+
"default:": "ברירת מחדל:",
|
|
13
|
+
"choices:": "בחירות:",
|
|
14
|
+
"aliases:": "כינויים:",
|
|
15
|
+
"generated-value": "ערך-שנוצר",
|
|
16
|
+
"Not enough non-option arguments: got %s, need at least %s": {
|
|
17
|
+
"one": "אין מספיק טיעונים שאינם אופציונלים: קיבל %s, צריך לפחות %s",
|
|
18
|
+
"other": "אין מספיק טיעונים שאינם אופציונלים: קיבל %s, צריך לפחות %s"
|
|
19
|
+
},
|
|
20
|
+
"Too many non-option arguments: got %s, maximum of %s": {
|
|
21
|
+
"one": "יותר מדי טיעונים שאינם אופציונלים: קיבל %s, מקסימום של %s",
|
|
22
|
+
"other": "יותר מדי טיעונים שאינם אופציונלים: קיבל %s, מקסימום של %s"
|
|
23
|
+
},
|
|
24
|
+
"Missing argument value: %s": {
|
|
25
|
+
"one": "חסר ערך הטענה: %s",
|
|
26
|
+
"other": "חסרים ערכי הטענה: %s"
|
|
27
|
+
},
|
|
28
|
+
"Missing required argument: %s": {
|
|
29
|
+
"one": "חסר טענה דרושה: %s",
|
|
30
|
+
"other": "חסרות טענות דרושות: %s"
|
|
31
|
+
},
|
|
32
|
+
"Unknown argument: %s": {
|
|
33
|
+
"one": "טענה לא ידוע: %s",
|
|
34
|
+
"other": "טענות לא ידועות: %s"
|
|
35
|
+
},
|
|
36
|
+
"Unknown command: %s": {
|
|
37
|
+
"one": "פקודת לא ידועה: %s",
|
|
38
|
+
"other": "פקודות לא ידועות: %s"
|
|
39
|
+
},
|
|
40
|
+
"Invalid values:": "ערכים לא חוקיים:",
|
|
41
|
+
"Argument: %s, Given: %s, Choices: %s": "טענות: %s, ניתנו: %s, בחירות: %s",
|
|
42
|
+
"Argument check failed: %s": "בדיקת הטענה נכשלה: %s",
|
|
43
|
+
"Implications failed:": "חסרים טיעונים תלויים:",
|
|
44
|
+
"Not enough arguments following: %s": "אין מספיק טיעונים לאחר: %s",
|
|
45
|
+
"Invalid JSON config file: %s": "קובץ תצורה לא תקין של JSON: %s",
|
|
46
|
+
"Path to JSON config file": "נתיב לקובץ התצורה של JSON",
|
|
47
|
+
"Show help": "הצג עזרה",
|
|
48
|
+
"Show version number": "הצג מספר גרסה",
|
|
49
|
+
"Did you mean %s?": "האם התכוונת ל- %s?",
|
|
50
|
+
"Arguments %s and %s are mutually exclusive" : "טענות %s ו- %s סותרים זה את זה",
|
|
51
|
+
"Positionals:": "עמדות:",
|
|
52
|
+
"command": "פקודה",
|
|
53
|
+
"deprecated": "הוצא משימוש",
|
|
54
|
+
"deprecated: %s": "הוצא משימוש: %s"
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0-browser.0",
|
|
4
4
|
"description": "yargs the modern, pirate-themed, successor to optimist.",
|
|
5
|
-
"main": "./index.
|
|
5
|
+
"main": "./index.mjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
|
8
|
-
"
|
|
9
|
-
{
|
|
10
|
-
"import": "./index.mjs",
|
|
11
|
-
"require": "./index.cjs"
|
|
12
|
-
},
|
|
13
|
-
"./index.cjs"
|
|
14
|
-
],
|
|
15
|
-
"./helpers": {
|
|
16
|
-
"import": "./helpers/helpers.mjs",
|
|
17
|
-
"require": "./helpers/index.js"
|
|
18
|
-
},
|
|
8
|
+
"./helpers": "./helpers/helpers.mjs",
|
|
19
9
|
"./browser": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
10
|
+
"types": "./browser.d.ts",
|
|
11
|
+
"import": "./browser.mjs"
|
|
22
12
|
},
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"import": "./yargs.mjs",
|
|
26
|
-
"require": "./yargs"
|
|
27
|
-
},
|
|
28
|
-
"./yargs"
|
|
29
|
-
]
|
|
13
|
+
".": "./index.mjs",
|
|
14
|
+
"./yargs": "./index.mjs"
|
|
30
15
|
},
|
|
31
16
|
"type": "module",
|
|
32
17
|
"module": "./index.mjs",
|
|
@@ -39,12 +24,9 @@
|
|
|
39
24
|
"files": [
|
|
40
25
|
"browser.mjs",
|
|
41
26
|
"browser.d.ts",
|
|
42
|
-
"index.cjs",
|
|
43
27
|
"helpers/*.js",
|
|
44
28
|
"helpers/*",
|
|
45
29
|
"index.mjs",
|
|
46
|
-
"yargs",
|
|
47
|
-
"yargs.mjs",
|
|
48
30
|
"build",
|
|
49
31
|
"locales",
|
|
50
32
|
"LICENSE",
|
|
@@ -53,54 +35,52 @@
|
|
|
53
35
|
"!**/*.d.ts"
|
|
54
36
|
],
|
|
55
37
|
"dependencies": {
|
|
56
|
-
"cliui": "^
|
|
38
|
+
"cliui": "^9.0.1",
|
|
57
39
|
"escalade": "^3.1.1",
|
|
58
40
|
"get-caller-file": "^2.0.5",
|
|
59
|
-
"
|
|
60
|
-
"string-width": "^4.2.3",
|
|
41
|
+
"string-width": "^7.2.0",
|
|
61
42
|
"y18n": "^5.0.5",
|
|
62
43
|
"yargs-parser": "^21.1.1"
|
|
63
44
|
},
|
|
64
45
|
"devDependencies": {
|
|
46
|
+
"@babel/eslint-parser": "^7.26.10",
|
|
47
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
65
48
|
"@types/chai": "^4.2.11",
|
|
66
49
|
"@types/mocha": "^9.0.0",
|
|
67
|
-
"@types/node": "^
|
|
68
|
-
"
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
52
|
+
"browserslist-generator": "^2.0.1",
|
|
53
|
+
"c8": "^9.1.0",
|
|
69
54
|
"chai": "^4.2.0",
|
|
70
55
|
"chalk": "^4.0.0",
|
|
71
|
-
"coveralls": "^3.0.9",
|
|
72
56
|
"cpr": "^3.0.1",
|
|
73
57
|
"cross-env": "^7.0.2",
|
|
74
|
-
"cross-spawn": "^7.0.
|
|
75
|
-
"eslint": "^
|
|
76
|
-
"
|
|
58
|
+
"cross-spawn": "^7.0.6",
|
|
59
|
+
"eslint": "^8.57.1",
|
|
60
|
+
"eslint-plugin-prettier": "^5.1.2",
|
|
61
|
+
"gts": "^5.2.0",
|
|
77
62
|
"hashish": "0.0.4",
|
|
78
|
-
"mocha": "^
|
|
63
|
+
"mocha": "^10.8.2",
|
|
79
64
|
"rimraf": "^3.0.2",
|
|
80
|
-
"
|
|
81
|
-
"rollup-plugin-cleanup": "^3.1.1",
|
|
82
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
83
|
-
"rollup-plugin-ts": "^2.0.4",
|
|
84
|
-
"typescript": "^4.0.2",
|
|
65
|
+
"typescript": "^5.8.3",
|
|
85
66
|
"which": "^2.0.0",
|
|
86
67
|
"yargs-test-extends": "^1.0.1"
|
|
87
68
|
},
|
|
88
69
|
"scripts": {
|
|
89
70
|
"fix": "gts fix && npm run fix:js",
|
|
90
|
-
"fix:js": "eslint . --ext
|
|
71
|
+
"fix:js": "eslint . --ext mjs --ext js --fix",
|
|
91
72
|
"posttest": "npm run check",
|
|
92
|
-
"test": "c8 mocha --enable-source-maps ./test/*.
|
|
73
|
+
"test": "c8 mocha --enable-source-maps ./test/*.mjs --require ./test/before.mjs --timeout=24000 --check-leaks",
|
|
93
74
|
"test:esm": "c8 mocha --enable-source-maps ./test/esm/*.mjs --check-leaks",
|
|
94
75
|
"coverage": "c8 report --check-coverage",
|
|
95
76
|
"prepare": "npm run compile",
|
|
96
|
-
"pretest": "npm run compile -- -p tsconfig.test.json
|
|
77
|
+
"pretest": "npm run compile -- -p tsconfig.test.json",
|
|
97
78
|
"compile": "rimraf build && tsc",
|
|
98
|
-
"postcompile": "npm run build:cjs",
|
|
99
|
-
"build:cjs": "rollup -c rollup.config.cjs",
|
|
100
|
-
"postbuild:cjs": "rimraf ./build/index.cjs.d.ts",
|
|
101
79
|
"check": "gts lint && npm run check:js",
|
|
102
|
-
"check:js": "eslint . --ext
|
|
103
|
-
"clean": "gts clean"
|
|
80
|
+
"check:js": "eslint . --ext mjs --ext js",
|
|
81
|
+
"clean": "gts clean",
|
|
82
|
+
"watch": "rimraf build && npm:watch:tsc",
|
|
83
|
+
"watch:tsc": "tsc --watch"
|
|
104
84
|
},
|
|
105
85
|
"repository": {
|
|
106
86
|
"type": "git",
|
|
@@ -118,6 +98,6 @@
|
|
|
118
98
|
],
|
|
119
99
|
"license": "MIT",
|
|
120
100
|
"engines": {
|
|
121
|
-
"node": ">=
|
|
101
|
+
"node": "^20.19.0 || ^22.12.0 || >=23"
|
|
122
102
|
}
|
|
123
103
|
}
|
package/build/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var t=require("assert");class e extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,e)}}let s,i=[];function n(t,o,a,h){s=h;let l={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if("string"!=typeof t.extends)return l;const r=/\.json|\..*rc$/.test(t.extends);let h=null;if(r)h=function(t,e){return s.path.resolve(t,e)}(o,t.extends);else try{h=require.resolve(t.extends)}catch(e){return t}!function(t){if(i.indexOf(t)>-1)throw new e(`Circular extended configurations: '${t}'.`)}(h),i.push(h),l=r?JSON.parse(s.readFileSync(h,"utf8")):require(t.extends),delete t.extends,l=n(l,s.path.dirname(h),a,s)}return i=[],a?r(l,t):Object.assign({},l,t)}function r(t,e){const s={};function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(s,t);for(const n of Object.keys(e))i(e[n])&&i(s[n])?s[n]=r(t[n],e[n]):s[n]=e[n];return s}function o(t){const e=t.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),s=/\.*[\][<>]/g,i=e.shift();if(!i)throw new Error(`No command found in: ${t}`);const n={cmd:i.replace(s,""),demanded:[],optional:[]};return e.forEach(((t,i)=>{let r=!1;t=t.replace(/\s/g,""),/\.+[\]>]/.test(t)&&i===e.length-1&&(r=!0),/^\[/.test(t)?n.optional.push({cmd:t.replace(s,"").split("|"),variadic:r}):n.demanded.push({cmd:t.replace(s,"").split("|"),variadic:r})})),n}const a=["first","second","third","fourth","fifth","sixth"];function h(t,s,i){try{let n=0;const[r,a,h]="object"==typeof t?[{demanded:[],optional:[]},t,s]:[o(`cmd ${t}`),s,i],f=[].slice.call(a);for(;f.length&&void 0===f[f.length-1];)f.pop();const d=h||f.length;if(d<r.demanded.length)throw new e(`Not enough arguments provided. Expected ${r.demanded.length} but received ${f.length}.`);const u=r.demanded.length+r.optional.length;if(d>u)throw new e(`Too many arguments provided. Expected max ${u} but received ${d}.`);r.demanded.forEach((t=>{const e=l(f.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&c(e,t.cmd,n),n+=1})),r.optional.forEach((t=>{if(0===f.length)return;const e=l(f.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&c(e,t.cmd,n),n+=1}))}catch(t){console.warn(t.stack)}}function l(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function c(t,s,i){throw new e(`Invalid ${a[i]||"manyith"} argument. Expected ${s.join(" or ")} but received ${t}.`)}function f(t){return!!t&&!!t.then&&"function"==typeof t.then}function d(t,e,s,i){s.assert.notStrictEqual(t,e,i)}function u(t,e){e.assert.strictEqual(typeof t,"string")}function p(t){return Object.keys(t)}function g(t={},e=(()=>!0)){const s={};return p(t).forEach((i=>{e(i,t[i])&&(s[i]=t[i])})),s}function m(){return process.versions.electron&&!process.defaultApp?0:1}function y(){return process.argv[m()]}var b=Object.freeze({__proto__:null,hideBin:function(t){return t.slice(m()+1)},getProcessArgvBin:y});function v(t,e,s,i){if("a"===s&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?i:"a"===s?i.call(t):i?i.value:e.get(t)}function O(t,e,s,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(t,s):n?n.value=s:e.set(t,s),s}class w{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,s=!0,i=!1){if(h("<array|function> [boolean] [boolean] [boolean]",[t,e,s],arguments.length),Array.isArray(t)){for(let i=0;i<t.length;i++){if("function"!=typeof t[i])throw Error("middleware must be a function");const n=t[i];n.applyBeforeValidation=e,n.global=s}Array.prototype.push.apply(this.globalMiddleware,t)}else if("function"==typeof t){const n=t;n.applyBeforeValidation=e,n.global=s,n.mutates=i,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const s=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((t=>{const i=[...s[e]||[],e];return!t.option||!i.includes(t.option)})),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();void 0!==t&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter((t=>t.global))}}function C(t,e,s,i){return s.reduce(((t,s)=>{if(s.applyBeforeValidation!==i)return t;if(s.mutates){if(s.applied)return t;s.applied=!0}if(f(t))return t.then((t=>Promise.all([t,s(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const i=s(t,e);return f(i)?i.then((e=>Object.assign(t,e))):Object.assign(t,i)}}),t)}function j(t,e,s=(t=>{throw t})){try{const s="function"==typeof t?t():t;return f(s)?s.then((t=>e(t))):e(s)}catch(t){return s(t)}}const M=/(^\*)|(^\$0)/;class _{constructor(t,e,s,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=t,this.globalMiddleware=s,this.validation=e}addDirectory(t,e,s,i){"boolean"!=typeof(i=i||{}).recurse&&(i.recurse=!1),Array.isArray(i.extensions)||(i.extensions=["js"]);const n="function"==typeof i.visit?i.visit:t=>t;i.visit=(t,e,s)=>{const i=n(t,e,s);if(i){if(this.requireCache.has(e))return i;this.requireCache.add(e),this.addHandler(i)}return i},this.shim.requireDirectory({require:e,filename:s},t,i)}addHandler(t,e,s,i,n,r){let a=[];const h=function(t){return t?t.map((t=>(t.applyBeforeValidation=!1,t))):[]}(n);if(i=i||(()=>{}),Array.isArray(t))if(function(t){return t.every((t=>"string"==typeof t))}(t))[t,...a]=t;else for(const e of t)this.addHandler(e);else{if(function(t){return"object"==typeof t&&!Array.isArray(t)}(t)){let e=Array.isArray(t.command)||"string"==typeof t.command?t.command:this.moduleName(t);return t.aliases&&(e=[].concat(e).concat(t.aliases)),void this.addHandler(e,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated)}if(k(s))return void this.addHandler([t].concat(a),e,s.builder,s.handler,s.middlewares,s.deprecated)}if("string"==typeof t){const n=o(t);a=a.map((t=>o(t).cmd));let l=!1;const c=[n.cmd].concat(a).filter((t=>!M.test(t)||(l=!0,!1)));0===c.length&&l&&c.push("$0"),l&&(n.cmd=c[0],a=c.slice(1),t=t.replace(M,n.cmd)),a.forEach((t=>{this.aliasMap[t]=n.cmd})),!1!==e&&this.usage.command(t,e,l,a,r),this.handlers[n.cmd]={original:t,description:e,handler:i,builder:s||{},middlewares:h,deprecated:r,demanded:n.demanded,optional:n.optional},l&&(this.defaultCommand=this.handlers[n.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,s,i,n,r){const o=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,a=e.getInternalMethods().getContext(),h=a.commands.slice(),l=!t;t&&(a.commands.push(t),a.fullCommands.push(o.original));const c=this.applyBuilderUpdateUsageAndParse(l,o,e,s.aliases,h,i,n,r);return f(c)?c.then((t=>this.applyMiddlewareAndGetResult(l,o,t.innerArgv,a,n,t.aliases,e))):this.applyMiddlewareAndGetResult(l,o,c.innerArgv,a,n,c.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,s,i,n,r,o,a){const h=e.builder;let l=s;if(x(h)){s.getInternalMethods().getUsageInstance().freeze();const c=h(s.getInternalMethods().reset(i),a);if(f(c))return c.then((i=>{var a;return l=(a=i)&&"function"==typeof a.getInternalMethods?i:s,this.parseAndUpdateUsage(t,e,l,n,r,o)}))}else(function(t){return"object"==typeof t})(h)&&(s.getInternalMethods().getUsageInstance().freeze(),l=s.getInternalMethods().reset(i),Object.keys(e.builder).forEach((t=>{l.option(t,h[t])})));return this.parseAndUpdateUsage(t,e,l,n,r,o)}parseAndUpdateUsage(t,e,s,i,n,r){t&&s.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(s)&&s.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,e),e.description);const o=s.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,n,r);return f(o)?o.then((t=>({aliases:s.parsed.aliases,innerArgv:t}))):{aliases:s.parsed.aliases,innerArgv:o}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&0===t.getInternalMethods().getUsageInstance().getUsage().length}usageFromParentCommandsCommandHandler(t,e){const s=M.test(e.original)?e.original.replace(M,"").trim():e.original,i=t.filter((t=>!M.test(t)));return i.push(s),`$0 ${i.join(" ")}`}handleValidationAndGetResult(t,e,s,i,n,r,o,a){if(!r.getInternalMethods().getHasOutput()){const e=r.getInternalMethods().runValidation(n,a,r.parsed.error,t);s=j(s,(t=>(e(t),t)))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const i=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(s,i,!1,!1),s=j(s=C(s,r,o,!1),(t=>{const s=e.handler(t);return f(s)?s.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),f(s)&&!r.getInternalMethods().hasParseCallback()&&s.catch((t=>{try{r.getInternalMethods().getUsageInstance().fail(null,t)}catch(t){}}))}return t||(i.commands.pop(),i.fullCommands.pop()),s}applyMiddlewareAndGetResult(t,e,s,i,n,r,o){let a={};if(n)return s;o.getInternalMethods().getHasOutput()||(a=this.populatePositionals(e,s,i,o));const h=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),l=C(s,o,h,!0);return f(l)?l.then((s=>this.handleValidationAndGetResult(t,e,s,i,r,o,h,a))):this.handleValidationAndGetResult(t,e,l,i,r,o,h,a)}populatePositionals(t,e,s,i){e._=e._.slice(s.commands.length);const n=t.demanded.slice(0),r=t.optional.slice(0),o={};for(this.validation.positionalCount(n.length,e._.length);n.length;){const t=n.shift();this.populatePositional(t,e,o)}for(;r.length;){const t=r.shift();this.populatePositional(t,e,o)}return e._=s.commands.concat(e._.map((t=>""+t))),this.postProcessPositionals(e,o,this.cmdToParseOptions(t.original),i),o}populatePositional(t,e,s){const i=t.cmd[0];t.variadic?s[i]=e._.splice(0).map(String):e._.length&&(s[i]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},s=o(t);return s.demanded.forEach((t=>{const[s,...i]=t.cmd;t.variadic&&(e.array.push(s),e.default[s]=[]),e.alias[s]=i,e.demand[s]=!0})),s.optional.forEach((t=>{const[s,...i]=t.cmd;t.variadic&&(e.array.push(s),e.default[s]=[]),e.alias[s]=i})),e}postProcessPositionals(t,e,s,i){const n=Object.assign({},i.getOptions());n.default=Object.assign(s.default,n.default);for(const t of Object.keys(s.alias))n.alias[t]=(n.alias[t]||[]).concat(s.alias[t]);n.array=n.array.concat(s.array),n.config={};const r=[];if(Object.keys(e).forEach((t=>{e[t].map((e=>{n.configuration["unknown-options-as-args"]&&(n.key[t]=!0),r.push(`--${t}`),r.push(e)}))})),!r.length)return;const o=Object.assign({},n.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},n,{configuration:o}));if(a.error)i.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{const s=Object.keys(e);Object.keys(e).forEach((t=>{s.push(...a.aliases[t])})),Object.keys(a.argv).forEach((n=>{s.includes(n)&&(e[n]||(e[n]=a.argv[n]),!this.isInConfigs(i,n)&&!this.isDefaulted(i,n)&&Object.prototype.hasOwnProperty.call(t,n)&&Object.prototype.hasOwnProperty.call(a.argv,n)&&(Array.isArray(t[n])||Array.isArray(a.argv[n]))?t[n]=[].concat(t[n],a.argv[n]):t[n]=a.argv[n])}))}}isDefaulted(t,e){const{default:s}=t.getOptions();return Object.prototype.hasOwnProperty.call(s,e)||Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:s}=t.getOptions();return s.some((t=>Object.prototype.hasOwnProperty.call(t,e)))||s.some((t=>Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(e))))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const e=M.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(e,this.defaultCommand.description)}const e=this.defaultCommand.builder;if(x(e))return e(t,!0);k(e)||Object.keys(e).forEach((s=>{t.option(s,e[s])}))}moduleName(t){const e=function(t){if("undefined"==typeof require)return null;for(let e,s=0,i=Object.keys(require.cache);s<i.length;s++)if(e=require.cache[i[s]],e.exports===t)return e;return null}(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:s}){for(const i of[t,e,s]){if("string"==typeof i||!1===i)return i;d(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();d(t,void 0,this.shim),({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t)}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function k(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function x(t){return"function"==typeof t}function E(t){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((e=>{const s=e;s._handle&&s.isTTY&&"function"==typeof s._handle.setBlocking&&s._handle.setBlocking(t)}))}function A(t){return"boolean"==typeof t}function P(t,s){const i=s.y18n.__,n={},r=[];n.failFn=function(t){r.push(t)};let o=null,a=null,h=!0;n.showHelpOnFail=function(e=!0,s){const[i,r]="string"==typeof e?[!0,e]:[e,s];return t.getInternalMethods().isGlobalContext()&&(a=r),o=r,h=i,n};let l=!1;n.fail=function(s,i){const c=t.getInternalMethods().getLoggerInstance();if(!r.length){if(t.getExitProcess()&&E(!0),!l){l=!0,h&&(t.showHelp("error"),c.error()),(s||i)&&c.error(s||i);const e=o||a;e&&((s||i)&&c.error(""),c.error(e))}if(i=i||new e(s),t.getExitProcess())return t.exit(1);if(t.getInternalMethods().hasParseCallback())return t.exit(1,i);throw i}for(let t=r.length-1;t>=0;--t){const e=r[t];if(A(e)){if(i)throw i;if(s)throw Error(s)}else e(s,i,n)}};let c=[],f=!1;n.usage=(t,e)=>null===t?(f=!0,c=[],n):(f=!1,c.push([t,e||""]),n),n.getUsage=()=>c,n.getUsageDisabled=()=>f,n.getPositionalGroupName=()=>i("Positionals:");let d=[];n.example=(t,e)=>{d.push([t,e||""])};let u=[];n.command=function(t,e,s,i,n=!1){s&&(u=u.map((t=>(t[2]=!1,t)))),u.push([t,e||"",s,i,n])},n.getCommands=()=>u;let p={};n.describe=function(t,e){Array.isArray(t)?t.forEach((t=>{n.describe(t,e)})):"object"==typeof t?Object.keys(t).forEach((e=>{n.describe(e,t[e])})):p[t]=e},n.getDescriptions=()=>p;let m=[];n.epilog=t=>{m.push(t)};let y,b=!1;n.wrap=t=>{b=!0,y=t},n.getWrap=()=>s.getEnv("YARGS_DISABLE_WRAP")?null:(b||(y=function(){const t=80;return s.process.stdColumns?Math.min(t,s.process.stdColumns):t}(),b=!0),y);const v="__yargsString__:";function O(t,e,i){let n=0;return Array.isArray(t)||(t=Object.values(t).map((t=>[t]))),t.forEach((t=>{n=Math.max(s.stringWidth(i?`${i} ${I(t[0])}`:I(t[0]))+$(t[0]),n)})),e&&(n=Math.min(n,parseInt((.5*e).toString(),10))),n}let w;function C(e){return t.getOptions().hiddenOptions.indexOf(e)<0||t.parsed.argv[t.getOptions().showHiddenOpt]}function j(t,e){let s=`[${i("default:")} `;if(void 0===t&&!e)return null;if(e)s+=e;else switch(typeof t){case"string":s+=`"${t}"`;break;case"object":s+=JSON.stringify(t);break;default:s+=t}return`${s}]`}n.deferY18nLookup=t=>v+t,n.help=function(){if(w)return w;!function(){const e=t.getDemandedOptions(),s=t.getOptions();(Object.keys(s.alias)||[]).forEach((i=>{s.alias[i].forEach((r=>{p[r]&&n.describe(i,p[r]),r in e&&t.demandOption(i,e[r]),s.boolean.includes(r)&&t.boolean(i),s.count.includes(r)&&t.count(i),s.string.includes(r)&&t.string(i),s.normalize.includes(r)&&t.normalize(i),s.array.includes(r)&&t.array(i),s.number.includes(r)&&t.number(i)}))}))}();const e=t.customScriptName?t.$0:s.path.basename(t.$0),r=t.getDemandedOptions(),o=t.getDemandedCommands(),a=t.getDeprecatedOptions(),h=t.getGroups(),l=t.getOptions();let g=[];g=g.concat(Object.keys(p)),g=g.concat(Object.keys(r)),g=g.concat(Object.keys(o)),g=g.concat(Object.keys(l.default)),g=g.filter(C),g=Object.keys(g.reduce(((t,e)=>("_"!==e&&(t[e]=!0),t)),{}));const y=n.getWrap(),b=s.cliui({width:y,wrap:!!y});if(!f)if(c.length)c.forEach((t=>{b.div({text:`${t[0].replace(/\$0/g,e)}`}),t[1]&&b.div({text:`${t[1]}`,padding:[1,0,0,0]})})),b.div();else if(u.length){let t=null;t=o._?`${e} <${i("command")}>\n`:`${e} [${i("command")}]\n`,b.div(`${t}`)}if(u.length>1||1===u.length&&!u[0][2]){b.div(i("Commands:"));const s=t.getInternalMethods().getContext(),n=s.commands.length?`${s.commands.join(" ")} `:"";!0===t.getInternalMethods().getParserConfiguration()["sort-commands"]&&(u=u.sort(((t,e)=>t[0].localeCompare(e[0]))));const r=e?`${e} `:"";u.forEach((t=>{const s=`${r}${n}${t[0].replace(/^\$0 ?/,"")}`;b.span({text:s,padding:[0,2,0,2],width:O(u,y,`${e}${n}`)+4},{text:t[1]});const o=[];t[2]&&o.push(`[${i("default")}]`),t[3]&&t[3].length&&o.push(`[${i("aliases:")} ${t[3].join(", ")}]`),t[4]&&("string"==typeof t[4]?o.push(`[${i("deprecated: %s",t[4])}]`):o.push(`[${i("deprecated")}]`)),o.length?b.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):b.div()})),b.div()}const M=(Object.keys(l.alias)||[]).concat(Object.keys(t.parsed.newAliases)||[]);g=g.filter((e=>!t.parsed.newAliases[e]&&M.every((t=>-1===(l.alias[t]||[]).indexOf(e)))));const _=i("Options:");h[_]||(h[_]=[]),function(t,e,s,i){let n=[],r=null;Object.keys(s).forEach((t=>{n=n.concat(s[t])})),t.forEach((t=>{r=[t].concat(e[t]),r.some((t=>-1!==n.indexOf(t)))||s[i].push(t)}))}(g,l.alias,h,_);const k=t=>/^--/.test(I(t)),x=Object.keys(h).filter((t=>h[t].length>0)).map((t=>({groupName:t,normalizedKeys:h[t].filter(C).map((t=>{if(M.includes(t))return t;for(let e,s=0;void 0!==(e=M[s]);s++)if((l.alias[e]||[]).includes(t))return e;return t}))}))).filter((({normalizedKeys:t})=>t.length>0)).map((({groupName:t,normalizedKeys:e})=>{const s=e.reduce(((e,s)=>(e[s]=[s].concat(l.alias[s]||[]).map((e=>t===n.getPositionalGroupName()?e:(/^[0-9]$/.test(e)?l.boolean.includes(s)?"-":"--":e.length>1?"--":"-")+e)).sort(((t,e)=>k(t)===k(e)?0:k(t)?1:-1)).join(", "),e)),{});return{groupName:t,normalizedKeys:e,switches:s}}));if(x.filter((({groupName:t})=>t!==n.getPositionalGroupName())).some((({normalizedKeys:t,switches:e})=>!t.every((t=>k(e[t])))))&&x.filter((({groupName:t})=>t!==n.getPositionalGroupName())).forEach((({normalizedKeys:t,switches:e})=>{t.forEach((t=>{var s,i;k(e[t])&&(e[t]=(s=e[t],i="-x, ".length,S(s)?{text:s.text,indentation:s.indentation+i}:{text:s,indentation:i}))}))})),x.forEach((({groupName:e,normalizedKeys:s,switches:o})=>{b.div(e),s.forEach((e=>{const s=o[e];let h=p[e]||"",c=null;h.includes(v)&&(h=i(h.substring(v.length))),l.boolean.includes(e)&&(c=`[${i("boolean")}]`),l.count.includes(e)&&(c=`[${i("count")}]`),l.string.includes(e)&&(c=`[${i("string")}]`),l.normalize.includes(e)&&(c=`[${i("string")}]`),l.array.includes(e)&&(c=`[${i("array")}]`),l.number.includes(e)&&(c=`[${i("number")}]`);const f=[e in a?(d=a[e],"string"==typeof d?`[${i("deprecated: %s",d)}]`:`[${i("deprecated")}]`):null,c,e in r?`[${i("required")}]`:null,l.choices&&l.choices[e]?`[${i("choices:")} ${n.stringifiedValues(l.choices[e])}]`:null,j(l.default[e],l.defaultDescription[e])].filter(Boolean).join(" ");var d;b.span({text:I(s),padding:[0,2,0,2+$(s)],width:O(o,y)+4},h);const u=!0===t.getInternalMethods().getUsageConfiguration()["hide-types"];f&&!u?b.div({text:f,padding:[0,0,0,2],align:"right"}):b.div()})),b.div()})),d.length&&(b.div(i("Examples:")),d.forEach((t=>{t[0]=t[0].replace(/\$0/g,e)})),d.forEach((t=>{""===t[1]?b.div({text:t[0],padding:[0,2,0,2]}):b.div({text:t[0],padding:[0,2,0,2],width:O(d,y)+4},{text:t[1]})})),b.div()),m.length>0){const t=m.map((t=>t.replace(/\$0/g,e))).join("\n");b.div(`${t}\n`)}return b.toString().replace(/\s*$/,"")},n.cacheHelpMessage=function(){w=this.help()},n.clearCachedHelpMessage=function(){w=void 0},n.hasCachedHelpMessage=function(){return!!w},n.showHelp=e=>{const s=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:s[e])(n.help())},n.functionDescription=t=>["(",t.name?s.Parser.decamelize(t.name,"-"):i("generated-value"),")"].join(""),n.stringifiedValues=function(t,e){let s="";const i=e||", ",n=[].concat(t);return t&&n.length?(n.forEach((t=>{s.length&&(s+=i),s+=JSON.stringify(t)})),s):s};let M=null;n.version=t=>{M=t},n.showVersion=e=>{const s=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:s[e])(M)},n.reset=function(t){return o=null,l=!1,c=[],f=!1,m=[],d=[],u=[],p=g(p,(e=>!t[e])),n};const _=[];return n.freeze=function(){_.push({failMessage:o,failureOutput:l,usages:c,usageDisabled:f,epilogs:m,examples:d,commands:u,descriptions:p})},n.unfreeze=function(t=!1){const e=_.pop();e&&(t?(p={...e.descriptions,...p},u=[...e.commands,...u],c=[...e.usages,...c],d=[...e.examples,...d],m=[...e.epilogs,...m]):({failMessage:o,failureOutput:l,usages:c,usageDisabled:f,epilogs:m,examples:d,commands:u,descriptions:p}=e))},n}function S(t){return"object"==typeof t}function $(t){return S(t)?t.indentation:0}function I(t){return S(t)?t.text:t}class D{constructor(t,e,s,i){var n,r,o;this.yargs=t,this.usage=e,this.command=s,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=null!==(o=(null===(n=this.shim.getEnv("SHELL"))||void 0===n?void 0:n.includes("zsh"))||(null===(r=this.shim.getEnv("ZSH_NAME"))||void 0===r?void 0:r.includes("zsh")))&&void 0!==o&&o}defaultCompletion(t,e,s,i){const n=this.command.getCommandHandlers();for(let e=0,s=t.length;e<s;++e)if(n[t[e]]&&n[t[e]].builder){const s=n[t[e]].builder;if(x(s)){this.indexAfterLastReset=e+1;const t=this.yargs.getInternalMethods().reset();return s(t,!0),t.argv}}const r=[];this.commandCompletions(r,t,s),this.optionCompletions(r,t,e,s),this.choicesFromOptionsCompletions(r,t,e,s),this.choicesFromPositionalsCompletions(r,t,e,s),i(null,r)}commandCompletions(t,e,s){const i=this.yargs.getInternalMethods().getContext().commands;s.match(/^-/)||i[i.length-1]===s||this.previousArgHasChoices(e)||this.usage.getCommands().forEach((s=>{const i=o(s[0]).cmd;if(-1===e.indexOf(i))if(this.zshShell){const e=s[1]||"";t.push(i.replace(/:/g,"\\:")+":"+e)}else t.push(i)}))}optionCompletions(t,e,s,i){if((i.match(/^-/)||""===i&&0===t.length)&&!this.previousArgHasChoices(e)){const s=this.yargs.getOptions(),n=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((r=>{const o=!!s.configuration["boolean-negation"]&&s.boolean.includes(r);n.includes(r)||s.hiddenOptions.includes(r)||this.argsContainKey(e,r,o)||(this.completeOptionKey(r,t,i),o&&s.default[r]&&this.completeOptionKey(`no-${r}`,t,i))}))}}choicesFromOptionsCompletions(t,e,s,i){if(this.previousArgHasChoices(e)){const s=this.getPreviousArgChoices(e);s&&s.length>0&&t.push(...s.map((t=>t.replace(/:/g,"\\:"))))}}choicesFromPositionalsCompletions(t,e,s,i){if(""===i&&t.length>0&&this.previousArgHasChoices(e))return;const n=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=n[s._.length-r-1];if(!o)return;const a=this.yargs.getOptions().choices[o]||[];for(const e of a)e.startsWith(i)&&t.push(e.replace(/:/g,"\\:"))}getPreviousArgChoices(t){if(t.length<1)return;let e=t[t.length-1],s="";if(!e.startsWith("-")&&t.length>1&&(s=e,e=t[t.length-2]),!e.startsWith("-"))return;const i=e.replace(/^-+/,""),n=this.yargs.getOptions(),r=[i,...this.yargs.getAliases()[i]||[]];let o;for(const t of r)if(Object.prototype.hasOwnProperty.call(n.key,t)&&Array.isArray(n.choices[t])){o=n.choices[t];break}return o?o.filter((t=>!s||t.startsWith(s))):void 0}previousArgHasChoices(t){const e=this.getPreviousArgChoices(t);return void 0!==e&&e.length>0}argsContainKey(t,e,s){const i=e=>-1!==t.indexOf((/^[^0-9]$/.test(e)?"-":"--")+e);if(i(e))return!0;if(s&&i(`no-${e}`))return!0;if(this.aliases)for(const t of this.aliases[e])if(i(t))return!0;return!1}completeOptionKey(t,e,s){var i,n,r;const o=this.usage.getDescriptions(),a=!/^--/.test(s)&&(t=>/^[^0-9]$/.test(t))(t)?"-":"--";if(this.zshShell){const s=null===(i=null==this?void 0:this.aliases)||void 0===i?void 0:i[t].find((t=>{const e=o[t];return"string"==typeof e&&e.length>0})),h=s?o[s]:void 0,l=null!==(r=null!==(n=o[t])&&void 0!==n?n:h)&&void 0!==r?r:"";e.push(a+`${t.replace(/:/g,"\\:")}:${l.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`)}else e.push(a+t)}customCompletion(t,e,s,i){if(d(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(s,e);return f(t)?t.then((t=>{this.shim.process.nextTick((()=>{i(null,t)}))})).catch((t=>{this.shim.process.nextTick((()=>{i(t,void 0)}))})):i(null,t)}return function(t){return t.length>3}(this.customCompletionFunction)?this.customCompletionFunction(s,e,((n=i)=>this.defaultCompletion(t,e,s,n)),(t=>{i(null,t)})):this.customCompletionFunction(s,e,(t=>{i(null,t)}))}getCompletion(t,e){const s=t.length?t[t.length-1]:"",i=this.yargs.parse(t,!0),n=this.customCompletionFunction?i=>this.customCompletion(t,i,s,e):i=>this.defaultCompletion(t,i,s,e);return f(i)?i.then(n):n(i)}generateCompletionScript(t,e){let s=this.zshShell?'#compdef {{app_name}}\n###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc\n# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local reply\n local si=$IFS\n IFS=$\'\n\' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "${words[@]}"))\n IFS=$si\n _describe \'values\' reply\n}\ncompdef _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n':'###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc\n# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local cur_word args type_list\n\n cur_word="${COMP_WORDS[COMP_CWORD]}"\n args=("${COMP_WORDS[@]}")\n\n # ask yargs to generate completions.\n type_list=$({{app_path}} --get-yargs-completions "${args[@]}")\n\n COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )\n\n # if no match was found, fall back to filename completion\n if [ ${#COMPREPLY[@]} -eq 0 ]; then\n COMPREPLY=()\n fi\n\n return 0\n}\ncomplete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n';const i=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),s=s.replace(/{{app_name}}/g,i),s=s.replace(/{{completion_command}}/g,e),s.replace(/{{app_path}}/g,t)}registerFunction(t){this.customCompletionFunction=t}setParsed(t){this.aliases=t.aliases}}function N(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;const s=[];let i,n;for(i=0;i<=e.length;i++)s[i]=[i];for(n=0;n<=t.length;n++)s[0][n]=n;for(i=1;i<=e.length;i++)for(n=1;n<=t.length;n++)e.charAt(i-1)===t.charAt(n-1)?s[i][n]=s[i-1][n-1]:i>1&&n>1&&e.charAt(i-2)===t.charAt(n-1)&&e.charAt(i-1)===t.charAt(n-2)?s[i][n]=s[i-2][n-2]+1:s[i][n]=Math.min(s[i-1][n-1]+1,Math.min(s[i][n-1]+1,s[i-1][n]+1));return s[e.length][t.length]}const H=["$0","--","_"];var z,W,q,U,F,L,V,G,R,T,B,K,Y,J,Z,X,Q,tt,et,st,it,nt,rt,ot,at,ht,lt,ct,ft,dt,ut,pt,gt,mt,yt;const bt=Symbol("copyDoubleDash"),vt=Symbol("copyDoubleDash"),Ot=Symbol("deleteFromParserHintObject"),wt=Symbol("emitWarning"),Ct=Symbol("freeze"),jt=Symbol("getDollarZero"),Mt=Symbol("getParserConfiguration"),_t=Symbol("getUsageConfiguration"),kt=Symbol("guessLocale"),xt=Symbol("guessVersion"),Et=Symbol("parsePositionalNumbers"),At=Symbol("pkgUp"),Pt=Symbol("populateParserHintArray"),St=Symbol("populateParserHintSingleValueDictionary"),$t=Symbol("populateParserHintArrayDictionary"),It=Symbol("populateParserHintDictionary"),Dt=Symbol("sanitizeKey"),Nt=Symbol("setKey"),Ht=Symbol("unfreeze"),zt=Symbol("validateAsync"),Wt=Symbol("getCommandInstance"),qt=Symbol("getContext"),Ut=Symbol("getHasOutput"),Ft=Symbol("getLoggerInstance"),Lt=Symbol("getParseContext"),Vt=Symbol("getUsageInstance"),Gt=Symbol("getValidationInstance"),Rt=Symbol("hasParseCallback"),Tt=Symbol("isGlobalContext"),Bt=Symbol("postProcess"),Kt=Symbol("rebase"),Yt=Symbol("reset"),Jt=Symbol("runYargsParserAndExecuteCommands"),Zt=Symbol("runValidation"),Xt=Symbol("setHasOutput"),Qt=Symbol("kTrackManuallySetKeys");class te{constructor(t=[],e,s,i){this.customScriptName=!1,this.parsed=!1,z.set(this,void 0),W.set(this,void 0),q.set(this,{commands:[],fullCommands:[]}),U.set(this,null),F.set(this,null),L.set(this,"show-hidden"),V.set(this,null),G.set(this,!0),R.set(this,{}),T.set(this,!0),B.set(this,[]),K.set(this,void 0),Y.set(this,{}),J.set(this,!1),Z.set(this,null),X.set(this,!0),Q.set(this,void 0),tt.set(this,""),et.set(this,void 0),st.set(this,void 0),it.set(this,{}),nt.set(this,null),rt.set(this,null),ot.set(this,{}),at.set(this,{}),ht.set(this,void 0),lt.set(this,!1),ct.set(this,void 0),ft.set(this,!1),dt.set(this,!1),ut.set(this,!1),pt.set(this,void 0),gt.set(this,{}),mt.set(this,null),yt.set(this,void 0),O(this,ct,i,"f"),O(this,ht,t,"f"),O(this,W,e,"f"),O(this,st,s,"f"),O(this,K,new w(this),"f"),this.$0=this[jt](),this[Yt](),O(this,z,v(this,z,"f"),"f"),O(this,pt,v(this,pt,"f"),"f"),O(this,yt,v(this,yt,"f"),"f"),O(this,et,v(this,et,"f"),"f"),v(this,et,"f").showHiddenOpt=v(this,L,"f"),O(this,Q,this[vt](),"f")}addHelpOpt(t,e){return h("[string|boolean] [string]",[t,e],arguments.length),v(this,Z,"f")&&(this[Ot](v(this,Z,"f")),O(this,Z,null,"f")),!1===t&&void 0===e||(O(this,Z,"string"==typeof t?t:"help","f"),this.boolean(v(this,Z,"f")),this.describe(v(this,Z,"f"),e||v(this,pt,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(h("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const s="string"==typeof t?t:v(this,L,"f");return this.boolean(s),this.describe(s,e||v(this,pt,"f").deferY18nLookup("Show hidden options")),v(this,et,"f").showHiddenOpt=s,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return h("<object|string|array> [string|array]",[t,e],arguments.length),this[$t](this.alias.bind(this),"alias",t,e),this}array(t){return h("<array|string>",[t],arguments.length),this[Pt]("array",t),this[Qt](t),this}boolean(t){return h("<array|string>",[t],arguments.length),this[Pt]("boolean",t),this[Qt](t),this}check(t,e){return h("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,s)=>j((()=>t(e,s.getOptions())),(s=>(s?("string"==typeof s||s instanceof Error)&&v(this,pt,"f").fail(s.toString(),s):v(this,pt,"f").fail(v(this,ct,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(v(this,pt,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return h("<object|string|array> [string|array]",[t,e],arguments.length),this[$t](this.choices.bind(this),"choices",t,e),this}coerce(t,s){if(h("<object|string|array> [function]",[t,s],arguments.length),Array.isArray(t)){if(!s)throw new e("coerce callback must be provided");for(const e of t)this.coerce(e,s);return this}if("object"==typeof t){for(const e of Object.keys(t))this.coerce(e,t[e]);return this}if(!s)throw new e("coerce callback must be provided");return v(this,et,"f").key[t]=!0,v(this,K,"f").addCoerceMiddleware(((i,n)=>{let r;return Object.prototype.hasOwnProperty.call(i,t)?j((()=>(r=n.getAliases(),s(i[t]))),(e=>{i[t]=e;const s=n.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&!0!==s)for(const s of r[t])i[s]=e;return i}),(t=>{throw new e(t.message)})):i}),t),this}conflicts(t,e){return h("<string|object> [string|array]",[t,e],arguments.length),v(this,yt,"f").conflicts(t,e),this}config(t="config",e,s){return h("[object|string] [string|function] [function]",[t,e,s],arguments.length),"object"!=typeof t||Array.isArray(t)?("function"==typeof e&&(s=e,e=void 0),this.describe(t,e||v(this,pt,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{v(this,et,"f").config[t]=s||!0})),this):(t=n(t,v(this,W,"f"),this[Mt]()["deep-merge-config"]||!1,v(this,ct,"f")),v(this,et,"f").configObjects=(v(this,et,"f").configObjects||[]).concat(t),this)}completion(t,e,s){return h("[string] [string|boolean|function] [function]",[t,e,s],arguments.length),"function"==typeof e&&(s=e,e=void 0),O(this,F,t||v(this,F,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(v(this,F,"f"),e),s&&v(this,U,"f").registerFunction(s),this}command(t,e,s,i,n,r){return h("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,s,i,n,r],arguments.length),v(this,z,"f").addHandler(t,e,s,i,n,r),this}commands(t,e,s,i,n,r){return this.command(t,e,s,i,n,r)}commandDir(t,e){h("<string> [object]",[t,e],arguments.length);const s=v(this,st,"f")||v(this,ct,"f").require;return v(this,z,"f").addDirectory(t,s,v(this,ct,"f").getCallerFile(),e),this}count(t){return h("<array|string>",[t],arguments.length),this[Pt]("count",t),this[Qt](t),this}default(t,e,s){return h("<object|string|array> [*] [string]",[t,e,s],arguments.length),s&&(u(t,v(this,ct,"f")),v(this,et,"f").defaultDescription[t]=s),"function"==typeof e&&(u(t,v(this,ct,"f")),v(this,et,"f").defaultDescription[t]||(v(this,et,"f").defaultDescription[t]=v(this,pt,"f").functionDescription(e)),e=e.call()),this[St](this.default.bind(this),"default",t,e),this}defaults(t,e,s){return this.default(t,e,s)}demandCommand(t=1,e,s,i){return h("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,s,i],arguments.length),"number"!=typeof e&&(s=e,e=1/0),this.global("_",!1),v(this,et,"f").demandedCommands._={min:t,max:e,minMsg:s,maxMsg:i},this}demand(t,e,s){return Array.isArray(e)?(e.forEach((t=>{d(s,!0,v(this,ct,"f")),this.demandOption(t,s)})),e=1/0):"number"!=typeof e&&(s=e,e=1/0),"number"==typeof t?(d(s,!0,v(this,ct,"f")),this.demandCommand(t,e,s,s)):Array.isArray(t)?t.forEach((t=>{d(s,!0,v(this,ct,"f")),this.demandOption(t,s)})):"string"==typeof s?this.demandOption(t,s):!0!==s&&void 0!==s||this.demandOption(t),this}demandOption(t,e){return h("<object|string|array> [string]",[t,e],arguments.length),this[St](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return h("<string> [string|boolean]",[t,e],arguments.length),v(this,et,"f").deprecatedOptions[t]=e,this}describe(t,e){return h("<object|string|array> [string]",[t,e],arguments.length),this[Nt](t,!0),v(this,pt,"f").describe(t,e),this}detectLocale(t){return h("<boolean>",[t],arguments.length),O(this,G,t,"f"),this}env(t){return h("[string|boolean]",[t],arguments.length),!1===t?delete v(this,et,"f").envPrefix:v(this,et,"f").envPrefix=t||"",this}epilogue(t){return h("<string>",[t],arguments.length),v(this,pt,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return h("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):v(this,pt,"f").example(t,e),this}exit(t,e){O(this,J,!0,"f"),O(this,V,e,"f"),v(this,T,"f")&&v(this,ct,"f").process.exit(t)}exitProcess(t=!0){return h("[boolean]",[t],arguments.length),O(this,T,t,"f"),this}fail(t){if(h("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new e("Invalid first argument. Expected function or boolean 'false'");return v(this,pt,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return h("<array> [function]",[t,e],arguments.length),e?v(this,U,"f").getCompletion(t,e):new Promise(((e,s)=>{v(this,U,"f").getCompletion(t,((t,i)=>{t?s(t):e(i)}))}))}getDemandedOptions(){return h([],0),v(this,et,"f").demandedOptions}getDemandedCommands(){return h([],0),v(this,et,"f").demandedCommands}getDeprecatedOptions(){return h([],0),v(this,et,"f").deprecatedOptions}getDetectLocale(){return v(this,G,"f")}getExitProcess(){return v(this,T,"f")}getGroups(){return Object.assign({},v(this,Y,"f"),v(this,at,"f"))}getHelp(){if(O(this,J,!0,"f"),!v(this,pt,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[Jt](v(this,ht,"f"),void 0,void 0,0,!0);if(f(t))return t.then((()=>v(this,pt,"f").help()))}const t=v(this,z,"f").runDefaultBuilderOn(this);if(f(t))return t.then((()=>v(this,pt,"f").help()))}return Promise.resolve(v(this,pt,"f").help())}getOptions(){return v(this,et,"f")}getStrict(){return v(this,ft,"f")}getStrictCommands(){return v(this,dt,"f")}getStrictOptions(){return v(this,ut,"f")}global(t,e){return h("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?v(this,et,"f").local=v(this,et,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{v(this,et,"f").local.includes(t)||v(this,et,"f").local.push(t)})),this}group(t,e){h("<string|array> <string>",[t,e],arguments.length);const s=v(this,at,"f")[e]||v(this,Y,"f")[e];v(this,at,"f")[e]&&delete v(this,at,"f")[e];const i={};return v(this,Y,"f")[e]=(s||[]).concat(t).filter((t=>!i[t]&&(i[t]=!0))),this}hide(t){return h("<string>",[t],arguments.length),v(this,et,"f").hiddenOptions.push(t),this}implies(t,e){return h("<string|object> [number|string|array]",[t,e],arguments.length),v(this,yt,"f").implies(t,e),this}locale(t){return h("[string]",[t],arguments.length),void 0===t?(this[kt](),v(this,ct,"f").y18n.getLocale()):(O(this,G,!1,"f"),v(this,ct,"f").y18n.setLocale(t),this)}middleware(t,e,s){return v(this,K,"f").addMiddleware(t,!!e,s)}nargs(t,e){return h("<string|object|array> [number]",[t,e],arguments.length),this[St](this.nargs.bind(this),"narg",t,e),this}normalize(t){return h("<array|string>",[t],arguments.length),this[Pt]("normalize",t),this}number(t){return h("<array|string>",[t],arguments.length),this[Pt]("number",t),this[Qt](t),this}option(t,e){if(h("<string|object> [object]",[t,e],arguments.length),"object"==typeof t)Object.keys(t).forEach((e=>{this.options(e,t[e])}));else{"object"!=typeof e&&(e={}),this[Qt](t),!v(this,mt,"f")||"version"!==t&&"version"!==(null==e?void 0:e.alias)||this[wt](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join("\n"),void 0,"versionWarning"),v(this,et,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);const s=e.deprecate||e.deprecated;s&&this.deprecateOption(t,s);const i=e.demand||e.required||e.require;i&&this.demand(t,i),e.demandOption&&this.demandOption(t,"string"==typeof e.demandOption?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),void 0!==e.implies&&this.implies(t,e.implies),void 0!==e.nargs&&this.nargs(t,e.nargs),e.config&&this.config(t,e.configParser),e.normalize&&this.normalize(t),e.choices&&this.choices(t,e.choices),e.coerce&&this.coerce(t,e.coerce),e.group&&this.group(t,e.group),(e.boolean||"boolean"===e.type)&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||"array"===e.type)&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||"number"===e.type)&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||"string"===e.type)&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||"count"===e.type)&&this.count(t),"boolean"==typeof e.global&&this.global(t,e.global),e.defaultDescription&&(v(this,et,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const n=e.describe||e.description||e.desc,r=v(this,pt,"f").getDescriptions();Object.prototype.hasOwnProperty.call(r,t)&&"string"!=typeof n||this.describe(t,n),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,s){h("[string|array] [function|boolean|object] [function]",[t,e,s],arguments.length),this[Ct](),void 0===t&&(t=v(this,ht,"f")),"object"==typeof e&&(O(this,rt,e,"f"),e=s),"function"==typeof e&&(O(this,nt,e,"f"),e=!1),e||O(this,ht,t,"f"),v(this,nt,"f")&&O(this,T,!1,"f");const i=this[Jt](t,!!e),n=this.parsed;return v(this,U,"f").setParsed(this.parsed),f(i)?i.then((t=>(v(this,nt,"f")&&v(this,nt,"f").call(this,v(this,V,"f"),t,v(this,tt,"f")),t))).catch((t=>{throw v(this,nt,"f")&&v(this,nt,"f")(t,this.parsed.argv,v(this,tt,"f")),t})).finally((()=>{this[Ht](),this.parsed=n})):(v(this,nt,"f")&&v(this,nt,"f").call(this,v(this,V,"f"),i,v(this,tt,"f")),this[Ht](),this.parsed=n,i)}parseAsync(t,e,s){const i=this.parse(t,e,s);return f(i)?i:Promise.resolve(i)}parseSync(t,s,i){const n=this.parse(t,s,i);if(f(n))throw new e(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return n}parserConfiguration(t){return h("<object>",[t],arguments.length),O(this,it,t,"f"),this}pkgConf(t,e){h("<string> [string]",[t,e],arguments.length);let s=null;const i=this[At](e||v(this,W,"f"));return i[t]&&"object"==typeof i[t]&&(s=n(i[t],e||v(this,W,"f"),this[Mt]()["deep-merge-config"]||!1,v(this,ct,"f")),v(this,et,"f").configObjects=(v(this,et,"f").configObjects||[]).concat(s)),this}positional(t,e){h("<string> <object>",[t,e],arguments.length);const s=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=g(e,((t,e)=>!("type"===t&&!["string","number","boolean"].includes(e))&&s.includes(t)));const i=v(this,q,"f").fullCommands[v(this,q,"f").fullCommands.length-1],n=i?v(this,z,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return p(n).forEach((s=>{const i=n[s];Array.isArray(i)?-1!==i.indexOf(t)&&(e[s]=!0):i[t]&&!(s in e)&&(e[s]=i[t])})),this.group(t,v(this,pt,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return h("[boolean]",[t],arguments.length),O(this,lt,t,"f"),this}required(t,e,s){return this.demand(t,e,s)}require(t,e,s){return this.demand(t,e,s)}requiresArg(t){return h("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&v(this,et,"f").narg[t]||this[St](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return h("[string] [string]",[t,e],arguments.length),t=t||this.$0,v(this,Q,"f").log(v(this,U,"f").generateCompletionScript(t,e||v(this,F,"f")||"completion")),this}showHelp(t){if(h("[string|function]",[t],arguments.length),O(this,J,!0,"f"),!v(this,pt,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[Jt](v(this,ht,"f"),void 0,void 0,0,!0);if(f(e))return e.then((()=>{v(this,pt,"f").showHelp(t)})),this}const e=v(this,z,"f").runDefaultBuilderOn(this);if(f(e))return e.then((()=>{v(this,pt,"f").showHelp(t)})),this}return v(this,pt,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return h("[boolean|string] [string]",[t,e],arguments.length),v(this,pt,"f").showHelpOnFail(t,e),this}showVersion(t){return h("[string|function]",[t],arguments.length),v(this,pt,"f").showVersion(t),this}skipValidation(t){return h("<array|string>",[t],arguments.length),this[Pt]("skipValidation",t),this}strict(t){return h("[boolean]",[t],arguments.length),O(this,ft,!1!==t,"f"),this}strictCommands(t){return h("[boolean]",[t],arguments.length),O(this,dt,!1!==t,"f"),this}strictOptions(t){return h("[boolean]",[t],arguments.length),O(this,ut,!1!==t,"f"),this}string(t){return h("<array|string>",[t],arguments.length),this[Pt]("string",t),this[Qt](t),this}terminalWidth(){return h([],0),v(this,ct,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return h("<object>",[t],arguments.length),O(this,G,!1,"f"),v(this,ct,"f").y18n.updateLocale(t),this}usage(t,s,i,n){if(h("<string|null|undefined> [string|boolean] [function|object] [function]",[t,s,i,n],arguments.length),void 0!==s){if(d(t,null,v(this,ct,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,s,i,n);throw new e(".usage() description must start with $0 if being used as alias for .command()")}return v(this,pt,"f").usage(t),this}usageConfiguration(t){return h("<object>",[t],arguments.length),O(this,gt,t,"f"),this}version(t,e,s){const i="version";if(h("[boolean|string] [string] [string]",[t,e,s],arguments.length),v(this,mt,"f")&&(this[Ot](v(this,mt,"f")),v(this,pt,"f").version(void 0),O(this,mt,null,"f")),0===arguments.length)s=this[xt](),t=i;else if(1===arguments.length){if(!1===t)return this;s=t,t=i}else 2===arguments.length&&(s=e,e=void 0);return O(this,mt,"string"==typeof t?t:i,"f"),e=e||v(this,pt,"f").deferY18nLookup("Show version number"),v(this,pt,"f").version(s||void 0),this.boolean(v(this,mt,"f")),this.describe(v(this,mt,"f"),e),this}wrap(t){return h("<number|null|undefined>",[t],arguments.length),v(this,pt,"f").wrap(t),this}[(z=new WeakMap,W=new WeakMap,q=new WeakMap,U=new WeakMap,F=new WeakMap,L=new WeakMap,V=new WeakMap,G=new WeakMap,R=new WeakMap,T=new WeakMap,B=new WeakMap,K=new WeakMap,Y=new WeakMap,J=new WeakMap,Z=new WeakMap,X=new WeakMap,Q=new WeakMap,tt=new WeakMap,et=new WeakMap,st=new WeakMap,it=new WeakMap,nt=new WeakMap,rt=new WeakMap,ot=new WeakMap,at=new WeakMap,ht=new WeakMap,lt=new WeakMap,ct=new WeakMap,ft=new WeakMap,dt=new WeakMap,ut=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,yt=new WeakMap,bt)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[vt](){return{log:(...t)=>{this[Rt]()||console.log(...t),O(this,J,!0,"f"),v(this,tt,"f").length&&O(this,tt,v(this,tt,"f")+"\n","f"),O(this,tt,v(this,tt,"f")+t.join(" "),"f")},error:(...t)=>{this[Rt]()||console.error(...t),O(this,J,!0,"f"),v(this,tt,"f").length&&O(this,tt,v(this,tt,"f")+"\n","f"),O(this,tt,v(this,tt,"f")+t.join(" "),"f")}}}[Ot](t){p(v(this,et,"f")).forEach((e=>{if("configObjects"===e)return;const s=v(this,et,"f")[e];Array.isArray(s)?s.includes(t)&&s.splice(s.indexOf(t),1):"object"==typeof s&&delete s[t]})),delete v(this,pt,"f").getDescriptions()[t]}[wt](t,e,s){v(this,R,"f")[s]||(v(this,ct,"f").process.emitWarning(t,e),v(this,R,"f")[s]=!0)}[Ct](){v(this,B,"f").push({options:v(this,et,"f"),configObjects:v(this,et,"f").configObjects.slice(0),exitProcess:v(this,T,"f"),groups:v(this,Y,"f"),strict:v(this,ft,"f"),strictCommands:v(this,dt,"f"),strictOptions:v(this,ut,"f"),completionCommand:v(this,F,"f"),output:v(this,tt,"f"),exitError:v(this,V,"f"),hasOutput:v(this,J,"f"),parsed:this.parsed,parseFn:v(this,nt,"f"),parseContext:v(this,rt,"f")}),v(this,pt,"f").freeze(),v(this,yt,"f").freeze(),v(this,z,"f").freeze(),v(this,K,"f").freeze()}[jt](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(v(this,ct,"f").process.argv()[0])?v(this,ct,"f").process.argv().slice(1,2):v(this,ct,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[Kt](v(this,W,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),v(this,ct,"f").getEnv("_")&&v(this,ct,"f").getProcessArgvBin()===v(this,ct,"f").getEnv("_")&&(e=v(this,ct,"f").getEnv("_").replace(`${v(this,ct,"f").path.dirname(v(this,ct,"f").process.execPath())}/`,"")),e}[Mt](){return v(this,it,"f")}[_t](){return v(this,gt,"f")}[kt](){if(!v(this,G,"f"))return;const t=v(this,ct,"f").getEnv("LC_ALL")||v(this,ct,"f").getEnv("LC_MESSAGES")||v(this,ct,"f").getEnv("LANG")||v(this,ct,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[xt](){return this[At]().version||"unknown"}[Et](t){const e=t["--"]?t["--"]:t._;for(let t,s=0;void 0!==(t=e[s]);s++)v(this,ct,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[s]=Number(t));return t}[At](t){const e=t||"*";if(v(this,ot,"f")[e])return v(this,ot,"f")[e];let s={};try{let e=t||v(this,ct,"f").mainFilename;!t&&v(this,ct,"f").path.extname(e)&&(e=v(this,ct,"f").path.dirname(e));const i=v(this,ct,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));d(i,void 0,v(this,ct,"f")),s=JSON.parse(v(this,ct,"f").readFileSync(i,"utf8"))}catch(t){}return v(this,ot,"f")[e]=s||{},v(this,ot,"f")[e]}[Pt](t,e){(e=[].concat(e)).forEach((e=>{e=this[Dt](e),v(this,et,"f")[t].push(e)}))}[St](t,e,s,i){this[It](t,e,s,i,((t,e,s)=>{v(this,et,"f")[t][e]=s}))}[$t](t,e,s,i){this[It](t,e,s,i,((t,e,s)=>{v(this,et,"f")[t][e]=(v(this,et,"f")[t][e]||[]).concat(s)}))}[It](t,e,s,i,n){if(Array.isArray(s))s.forEach((e=>{t(e,i)}));else if((t=>"object"==typeof t)(s))for(const e of p(s))t(e,s[e]);else n(e,this[Dt](s),i)}[Dt](t){return"__proto__"===t?"___proto___":t}[Nt](t,e){return this[St](this[Nt].bind(this),"key",t,e),this}[Ht](){var t,e,s,i,n,r,o,a,h,l,c,f;const u=v(this,B,"f").pop();let p;d(u,void 0,v(this,ct,"f")),t=this,e=this,s=this,i=this,n=this,r=this,o=this,a=this,h=this,l=this,c=this,f=this,({options:{set value(e){O(t,et,e,"f")}}.value,configObjects:p,exitProcess:{set value(t){O(e,T,t,"f")}}.value,groups:{set value(t){O(s,Y,t,"f")}}.value,output:{set value(t){O(i,tt,t,"f")}}.value,exitError:{set value(t){O(n,V,t,"f")}}.value,hasOutput:{set value(t){O(r,J,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){O(o,ft,t,"f")}}.value,strictCommands:{set value(t){O(a,dt,t,"f")}}.value,strictOptions:{set value(t){O(h,ut,t,"f")}}.value,completionCommand:{set value(t){O(l,F,t,"f")}}.value,parseFn:{set value(t){O(c,nt,t,"f")}}.value,parseContext:{set value(t){O(f,rt,t,"f")}}.value}=u),v(this,et,"f").configObjects=p,v(this,pt,"f").unfreeze(),v(this,yt,"f").unfreeze(),v(this,z,"f").unfreeze(),v(this,K,"f").unfreeze()}[zt](t,e){return j(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[Wt].bind(this),getContext:this[qt].bind(this),getHasOutput:this[Ut].bind(this),getLoggerInstance:this[Ft].bind(this),getParseContext:this[Lt].bind(this),getParserConfiguration:this[Mt].bind(this),getUsageConfiguration:this[_t].bind(this),getUsageInstance:this[Vt].bind(this),getValidationInstance:this[Gt].bind(this),hasParseCallback:this[Rt].bind(this),isGlobalContext:this[Tt].bind(this),postProcess:this[Bt].bind(this),reset:this[Yt].bind(this),runValidation:this[Zt].bind(this),runYargsParserAndExecuteCommands:this[Jt].bind(this),setHasOutput:this[Xt].bind(this)}}[Wt](){return v(this,z,"f")}[qt](){return v(this,q,"f")}[Ut](){return v(this,J,"f")}[Ft](){return v(this,Q,"f")}[Lt](){return v(this,rt,"f")||{}}[Vt](){return v(this,pt,"f")}[Gt](){return v(this,yt,"f")}[Rt](){return!!v(this,nt,"f")}[Tt](){return v(this,X,"f")}[Bt](t,e,s,i){if(s)return t;if(f(t))return t;e||(t=this[bt](t));return(this[Mt]()["parse-positional-numbers"]||void 0===this[Mt]()["parse-positional-numbers"])&&(t=this[Et](t)),i&&(t=C(t,this,v(this,K,"f").getMiddleware(),!1)),t}[Yt](t={}){O(this,et,v(this,et,"f")||{},"f");const e={};e.local=v(this,et,"f").local||[],e.configObjects=v(this,et,"f").configObjects||[];const s={};e.local.forEach((e=>{s[e]=!0,(t[e]||[]).forEach((t=>{s[t]=!0}))})),Object.assign(v(this,at,"f"),Object.keys(v(this,Y,"f")).reduce(((t,e)=>{const i=v(this,Y,"f")[e].filter((t=>!(t in s)));return i.length>0&&(t[e]=i),t}),{})),O(this,Y,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(v(this,et,"f")[t]||[]).filter((t=>!s[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=g(v(this,et,"f")[t],(t=>!s[t]))})),e.envPrefix=v(this,et,"f").envPrefix,O(this,et,e,"f"),O(this,pt,v(this,pt,"f")?v(this,pt,"f").reset(s):P(this,v(this,ct,"f")),"f"),O(this,yt,v(this,yt,"f")?v(this,yt,"f").reset(s):function(t,e,s){const i=s.y18n.__,n=s.y18n.__n,r={nonOptionCount:function(s){const i=t.getDemandedCommands(),r=s._.length+(s["--"]?s["--"].length:0)-t.getInternalMethods().getContext().commands.length;i._&&(r<i._.min||r>i._.max)&&(r<i._.min?void 0!==i._.minMsg?e.fail(i._.minMsg?i._.minMsg.replace(/\$0/g,r.toString()).replace(/\$1/,i._.min.toString()):null):e.fail(n("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",r,r.toString(),i._.min.toString())):r>i._.max&&(void 0!==i._.maxMsg?e.fail(i._.maxMsg?i._.maxMsg.replace(/\$0/g,r.toString()).replace(/\$1/,i._.max.toString()):null):e.fail(n("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",r,r.toString(),i._.max.toString()))))},positionalCount:function(t,s){s<t&&e.fail(n("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",s,s+"",t+""))},requiredArguments:function(t,s){let i=null;for(const e of Object.keys(s))Object.prototype.hasOwnProperty.call(t,e)&&void 0!==t[e]||(i=i||{},i[e]=s[e]);if(i){const t=[];for(const e of Object.keys(i)){const s=i[e];s&&t.indexOf(s)<0&&t.push(s)}const s=t.length?`\n${t.join("\n")}`:"";e.fail(n("Missing required argument: %s","Missing required arguments: %s",Object.keys(i).length,Object.keys(i).join(", ")+s))}},unknownArguments:function(s,i,o,a,h=!0){var l;const c=t.getInternalMethods().getCommandInstance().getCommands(),f=[],d=t.getInternalMethods().getContext();if(Object.keys(s).forEach((e=>{H.includes(e)||Object.prototype.hasOwnProperty.call(o,e)||Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),e)||r.isValidAndSomeAliasIsNotNew(e,i)||f.push(e)})),h&&(d.commands.length>0||c.length>0||a)&&s._.slice(d.commands.length).forEach((t=>{c.includes(""+t)||f.push(""+t)})),h){const e=(null===(l=t.getDemandedCommands()._)||void 0===l?void 0:l.max)||0,i=d.commands.length+e;i<s._.length&&s._.slice(i).forEach((t=>{t=String(t),d.commands.includes(t)||f.includes(t)||f.push(t)}))}f.length&&e.fail(n("Unknown argument: %s","Unknown arguments: %s",f.length,f.map((t=>t.trim()?t:`"${t}"`)).join(", ")))},unknownCommands:function(s){const i=t.getInternalMethods().getCommandInstance().getCommands(),r=[],o=t.getInternalMethods().getContext();return(o.commands.length>0||i.length>0)&&s._.slice(o.commands.length).forEach((t=>{i.includes(""+t)||r.push(""+t)})),r.length>0&&(e.fail(n("Unknown command: %s","Unknown commands: %s",r.length,r.join(", "))),!0)},isValidAndSomeAliasIsNotNew:function(e,s){if(!Object.prototype.hasOwnProperty.call(s,e))return!1;const i=t.parsed.newAliases;return[e,...s[e]].some((t=>!Object.prototype.hasOwnProperty.call(i,t)||!i[e]))},limitedChoices:function(s){const n=t.getOptions(),r={};if(!Object.keys(n.choices).length)return;Object.keys(s).forEach((t=>{-1===H.indexOf(t)&&Object.prototype.hasOwnProperty.call(n.choices,t)&&[].concat(s[t]).forEach((e=>{-1===n.choices[t].indexOf(e)&&void 0!==e&&(r[t]=(r[t]||[]).concat(e))}))}));const o=Object.keys(r);if(!o.length)return;let a=i("Invalid values:");o.forEach((t=>{a+=`\n ${i("Argument: %s, Given: %s, Choices: %s",t,e.stringifiedValues(r[t]),e.stringifiedValues(n.choices[t]))}`})),e.fail(a)}};let o={};function a(t,e){const s=Number(e);return"number"==typeof(e=isNaN(s)?e:s)?e=t._.length>=e:e.match(/^--no-.+/)?(e=e.match(/^--no-(.+)/)[1],e=!Object.prototype.hasOwnProperty.call(t,e)):e=Object.prototype.hasOwnProperty.call(t,e),e}r.implies=function(e,i){h("<string|object> [array|number|string]",[e,i],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.implies(t,e[t])})):(t.global(e),o[e]||(o[e]=[]),Array.isArray(i)?i.forEach((t=>r.implies(e,t))):(d(i,void 0,s),o[e].push(i)))},r.getImplied=function(){return o},r.implications=function(t){const s=[];if(Object.keys(o).forEach((e=>{const i=e;(o[e]||[]).forEach((e=>{let n=i;const r=e;n=a(t,n),e=a(t,e),n&&!e&&s.push(` ${i} -> ${r}`)}))})),s.length){let t=`${i("Implications failed:")}\n`;s.forEach((e=>{t+=e})),e.fail(t)}};let l={};r.conflicts=function(e,s){h("<string|object> [array|string]",[e,s],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.conflicts(t,e[t])})):(t.global(e),l[e]||(l[e]=[]),Array.isArray(s)?s.forEach((t=>r.conflicts(e,t))):l[e].push(s))},r.getConflicting=()=>l,r.conflicting=function(n){Object.keys(n).forEach((t=>{l[t]&&l[t].forEach((s=>{s&&void 0!==n[t]&&void 0!==n[s]&&e.fail(i("Arguments %s and %s are mutually exclusive",t,s))}))})),t.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(l).forEach((t=>{l[t].forEach((r=>{r&&void 0!==n[s.Parser.camelCase(t)]&&void 0!==n[s.Parser.camelCase(r)]&&e.fail(i("Arguments %s and %s are mutually exclusive",t,r))}))}))},r.recommendCommands=function(t,s){s=s.sort(((t,e)=>e.length-t.length));let n=null,r=1/0;for(let e,i=0;void 0!==(e=s[i]);i++){const s=N(t,e);s<=3&&s<r&&(r=s,n=e)}n&&e.fail(i("Did you mean %s?",n))},r.reset=function(t){return o=g(o,(e=>!t[e])),l=g(l,(e=>!t[e])),r};const c=[];return r.freeze=function(){c.push({implied:o,conflicting:l})},r.unfreeze=function(){const t=c.pop();d(t,void 0,s),({implied:o,conflicting:l}=t)},r}(this,v(this,pt,"f"),v(this,ct,"f")),"f"),O(this,z,v(this,z,"f")?v(this,z,"f").reset():function(t,e,s,i){return new _(t,e,s,i)}(v(this,pt,"f"),v(this,yt,"f"),v(this,K,"f"),v(this,ct,"f")),"f"),v(this,U,"f")||O(this,U,function(t,e,s,i){return new D(t,e,s,i)}(this,v(this,pt,"f"),v(this,z,"f"),v(this,ct,"f")),"f"),v(this,K,"f").reset(),O(this,F,null,"f"),O(this,tt,"","f"),O(this,V,null,"f"),O(this,J,!1,"f"),this.parsed=!1,this}[Kt](t,e){return v(this,ct,"f").path.relative(t,e)}[Jt](t,s,i,n=0,r=!1){let o=!!i||r;t=t||v(this,ht,"f"),v(this,et,"f").__=v(this,ct,"f").y18n.__,v(this,et,"f").configuration=this[Mt]();const a=!!v(this,et,"f").configuration["populate--"],h=Object.assign({},v(this,et,"f").configuration,{"populate--":!0}),l=v(this,ct,"f").Parser.detailed(t,Object.assign({},v(this,et,"f"),{configuration:{"parse-positional-numbers":!1,...h}})),c=Object.assign(l.argv,v(this,rt,"f"));let d;const u=l.aliases;let p=!1,g=!1;Object.keys(c).forEach((t=>{t===v(this,Z,"f")&&c[t]?p=!0:t===v(this,mt,"f")&&c[t]&&(g=!0)})),c.$0=this.$0,this.parsed=l,0===n&&v(this,pt,"f").clearCachedHelpMessage();try{if(this[kt](),s)return this[Bt](c,a,!!i,!1);if(v(this,Z,"f")){[v(this,Z,"f")].concat(u[v(this,Z,"f")]||[]).filter((t=>t.length>1)).includes(""+c._[c._.length-1])&&(c._.pop(),p=!0)}O(this,X,!1,"f");const h=v(this,z,"f").getCommands(),m=v(this,U,"f").completionKey in c,y=p||m||r;if(c._.length){if(h.length){let t;for(let e,s=n||0;void 0!==c._[s];s++){if(e=String(c._[s]),h.includes(e)&&e!==v(this,F,"f")){const t=v(this,z,"f").runCommand(e,this,l,s+1,r,p||g||r);return this[Bt](t,a,!!i,!1)}if(!t&&e!==v(this,F,"f")){t=e;break}}!v(this,z,"f").hasDefaultCommand()&&v(this,lt,"f")&&t&&!y&&v(this,yt,"f").recommendCommands(t,h)}v(this,F,"f")&&c._.includes(v(this,F,"f"))&&!m&&(v(this,T,"f")&&E(!0),this.showCompletionScript(),this.exit(0))}if(v(this,z,"f").hasDefaultCommand()&&!y){const t=v(this,z,"f").runCommand(null,this,l,0,r,p||g||r);return this[Bt](t,a,!!i,!1)}if(m){v(this,T,"f")&&E(!0);const s=(t=[].concat(t)).slice(t.indexOf(`--${v(this,U,"f").completionKey}`)+1);return v(this,U,"f").getCompletion(s,((t,s)=>{if(t)throw new e(t.message);(s||[]).forEach((t=>{v(this,Q,"f").log(t)})),this.exit(0)})),this[Bt](c,!a,!!i,!1)}if(v(this,J,"f")||(p?(v(this,T,"f")&&E(!0),o=!0,this.showHelp("log"),this.exit(0)):g&&(v(this,T,"f")&&E(!0),o=!0,v(this,pt,"f").showVersion("log"),this.exit(0))),!o&&v(this,et,"f").skipValidation.length>0&&(o=Object.keys(c).some((t=>v(this,et,"f").skipValidation.indexOf(t)>=0&&!0===c[t]))),!o){if(l.error)throw new e(l.error.message);if(!m){const t=this[Zt](u,{},l.error);i||(d=C(c,this,v(this,K,"f").getMiddleware(),!0)),d=this[zt](t,null!=d?d:c),f(d)&&!i&&(d=d.then((()=>C(c,this,v(this,K,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof e))throw t;v(this,pt,"f").fail(t.message,t)}return this[Bt](null!=d?d:c,a,!!i,!0)}[Zt](t,s,i,n){const r={...this.getDemandedOptions()};return o=>{if(i)throw new e(i.message);v(this,yt,"f").nonOptionCount(o),v(this,yt,"f").requiredArguments(o,r);let a=!1;v(this,dt,"f")&&(a=v(this,yt,"f").unknownCommands(o)),v(this,ft,"f")&&!a?v(this,yt,"f").unknownArguments(o,t,s,!!n):v(this,ut,"f")&&v(this,yt,"f").unknownArguments(o,t,{},!1,!1),v(this,yt,"f").limitedChoices(o),v(this,yt,"f").implications(o),v(this,yt,"f").conflicting(o)}}[Xt](){O(this,J,!0,"f")}[Qt](t){if("string"==typeof t)v(this,et,"f").key[t]=!0;else for(const e of t)v(this,et,"f").key[e]=!0}}var ee,se;const{readFileSync:ie}=require("fs"),{inspect:ne}=require("util"),{resolve:re}=require("path"),oe=require("y18n"),ae=require("yargs-parser");var he,le={assert:{notStrictEqual:t.notStrictEqual,strictEqual:t.strictEqual},cliui:require("cliui"),findUp:require("escalade/sync"),getEnv:t=>process.env[t],getCallerFile:require("get-caller-file"),getProcessArgvBin:y,inspect:ne,mainFilename:null!==(se=null===(ee=null===require||void 0===require?void 0:require.main)||void 0===ee?void 0:ee.filename)&&void 0!==se?se:process.cwd(),Parser:ae,path:require("path"),process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(t,e)=>process.emitWarning(t,e),execPath:()=>process.execPath,exit:t=>{process.exit(t)},nextTick:process.nextTick,stdColumns:void 0!==process.stdout.columns?process.stdout.columns:null},readFileSync:ie,require:require,requireDirectory:require("require-directory"),stringWidth:require("string-width"),y18n:oe({directory:re(__dirname,"../locales"),updateFiles:!1})};const ce=(null===(he=null===process||void 0===process?void 0:process.env)||void 0===he?void 0:he.YARGS_MIN_NODE_VERSION)?Number(process.env.YARGS_MIN_NODE_VERSION):12;if(process&&process.version){if(Number(process.version.match(/v([^.]+)/)[1])<ce)throw Error(`yargs supports a minimum Node.js version of ${ce}. Read our version support policy: https://github.com/yargs/yargs#supported-nodejs-versions`)}const fe=require("yargs-parser");var de,ue={applyExtends:n,cjsPlatformShim:le,Yargs:(de=le,(t=[],e=de.process.cwd(),s)=>{const i=new te(t,e,s,de);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}),argsert:h,isPromise:f,objFilter:g,parseCommand:o,Parser:fe,processArgv:b,YError:e};module.exports=ue;
|
package/helpers/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
applyExtends,
|
|
3
|
-
cjsPlatformShim,
|
|
4
|
-
Parser,
|
|
5
|
-
processArgv,
|
|
6
|
-
} = require('../build/index.cjs');
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
applyExtends: (config, cwd, mergeExtends) => {
|
|
10
|
-
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
|
|
11
|
-
},
|
|
12
|
-
hideBin: processArgv.hideBin,
|
|
13
|
-
Parser,
|
|
14
|
-
};
|
package/index.cjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// classic singleton yargs API, to use yargs
|
|
3
|
-
// without running as a singleton do:
|
|
4
|
-
// require('yargs/yargs')(process.argv.slice(2))
|
|
5
|
-
const {Yargs, processArgv} = require('./build/index.cjs');
|
|
6
|
-
|
|
7
|
-
Argv(processArgv.hideBin(process.argv));
|
|
8
|
-
|
|
9
|
-
module.exports = Argv;
|
|
10
|
-
|
|
11
|
-
function Argv(processArgs, cwd) {
|
|
12
|
-
const argv = Yargs(processArgs, cwd, require);
|
|
13
|
-
singletonify(argv);
|
|
14
|
-
// TODO(bcoe): warn if argv.parse() or argv.argv is used directly.
|
|
15
|
-
return argv;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function defineGetter(obj, key, getter) {
|
|
19
|
-
Object.defineProperty(obj, key, {
|
|
20
|
-
configurable: true,
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: getter,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function lookupGetter(obj, key) {
|
|
26
|
-
const desc = Object.getOwnPropertyDescriptor(obj, key);
|
|
27
|
-
if (typeof desc !== 'undefined') {
|
|
28
|
-
return desc.get;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/* Hack an instance of Argv with process.argv into Argv
|
|
33
|
-
so people can do
|
|
34
|
-
require('yargs')(['--beeble=1','-z','zizzle']).argv
|
|
35
|
-
to parse a list of args and
|
|
36
|
-
require('yargs').argv
|
|
37
|
-
to get a parsed version of process.argv.
|
|
38
|
-
*/
|
|
39
|
-
function singletonify(inst) {
|
|
40
|
-
[
|
|
41
|
-
...Object.keys(inst),
|
|
42
|
-
...Object.getOwnPropertyNames(inst.constructor.prototype),
|
|
43
|
-
].forEach(key => {
|
|
44
|
-
if (key === 'argv') {
|
|
45
|
-
defineGetter(Argv, key, lookupGetter(inst, key));
|
|
46
|
-
} else if (typeof inst[key] === 'function') {
|
|
47
|
-
Argv[key] = inst[key].bind(inst);
|
|
48
|
-
} else {
|
|
49
|
-
defineGetter(Argv, '$0', () => inst.$0);
|
|
50
|
-
defineGetter(Argv, 'parsed', () => inst.parsed);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
package/yargs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// TODO: consolidate on using a helpers file at some point in the future, which
|
|
2
|
-
// is the approach currently used to export Parser and applyExtends for ESM:
|
|
3
|
-
const {applyExtends, cjsPlatformShim, Parser, Yargs, processArgv} = require('./build/index.cjs')
|
|
4
|
-
Yargs.applyExtends = (config, cwd, mergeExtends) => {
|
|
5
|
-
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim)
|
|
6
|
-
}
|
|
7
|
-
Yargs.hideBin = processArgv.hideBin
|
|
8
|
-
Yargs.Parser = Parser
|
|
9
|
-
module.exports = Yargs
|
package/yargs.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// TODO: consolidate on using a helpers file at some point in the future, which
|
|
2
|
-
// is the approach currently used to export Parser and applyExtends for ESM:
|
|
3
|
-
import pkg from './build/index.cjs';
|
|
4
|
-
const {applyExtends, cjsPlatformShim, Parser, processArgv, Yargs} = pkg;
|
|
5
|
-
Yargs.applyExtends = (config, cwd, mergeExtends) => {
|
|
6
|
-
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
|
|
7
|
-
};
|
|
8
|
-
Yargs.hideBin = processArgv.hideBin;
|
|
9
|
-
Yargs.Parser = Parser;
|
|
10
|
-
export default Yargs;
|