yargs 16.0.4-candidate.0 → 16.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/README.md +25 -6
- package/browser.mjs +4 -4
- package/build/index.cjs +348 -231
- package/build/lib/argsert.js +9 -5
- package/build/lib/command.js +44 -35
- package/build/lib/completion.js +27 -14
- package/build/lib/middleware.js +5 -3
- package/build/lib/parse-command.js +3 -3
- package/build/lib/usage.js +81 -47
- package/build/lib/utils/apply-extends.js +8 -7
- package/build/lib/utils/is-promise.js +2 -2
- package/build/lib/utils/obj-filter.js +1 -1
- package/build/lib/utils/set-blocking.js +4 -2
- package/build/lib/utils/which-module.js +1 -1
- package/build/lib/validation.js +37 -31
- package/build/lib/yargs-factory.js +126 -83
- package/helpers.mjs +7 -11
- package/index.cjs +17 -17
- package/index.mjs +5 -5
- package/lib/platform-shims/browser.mjs +38 -37
- package/package.json +31 -25
- package/yargs +2 -1
package/build/lib/argsert.js
CHANGED
|
@@ -5,15 +5,19 @@ export function argsert(arg1, arg2, arg3) {
|
|
|
5
5
|
function parseArgs() {
|
|
6
6
|
return typeof arg1 === 'object'
|
|
7
7
|
? [{ demanded: [], optional: [] }, arg1, arg2]
|
|
8
|
-
: [
|
|
8
|
+
: [
|
|
9
|
+
parseCommand(`cmd ${arg1}`),
|
|
10
|
+
arg2,
|
|
11
|
+
arg3,
|
|
12
|
+
];
|
|
9
13
|
}
|
|
10
14
|
try {
|
|
11
15
|
let position = 0;
|
|
12
|
-
|
|
16
|
+
const [parsed, callerArguments, _length] = parseArgs();
|
|
13
17
|
const args = [].slice.call(callerArguments);
|
|
14
18
|
while (args.length && args[args.length - 1] === undefined)
|
|
15
19
|
args.pop();
|
|
16
|
-
length =
|
|
20
|
+
const length = _length || args.length;
|
|
17
21
|
if (length < parsed.demanded.length) {
|
|
18
22
|
throw new YError(`Not enough arguments provided. Expected ${parsed.demanded.length} but received ${args.length}.`);
|
|
19
23
|
}
|
|
@@ -21,7 +25,7 @@ export function argsert(arg1, arg2, arg3) {
|
|
|
21
25
|
if (length > totalCommands) {
|
|
22
26
|
throw new YError(`Too many arguments provided. Expected max ${totalCommands} but received ${length}.`);
|
|
23
27
|
}
|
|
24
|
-
parsed.demanded.forEach(
|
|
28
|
+
parsed.demanded.forEach(demanded => {
|
|
25
29
|
const arg = args.shift();
|
|
26
30
|
const observedType = guessType(arg);
|
|
27
31
|
const matchingTypes = demanded.cmd.filter(type => type === observedType || type === '*');
|
|
@@ -29,7 +33,7 @@ export function argsert(arg1, arg2, arg3) {
|
|
|
29
33
|
argumentTypeError(observedType, demanded.cmd, position);
|
|
30
34
|
position += 1;
|
|
31
35
|
});
|
|
32
|
-
parsed.optional.forEach(
|
|
36
|
+
parsed.optional.forEach(optional => {
|
|
33
37
|
if (args.length === 0)
|
|
34
38
|
return;
|
|
35
39
|
const arg = args.shift();
|
package/build/lib/command.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { assertNotStrictEqual } from './typings/common-types.js';
|
|
1
|
+
import { assertNotStrictEqual, } from './typings/common-types.js';
|
|
2
2
|
import { isPromise } from './utils/is-promise.js';
|
|
3
|
-
import { applyMiddleware, commandMiddlewareFactory } from './middleware.js';
|
|
3
|
+
import { applyMiddleware, commandMiddlewareFactory, } from './middleware.js';
|
|
4
4
|
import { parseCommand } from './parse-command.js';
|
|
5
|
-
import { isYargsInstance } from './yargs-factory.js';
|
|
5
|
+
import { isYargsInstance, } from './yargs-factory.js';
|
|
6
6
|
import whichModule from './utils/which-module.js';
|
|
7
7
|
const DEFAULT_MARKER = /(^\*)|(^\$0)/;
|
|
8
8
|
export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
@@ -19,7 +19,9 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
19
19
|
cmd = cmd[0];
|
|
20
20
|
}
|
|
21
21
|
else if (isCommandHandlerDefinition(cmd)) {
|
|
22
|
-
let command =
|
|
22
|
+
let command = Array.isArray(cmd.command) || typeof cmd.command === 'string'
|
|
23
|
+
? cmd.command
|
|
24
|
+
: moduleName(cmd);
|
|
23
25
|
if (cmd.aliases)
|
|
24
26
|
command = [].concat(command).concat(cmd.aliases);
|
|
25
27
|
self.addHandler(command, extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
|
|
@@ -32,7 +34,7 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
32
34
|
const parsedCommand = parseCommand(cmd);
|
|
33
35
|
aliases = aliases.map(alias => parseCommand(alias).cmd);
|
|
34
36
|
let isDefault = false;
|
|
35
|
-
const parsedAliases = [parsedCommand.cmd].concat(aliases).filter(
|
|
37
|
+
const parsedAliases = [parsedCommand.cmd].concat(aliases).filter(c => {
|
|
36
38
|
if (DEFAULT_MARKER.test(c)) {
|
|
37
39
|
isDefault = true;
|
|
38
40
|
return false;
|
|
@@ -46,7 +48,7 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
46
48
|
aliases = parsedAliases.slice(1);
|
|
47
49
|
cmd = cmd.replace(DEFAULT_MARKER, parsedCommand.cmd);
|
|
48
50
|
}
|
|
49
|
-
aliases.forEach(
|
|
51
|
+
aliases.forEach(alias => {
|
|
50
52
|
aliasMap[alias] = parsedCommand.cmd;
|
|
51
53
|
});
|
|
52
54
|
if (description !== false) {
|
|
@@ -60,7 +62,7 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
60
62
|
middlewares,
|
|
61
63
|
deprecated,
|
|
62
64
|
demanded: parsedCommand.demanded,
|
|
63
|
-
optional: parsedCommand.optional
|
|
65
|
+
optional: parsedCommand.optional,
|
|
64
66
|
};
|
|
65
67
|
if (isDefault)
|
|
66
68
|
defaultCommand = handlers[parsedCommand.cmd];
|
|
@@ -93,7 +95,7 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
93
95
|
function commandFromFilename(filename) {
|
|
94
96
|
return shim.path.basename(filename, shim.path.extname(filename));
|
|
95
97
|
}
|
|
96
|
-
function extractDesc({ describe, description, desc }) {
|
|
98
|
+
function extractDesc({ describe, description, desc, }) {
|
|
97
99
|
for (const test of [describe, description, desc]) {
|
|
98
100
|
if (typeof test === 'string' || test === false)
|
|
99
101
|
return test;
|
|
@@ -121,7 +123,9 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
121
123
|
const builderOutput = builder(yargs.reset(parsed.aliases));
|
|
122
124
|
const innerYargs = isYargsInstance(builderOutput) ? builderOutput : yargs;
|
|
123
125
|
if (shouldUpdateUsage(innerYargs)) {
|
|
124
|
-
innerYargs
|
|
126
|
+
innerYargs
|
|
127
|
+
.getUsageInstance()
|
|
128
|
+
.usage(usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
|
|
125
129
|
}
|
|
126
130
|
innerArgv = innerYargs._parseArgs(null, null, true, commandIndex);
|
|
127
131
|
aliases = innerYargs.parsed.aliases;
|
|
@@ -129,9 +133,11 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
129
133
|
else if (isCommandBuilderOptionDefinitions(builder)) {
|
|
130
134
|
const innerYargs = yargs.reset(parsed.aliases);
|
|
131
135
|
if (shouldUpdateUsage(innerYargs)) {
|
|
132
|
-
innerYargs
|
|
136
|
+
innerYargs
|
|
137
|
+
.getUsageInstance()
|
|
138
|
+
.usage(usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
|
|
133
139
|
}
|
|
134
|
-
Object.keys(commandHandler.builder).forEach(
|
|
140
|
+
Object.keys(commandHandler.builder).forEach(key => {
|
|
135
141
|
innerYargs.option(key, builder[key]);
|
|
136
142
|
});
|
|
137
143
|
innerArgv = innerYargs._parseArgs(null, null, true, commandIndex);
|
|
@@ -140,7 +146,9 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
140
146
|
if (!yargs._hasOutput()) {
|
|
141
147
|
positionalMap = populatePositionals(commandHandler, innerArgv, currentContext);
|
|
142
148
|
}
|
|
143
|
-
const middlewares = globalMiddleware
|
|
149
|
+
const middlewares = globalMiddleware
|
|
150
|
+
.slice(0)
|
|
151
|
+
.concat(commandHandler.middlewares);
|
|
144
152
|
applyMiddleware(innerArgv, yargs, middlewares, true);
|
|
145
153
|
if (!yargs._hasOutput()) {
|
|
146
154
|
yargs._runValidation(innerArgv, aliases, positionalMap, yargs.parsed.error, !command);
|
|
@@ -193,12 +201,16 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
193
201
|
return innerArgv;
|
|
194
202
|
};
|
|
195
203
|
function shouldUpdateUsage(yargs) {
|
|
196
|
-
return !yargs.getUsageInstance().getUsageDisabled() &&
|
|
197
|
-
yargs.getUsageInstance().getUsage().length === 0;
|
|
204
|
+
return (!yargs.getUsageInstance().getUsageDisabled() &&
|
|
205
|
+
yargs.getUsageInstance().getUsage().length === 0);
|
|
198
206
|
}
|
|
199
207
|
function usageFromParentCommandsCommandHandler(parentCommands, commandHandler) {
|
|
200
|
-
const c = DEFAULT_MARKER.test(commandHandler.original)
|
|
201
|
-
|
|
208
|
+
const c = DEFAULT_MARKER.test(commandHandler.original)
|
|
209
|
+
? commandHandler.original.replace(DEFAULT_MARKER, '').trim()
|
|
210
|
+
: commandHandler.original;
|
|
211
|
+
const pc = parentCommands.filter(c => {
|
|
212
|
+
return !DEFAULT_MARKER.test(c);
|
|
213
|
+
});
|
|
202
214
|
pc.push(c);
|
|
203
215
|
return `$0 ${pc.join(' ')}`;
|
|
204
216
|
}
|
|
@@ -206,7 +218,8 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
206
218
|
assertNotStrictEqual(defaultCommand, undefined, shim);
|
|
207
219
|
if (shouldUpdateUsage(yargs)) {
|
|
208
220
|
const commandString = DEFAULT_MARKER.test(defaultCommand.original)
|
|
209
|
-
? defaultCommand.original
|
|
221
|
+
? defaultCommand.original
|
|
222
|
+
: defaultCommand.original.replace(/^[^[\]<>]*/, '$0 ');
|
|
210
223
|
yargs.getUsageInstance().usage(commandString, defaultCommand.description);
|
|
211
224
|
}
|
|
212
225
|
const builder = defaultCommand.builder;
|
|
@@ -214,7 +227,7 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
214
227
|
builder(yargs);
|
|
215
228
|
}
|
|
216
229
|
else {
|
|
217
|
-
Object.keys(builder).forEach(
|
|
230
|
+
Object.keys(builder).forEach(key => {
|
|
218
231
|
yargs.option(key, builder[key]);
|
|
219
232
|
});
|
|
220
233
|
}
|
|
@@ -256,8 +269,8 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
256
269
|
options.array = options.array.concat(parseOptions.array);
|
|
257
270
|
options.config = {};
|
|
258
271
|
const unparsed = [];
|
|
259
|
-
Object.keys(positionalMap).forEach(
|
|
260
|
-
positionalMap[key].map(
|
|
272
|
+
Object.keys(positionalMap).forEach(key => {
|
|
273
|
+
positionalMap[key].map(value => {
|
|
261
274
|
if (options.configuration['unknown-options-as-args'])
|
|
262
275
|
options.key[key] = true;
|
|
263
276
|
unparsed.push(`--${key}`);
|
|
@@ -267,20 +280,20 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
267
280
|
if (!unparsed.length)
|
|
268
281
|
return;
|
|
269
282
|
const config = Object.assign({}, options.configuration, {
|
|
270
|
-
'populate--': true
|
|
283
|
+
'populate--': true,
|
|
271
284
|
});
|
|
272
285
|
const parsed = shim.Parser.detailed(unparsed, Object.assign({}, options, {
|
|
273
|
-
configuration: config
|
|
286
|
+
configuration: config,
|
|
274
287
|
}));
|
|
275
288
|
if (parsed.error) {
|
|
276
289
|
yargs.getUsageInstance().fail(parsed.error.message, parsed.error);
|
|
277
290
|
}
|
|
278
291
|
else {
|
|
279
292
|
const positionalKeys = Object.keys(positionalMap);
|
|
280
|
-
Object.keys(positionalMap).forEach(
|
|
293
|
+
Object.keys(positionalMap).forEach(key => {
|
|
281
294
|
positionalKeys.push(...parsed.aliases[key]);
|
|
282
295
|
});
|
|
283
|
-
Object.keys(parsed.argv).forEach(
|
|
296
|
+
Object.keys(parsed.argv).forEach(key => {
|
|
284
297
|
if (positionalKeys.indexOf(key) !== -1) {
|
|
285
298
|
if (!positionalMap[key])
|
|
286
299
|
positionalMap[key] = parsed.argv[key];
|
|
@@ -294,10 +307,10 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
294
307
|
array: [],
|
|
295
308
|
default: {},
|
|
296
309
|
alias: {},
|
|
297
|
-
demand: {}
|
|
310
|
+
demand: {},
|
|
298
311
|
};
|
|
299
312
|
const parsed = parseCommand(cmdString);
|
|
300
|
-
parsed.demanded.forEach(
|
|
313
|
+
parsed.demanded.forEach(d => {
|
|
301
314
|
const [cmd, ...aliases] = d.cmd;
|
|
302
315
|
if (d.variadic) {
|
|
303
316
|
parseOptions.array.push(cmd);
|
|
@@ -306,7 +319,7 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
306
319
|
parseOptions.alias[cmd] = aliases;
|
|
307
320
|
parseOptions.demand[cmd] = true;
|
|
308
321
|
});
|
|
309
|
-
parsed.optional.forEach(
|
|
322
|
+
parsed.optional.forEach(o => {
|
|
310
323
|
const [cmd, ...aliases] = o.cmd;
|
|
311
324
|
if (o.variadic) {
|
|
312
325
|
parseOptions.array.push(cmd);
|
|
@@ -327,17 +340,13 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|
|
327
340
|
frozens.push({
|
|
328
341
|
handlers,
|
|
329
342
|
aliasMap,
|
|
330
|
-
defaultCommand
|
|
343
|
+
defaultCommand,
|
|
331
344
|
});
|
|
332
345
|
};
|
|
333
346
|
self.unfreeze = () => {
|
|
334
347
|
const frozen = frozens.pop();
|
|
335
348
|
assertNotStrictEqual(frozen, undefined, shim);
|
|
336
|
-
({
|
|
337
|
-
handlers,
|
|
338
|
-
aliasMap,
|
|
339
|
-
defaultCommand
|
|
340
|
-
} = frozen);
|
|
349
|
+
({ handlers, aliasMap, defaultCommand } = frozen);
|
|
341
350
|
};
|
|
342
351
|
return self;
|
|
343
352
|
}
|
|
@@ -345,9 +354,9 @@ export function isCommandHandlerDefinition(cmd) {
|
|
|
345
354
|
return typeof cmd === 'object';
|
|
346
355
|
}
|
|
347
356
|
export function isCommandBuilderDefinition(builder) {
|
|
348
|
-
return typeof builder === 'object' &&
|
|
357
|
+
return (typeof builder === 'object' &&
|
|
349
358
|
!!builder.builder &&
|
|
350
|
-
typeof builder.handler === 'function';
|
|
359
|
+
typeof builder.handler === 'function');
|
|
351
360
|
}
|
|
352
361
|
export function isCommandBuilderCallback(builder) {
|
|
353
362
|
return typeof builder === 'function';
|
package/build/lib/completion.js
CHANGED
|
@@ -5,7 +5,7 @@ import { isPromise } from './utils/is-promise.js';
|
|
|
5
5
|
import { parseCommand } from './parse-command.js';
|
|
6
6
|
export function completion(yargs, usage, command, shim) {
|
|
7
7
|
const self = {
|
|
8
|
-
completionKey: 'get-yargs-completions'
|
|
8
|
+
completionKey: 'get-yargs-completions',
|
|
9
9
|
};
|
|
10
10
|
let aliases;
|
|
11
11
|
self.setParsed = function setParsed(parsed) {
|
|
@@ -23,22 +23,30 @@ export function completion(yargs, usage, command, shim) {
|
|
|
23
23
|
if (isSyncCompletionFunction(completionFunction)) {
|
|
24
24
|
const result = completionFunction(current, argv);
|
|
25
25
|
if (isPromise(result)) {
|
|
26
|
-
return result
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
return result
|
|
27
|
+
.then(list => {
|
|
28
|
+
shim.process.nextTick(() => {
|
|
29
|
+
done(list);
|
|
30
|
+
});
|
|
31
|
+
})
|
|
32
|
+
.catch(err => {
|
|
33
|
+
shim.process.nextTick(() => {
|
|
34
|
+
throw err;
|
|
35
|
+
});
|
|
30
36
|
});
|
|
31
37
|
}
|
|
32
38
|
return done(result);
|
|
33
39
|
}
|
|
34
40
|
else {
|
|
35
|
-
return completionFunction(current, argv,
|
|
41
|
+
return completionFunction(current, argv, completions => {
|
|
36
42
|
done(completions);
|
|
37
43
|
});
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
if (completionFunction) {
|
|
41
|
-
return isPromise(argv)
|
|
47
|
+
return isPromise(argv)
|
|
48
|
+
? argv.then(runCompletionFunction)
|
|
49
|
+
: runCompletionFunction(argv);
|
|
42
50
|
}
|
|
43
51
|
const handlers = command.getCommandHandlers();
|
|
44
52
|
for (let i = 0, ii = args.length; i < ii; ++i) {
|
|
@@ -51,8 +59,9 @@ export function completion(yargs, usage, command, shim) {
|
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
|
-
if (!current.match(/^-/) &&
|
|
55
|
-
|
|
62
|
+
if (!current.match(/^-/) &&
|
|
63
|
+
parentCommands[parentCommands.length - 1] !== current) {
|
|
64
|
+
usage.getCommands().forEach(usageCommand => {
|
|
56
65
|
const commandName = parseCommand(usageCommand[0]).cmd;
|
|
57
66
|
if (args.indexOf(commandName) === -1) {
|
|
58
67
|
if (!zshShell) {
|
|
@@ -68,8 +77,9 @@ export function completion(yargs, usage, command, shim) {
|
|
|
68
77
|
if (current.match(/^-/) || (current === '' && completions.length === 0)) {
|
|
69
78
|
const descs = usage.getDescriptions();
|
|
70
79
|
const options = yargs.getOptions();
|
|
71
|
-
Object.keys(options.key).forEach(
|
|
72
|
-
const negable = !!options.configuration['boolean-negation'] &&
|
|
80
|
+
Object.keys(options.key).forEach(key => {
|
|
81
|
+
const negable = !!options.configuration['boolean-negation'] &&
|
|
82
|
+
options.boolean.includes(key);
|
|
73
83
|
let keyAndAliases = [key].concat(aliases[key] || []);
|
|
74
84
|
if (negable)
|
|
75
85
|
keyAndAliases = keyAndAliases.concat(keyAndAliases.map(key => `no-${key}`));
|
|
@@ -84,7 +94,8 @@ export function completion(yargs, usage, command, shim) {
|
|
|
84
94
|
}
|
|
85
95
|
else {
|
|
86
96
|
const desc = descs[key] || '';
|
|
87
|
-
completions.push(dashes +
|
|
97
|
+
completions.push(dashes +
|
|
98
|
+
`${key.replace(/:/g, '\\:')}:${desc.replace('__yargsString__:', '')}`);
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
}
|
|
@@ -96,7 +107,9 @@ export function completion(yargs, usage, command, shim) {
|
|
|
96
107
|
done(completions);
|
|
97
108
|
};
|
|
98
109
|
self.generateCompletionScript = function generateCompletionScript($0, cmd) {
|
|
99
|
-
let script = zshShell
|
|
110
|
+
let script = zshShell
|
|
111
|
+
? templates.completionZshTemplate
|
|
112
|
+
: templates.completionShTemplate;
|
|
100
113
|
const name = shim.path.basename($0);
|
|
101
114
|
if ($0.match(/\.js$/))
|
|
102
115
|
$0 = `./${$0}`;
|
|
@@ -105,7 +118,7 @@ export function completion(yargs, usage, command, shim) {
|
|
|
105
118
|
return script.replace(/{{app_path}}/g, $0);
|
|
106
119
|
};
|
|
107
120
|
let completionFunction = null;
|
|
108
|
-
self.registerFunction =
|
|
121
|
+
self.registerFunction = fn => {
|
|
109
122
|
completionFunction = fn;
|
|
110
123
|
};
|
|
111
124
|
return self;
|
package/build/lib/middleware.js
CHANGED
|
@@ -29,14 +29,16 @@ export function commandMiddlewareFactory(commandMiddleware) {
|
|
|
29
29
|
}
|
|
30
30
|
export function applyMiddleware(argv, yargs, middlewares, beforeValidation) {
|
|
31
31
|
const beforeValidationError = new Error('middleware cannot return a promise when applyBeforeValidation is true');
|
|
32
|
-
return middlewares
|
|
33
|
-
.reduce((acc, middleware) => {
|
|
32
|
+
return middlewares.reduce((acc, middleware) => {
|
|
34
33
|
if (middleware.applyBeforeValidation !== beforeValidation) {
|
|
35
34
|
return acc;
|
|
36
35
|
}
|
|
37
36
|
if (isPromise(acc)) {
|
|
38
37
|
return acc
|
|
39
|
-
.then(initialObj => Promise.all([
|
|
38
|
+
.then(initialObj => Promise.all([
|
|
39
|
+
initialObj,
|
|
40
|
+
middleware(initialObj, yargs),
|
|
41
|
+
]))
|
|
40
42
|
.then(([initialObj, middlewareObj]) => Object.assign(initialObj, middlewareObj));
|
|
41
43
|
}
|
|
42
44
|
else {
|
|
@@ -8,7 +8,7 @@ export function parseCommand(cmd) {
|
|
|
8
8
|
const parsedCommand = {
|
|
9
9
|
cmd: firstCommand.replace(bregex, ''),
|
|
10
10
|
demanded: [],
|
|
11
|
-
optional: []
|
|
11
|
+
optional: [],
|
|
12
12
|
};
|
|
13
13
|
splitCommand.forEach((cmd, i) => {
|
|
14
14
|
let variadic = false;
|
|
@@ -18,13 +18,13 @@ export function parseCommand(cmd) {
|
|
|
18
18
|
if (/^\[/.test(cmd)) {
|
|
19
19
|
parsedCommand.optional.push({
|
|
20
20
|
cmd: cmd.replace(bregex, '').split('|'),
|
|
21
|
-
variadic
|
|
21
|
+
variadic,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
parsedCommand.demanded.push({
|
|
26
26
|
cmd: cmd.replace(bregex, '').split('|'),
|
|
27
|
-
variadic
|
|
27
|
+
variadic,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
});
|