@trenskow/arguments-parser 0.3.77 → 0.3.79
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 +8 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -31,6 +31,7 @@ const argumentsParser = (
|
|
|
31
31
|
argvLevel = 0,
|
|
32
32
|
placeholder = '<>',
|
|
33
33
|
command,
|
|
34
|
+
onCommand,
|
|
34
35
|
strings = {},
|
|
35
36
|
help: {
|
|
36
37
|
usage: helpUsage,
|
|
@@ -151,11 +152,14 @@ const argumentsParser = (
|
|
|
151
152
|
|
|
152
153
|
try {
|
|
153
154
|
|
|
155
|
+
onCommand?.(tool, args.slice(1));
|
|
156
|
+
|
|
154
157
|
return await commands[tool]({
|
|
155
158
|
args: args.slice(1),
|
|
156
159
|
argumentsParser: argumentsParser({
|
|
157
160
|
args: args.slice(1),
|
|
158
161
|
argvLevel: argvLevel + 1,
|
|
162
|
+
onCommand,
|
|
159
163
|
placeholder,
|
|
160
164
|
command: commands[tool],
|
|
161
165
|
strings
|
|
@@ -213,6 +217,10 @@ const argumentsParser = (
|
|
|
213
217
|
|
|
214
218
|
});
|
|
215
219
|
|
|
220
|
+
shortOptions = Object.fromEntries(
|
|
221
|
+
Object.entries(shortOptions)
|
|
222
|
+
.map(([key, value]) => [value, key]));
|
|
223
|
+
|
|
216
224
|
if (allKeyPaths.length) {
|
|
217
225
|
|
|
218
226
|
helpOptions = () => {
|
|
@@ -289,10 +297,6 @@ const argumentsParser = (
|
|
|
289
297
|
continue;
|
|
290
298
|
}
|
|
291
299
|
|
|
292
|
-
shortOptions = Object.fromEntries(
|
|
293
|
-
Object.entries(shortOptions)
|
|
294
|
-
.map(([key, value]) => [value, key]));
|
|
295
|
-
|
|
296
300
|
let key = args[idx].slice(1);
|
|
297
301
|
|
|
298
302
|
if (args[idx].slice(1, 2) === '-') {
|