@trenskow/arguments-parser 0.3.91 → 0.3.92

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.
Files changed (2) hide show
  1. package/lib/index.js +15 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -189,8 +189,16 @@ const argumentsParser = (
189
189
  print(strings?.commands?.help?.available || 'Available commands:');
190
190
  print();
191
191
 
192
- const tools = Object.keys(commands).map((key) => ({
193
- name: caseit(key, 'kebab'),
192
+ const tools = Object.entries(commands).map(([key, command]) => ({
193
+ name: `${
194
+ caseit(key, 'kebab')
195
+ }${
196
+ Array.isArray(command.parameters) ? ` ${
197
+ command.parameters
198
+ .map((parameter) => `${opening}${parameter}${closing}`)
199
+ .join(' ')
200
+ }` : ''
201
+ }`,
194
202
  description: commands[key].description
195
203
  }));
196
204
 
@@ -291,8 +299,6 @@ const argumentsParser = (
291
299
  then: (...resultArguments) => {
292
300
  return (async () => {
293
301
 
294
- checkHelp();
295
-
296
302
  let nonOptions;
297
303
  let nonOptionsIndex = args.indexOf('--');
298
304
 
@@ -402,10 +408,14 @@ const argumentsParser = (
402
408
  };
403
409
  }
404
410
 
411
+ checkHelp();
412
+
405
413
  let rest = [];
406
414
 
407
415
  let idx;
408
416
 
417
+ checkHelp();
418
+
409
419
  for (idx = 0 ; idx < args.length ; idx++) {
410
420
 
411
421
  if (args[idx].slice(0, 1) !== '-') {
@@ -467,7 +477,7 @@ const argumentsParser = (
467
477
  }
468
478
  }
469
479
 
470
- if (args.length > 0) {
480
+ if (args.length - idx > 0) {
471
481
  printHelp(
472
482
  new Error(
473
483
  (strings?.empty?.help?.errors?.unexpected || 'Unexpected argument: <argument>.')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trenskow/arguments-parser",
3
- "version": "0.3.91",
3
+ "version": "0.3.92",
4
4
  "description": "Yet another arguments parser.",
5
5
  "main": "index.js",
6
6
  "type": "module",