@trenskow/arguments-parser 0.3.0 → 0.3.1
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/lib/index.js +17 -6
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -267,13 +267,15 @@ const argumentsParser = (
|
|
|
267
267
|
checkHelp();
|
|
268
268
|
|
|
269
269
|
let data = {};
|
|
270
|
+
let rest = [];
|
|
270
271
|
|
|
271
272
|
let idx;
|
|
272
273
|
|
|
273
274
|
for (idx = 0 ; idx < args.length ; idx++) {
|
|
274
275
|
|
|
275
276
|
if (args[idx].slice(0, 1) !== '-') {
|
|
276
|
-
|
|
277
|
+
rest.push(args[idx]);
|
|
278
|
+
continue;
|
|
277
279
|
}
|
|
278
280
|
|
|
279
281
|
shortOptions = Object.fromEntries(
|
|
@@ -319,11 +321,19 @@ const argumentsParser = (
|
|
|
319
321
|
|
|
320
322
|
}
|
|
321
323
|
|
|
322
|
-
if (
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
324
|
+
if (rest.length) {
|
|
325
|
+
switch (options.variadic || 'deny') {
|
|
326
|
+
case 'allow':
|
|
327
|
+
break;
|
|
328
|
+
case 'ignore':
|
|
329
|
+
rest = [];
|
|
330
|
+
break;
|
|
331
|
+
default:
|
|
332
|
+
printHelp(
|
|
333
|
+
new Error(
|
|
334
|
+
(strings?.empty?.help?.errors?.unexpected || 'Unexpected argument: <argument>.')
|
|
335
|
+
.replace('<argument>', args[0])));
|
|
336
|
+
}
|
|
327
337
|
}
|
|
328
338
|
|
|
329
339
|
try {
|
|
@@ -343,6 +353,7 @@ const argumentsParser = (
|
|
|
343
353
|
print.err(error.message);
|
|
344
354
|
process.exit(1);
|
|
345
355
|
},
|
|
356
|
+
rest,
|
|
346
357
|
nonOptions
|
|
347
358
|
});
|
|
348
359
|
|