@optique/core 0.8.11 → 0.8.13
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 +19 -2
- package/dist/facade.js +19 -2
- package/dist/usage.cjs +4 -2
- package/dist/usage.js +4 -2
- package/package.json +1 -1
package/dist/facade.cjs
CHANGED
|
@@ -285,9 +285,26 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
|
|
|
285
285
|
completion: require_primitives.constant(false),
|
|
286
286
|
result: originalParser
|
|
287
287
|
}));
|
|
288
|
+
const mainParserIndex = parsers.length - 1;
|
|
289
|
+
let combined;
|
|
288
290
|
if (parsers.length === 1) return parsers[0];
|
|
289
|
-
else if (parsers.length === 2)
|
|
290
|
-
else
|
|
291
|
+
else if (parsers.length === 2) combined = require_constructs.longestMatch(parsers[0], parsers[1]);
|
|
292
|
+
else combined = require_constructs.longestMatch(...parsers);
|
|
293
|
+
const topUsage = combined.usage[0];
|
|
294
|
+
if (topUsage?.type === "exclusive" && mainParserIndex > 0) {
|
|
295
|
+
const terms = [...topUsage.terms];
|
|
296
|
+
const [mainTerm] = terms.splice(mainParserIndex, 1);
|
|
297
|
+
const lenientCount = (helpParsers.helpOption ? 1 : 0) + (versionParsers.versionOption ? 1 : 0);
|
|
298
|
+
terms.splice(lenientCount, 0, mainTerm);
|
|
299
|
+
combined = {
|
|
300
|
+
...combined,
|
|
301
|
+
usage: [{
|
|
302
|
+
...topUsage,
|
|
303
|
+
terms
|
|
304
|
+
}]
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return combined;
|
|
291
308
|
}
|
|
292
309
|
/**
|
|
293
310
|
* Classifies the parsing result into a discriminated union for cleaner handling.
|
package/dist/facade.js
CHANGED
|
@@ -285,9 +285,26 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
|
|
|
285
285
|
completion: constant(false),
|
|
286
286
|
result: originalParser
|
|
287
287
|
}));
|
|
288
|
+
const mainParserIndex = parsers.length - 1;
|
|
289
|
+
let combined;
|
|
288
290
|
if (parsers.length === 1) return parsers[0];
|
|
289
|
-
else if (parsers.length === 2)
|
|
290
|
-
else
|
|
291
|
+
else if (parsers.length === 2) combined = longestMatch(parsers[0], parsers[1]);
|
|
292
|
+
else combined = longestMatch(...parsers);
|
|
293
|
+
const topUsage = combined.usage[0];
|
|
294
|
+
if (topUsage?.type === "exclusive" && mainParserIndex > 0) {
|
|
295
|
+
const terms = [...topUsage.terms];
|
|
296
|
+
const [mainTerm] = terms.splice(mainParserIndex, 1);
|
|
297
|
+
const lenientCount = (helpParsers.helpOption ? 1 : 0) + (versionParsers.versionOption ? 1 : 0);
|
|
298
|
+
terms.splice(lenientCount, 0, mainTerm);
|
|
299
|
+
combined = {
|
|
300
|
+
...combined,
|
|
301
|
+
usage: [{
|
|
302
|
+
...topUsage,
|
|
303
|
+
terms
|
|
304
|
+
}]
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return combined;
|
|
291
308
|
}
|
|
292
309
|
/**
|
|
293
310
|
* Classifies the parsing result into a discriminated union for cleaner handling.
|
package/dist/usage.cjs
CHANGED
|
@@ -186,8 +186,10 @@ function normalizeUsageTerm(term) {
|
|
|
186
186
|
const terms = [];
|
|
187
187
|
for (const usage of term.terms) {
|
|
188
188
|
const normalized = normalizeUsage(usage);
|
|
189
|
-
if (normalized.length
|
|
190
|
-
|
|
189
|
+
if (normalized.length >= 1 && normalized[0].type === "exclusive") {
|
|
190
|
+
const rest = normalized.slice(1);
|
|
191
|
+
for (const subUsage of normalized[0].terms) terms.push([...subUsage, ...rest]);
|
|
192
|
+
} else terms.push(normalized);
|
|
191
193
|
}
|
|
192
194
|
return {
|
|
193
195
|
type: "exclusive",
|
package/dist/usage.js
CHANGED
|
@@ -185,8 +185,10 @@ function normalizeUsageTerm(term) {
|
|
|
185
185
|
const terms = [];
|
|
186
186
|
for (const usage of term.terms) {
|
|
187
187
|
const normalized = normalizeUsage(usage);
|
|
188
|
-
if (normalized.length
|
|
189
|
-
|
|
188
|
+
if (normalized.length >= 1 && normalized[0].type === "exclusive") {
|
|
189
|
+
const rest = normalized.slice(1);
|
|
190
|
+
for (const subUsage of normalized[0].terms) terms.push([...subUsage, ...rest]);
|
|
191
|
+
} else terms.push(normalized);
|
|
190
192
|
}
|
|
191
193
|
return {
|
|
192
194
|
type: "exclusive",
|