@optique/core 0.10.0-dev.370 → 0.10.0-dev.374

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/dist/facade.cjs CHANGED
@@ -288,9 +288,26 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
288
288
  completion: require_primitives.constant(false),
289
289
  result: originalParser
290
290
  }));
291
+ const mainParserIndex = parsers.length - 1;
291
292
  if (parsers.length === 1) return parsers[0];
292
- else if (parsers.length === 2) return require_constructs.longestMatch(parsers[0], parsers[1]);
293
- else return require_constructs.longestMatch(...parsers);
293
+ let combined;
294
+ if (parsers.length === 2) combined = require_constructs.longestMatch(parsers[0], parsers[1]);
295
+ else combined = require_constructs.longestMatch(...parsers);
296
+ const topUsage = combined.usage[0];
297
+ if (topUsage?.type === "exclusive" && mainParserIndex > 0) {
298
+ const terms = [...topUsage.terms];
299
+ const [mainTerm] = terms.splice(mainParserIndex, 1);
300
+ const lenientCount = (helpParsers.helpOption ? 1 : 0) + (versionParsers.versionOption ? 1 : 0);
301
+ terms.splice(lenientCount, 0, mainTerm);
302
+ combined = {
303
+ ...combined,
304
+ usage: [{
305
+ ...topUsage,
306
+ terms
307
+ }]
308
+ };
309
+ }
310
+ return combined;
294
311
  }
295
312
  /**
296
313
  * Classifies the parsing result into a discriminated union for cleaner handling.
package/dist/facade.js CHANGED
@@ -288,9 +288,26 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
288
288
  completion: constant(false),
289
289
  result: originalParser
290
290
  }));
291
+ const mainParserIndex = parsers.length - 1;
291
292
  if (parsers.length === 1) return parsers[0];
292
- else if (parsers.length === 2) return longestMatch(parsers[0], parsers[1]);
293
- else return longestMatch(...parsers);
293
+ let combined;
294
+ if (parsers.length === 2) combined = longestMatch(parsers[0], parsers[1]);
295
+ else combined = longestMatch(...parsers);
296
+ const topUsage = combined.usage[0];
297
+ if (topUsage?.type === "exclusive" && mainParserIndex > 0) {
298
+ const terms = [...topUsage.terms];
299
+ const [mainTerm] = terms.splice(mainParserIndex, 1);
300
+ const lenientCount = (helpParsers.helpOption ? 1 : 0) + (versionParsers.versionOption ? 1 : 0);
301
+ terms.splice(lenientCount, 0, mainTerm);
302
+ combined = {
303
+ ...combined,
304
+ usage: [{
305
+ ...topUsage,
306
+ terms
307
+ }]
308
+ };
309
+ }
310
+ return combined;
294
311
  }
295
312
  /**
296
313
  * Classifies the parsing result into a discriminated union for cleaner handling.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "0.10.0-dev.370+bae705cb",
3
+ "version": "0.10.0-dev.374+981b7fab",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",