@optique/core 1.4.0-dev.2709 → 1.4.0-dev.2711
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/internal/usage.cjs +16 -3
- package/dist/internal/usage.js +16 -3
- package/dist/modifiers.cjs +7 -1
- package/dist/modifiers.js +7 -1
- package/dist/usage.cjs +7 -1
- package/dist/usage.js +7 -1
- package/package.json +2 -2
package/dist/internal/usage.cjs
CHANGED
|
@@ -28,6 +28,19 @@ function projectTerms(terms, isHidden) {
|
|
|
28
28
|
hidesRequired
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Projects an alternative of an exclusive term. Display filtering drops an
|
|
33
|
+
* alternative whose leading command is hidden as a whole, trailing terms
|
|
34
|
+
* included.
|
|
35
|
+
*/
|
|
36
|
+
function projectBranch(branch, isHidden) {
|
|
37
|
+
const first = branch[0];
|
|
38
|
+
if (first?.type === "command" && isHidden(first.hidden)) return {
|
|
39
|
+
...EMPTY,
|
|
40
|
+
hidesRequired: true
|
|
41
|
+
};
|
|
42
|
+
return projectTerms(branch, isHidden);
|
|
43
|
+
}
|
|
31
44
|
function projectTerm(term, isHidden) {
|
|
32
45
|
if (isHiddenLeaf(term, isHidden)) return {
|
|
33
46
|
...EMPTY,
|
|
@@ -71,7 +84,7 @@ function projectTerm(term, isHidden) {
|
|
|
71
84
|
let omissible = false;
|
|
72
85
|
let hidesRequired = false;
|
|
73
86
|
for (const branch of term.terms) {
|
|
74
|
-
const projection =
|
|
87
|
+
const projection = projectBranch(branch, isHidden);
|
|
75
88
|
hidesRequired ||= projection.hidesRequired;
|
|
76
89
|
if (!projection.visible) continue;
|
|
77
90
|
visible = true;
|
|
@@ -145,7 +158,7 @@ function resolveTerm(term, isHidden) {
|
|
|
145
158
|
const projection = projectTerm(resolved, isHidden);
|
|
146
159
|
if (!projection.visible || projection.omissible === term.acceptsEmpty) return resolved;
|
|
147
160
|
if (term.acceptsEmpty) {
|
|
148
|
-
const visible = branches.filter((branch) =>
|
|
161
|
+
const visible = branches.filter((branch) => projectBranch(branch, isHidden).visible);
|
|
149
162
|
return {
|
|
150
163
|
type: "optional",
|
|
151
164
|
terms: visible.length === 1 ? visible[0] : [{
|
|
@@ -156,7 +169,7 @@ function resolveTerm(term, isHidden) {
|
|
|
156
169
|
}
|
|
157
170
|
const required = [];
|
|
158
171
|
for (const branch of branches) {
|
|
159
|
-
const branchProjection =
|
|
172
|
+
const branchProjection = projectBranch(branch, isHidden);
|
|
160
173
|
if (!branchProjection.visible || !branchProjection.omissible) {
|
|
161
174
|
required.push(branch);
|
|
162
175
|
continue;
|
package/dist/internal/usage.js
CHANGED
|
@@ -27,6 +27,19 @@ function projectTerms(terms, isHidden) {
|
|
|
27
27
|
hidesRequired
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Projects an alternative of an exclusive term. Display filtering drops an
|
|
32
|
+
* alternative whose leading command is hidden as a whole, trailing terms
|
|
33
|
+
* included.
|
|
34
|
+
*/
|
|
35
|
+
function projectBranch(branch, isHidden) {
|
|
36
|
+
const first = branch[0];
|
|
37
|
+
if (first?.type === "command" && isHidden(first.hidden)) return {
|
|
38
|
+
...EMPTY,
|
|
39
|
+
hidesRequired: true
|
|
40
|
+
};
|
|
41
|
+
return projectTerms(branch, isHidden);
|
|
42
|
+
}
|
|
30
43
|
function projectTerm(term, isHidden) {
|
|
31
44
|
if (isHiddenLeaf(term, isHidden)) return {
|
|
32
45
|
...EMPTY,
|
|
@@ -70,7 +83,7 @@ function projectTerm(term, isHidden) {
|
|
|
70
83
|
let omissible = false;
|
|
71
84
|
let hidesRequired = false;
|
|
72
85
|
for (const branch of term.terms) {
|
|
73
|
-
const projection =
|
|
86
|
+
const projection = projectBranch(branch, isHidden);
|
|
74
87
|
hidesRequired ||= projection.hidesRequired;
|
|
75
88
|
if (!projection.visible) continue;
|
|
76
89
|
visible = true;
|
|
@@ -144,7 +157,7 @@ function resolveTerm(term, isHidden) {
|
|
|
144
157
|
const projection = projectTerm(resolved, isHidden);
|
|
145
158
|
if (!projection.visible || projection.omissible === term.acceptsEmpty) return resolved;
|
|
146
159
|
if (term.acceptsEmpty) {
|
|
147
|
-
const visible = branches.filter((branch) =>
|
|
160
|
+
const visible = branches.filter((branch) => projectBranch(branch, isHidden).visible);
|
|
148
161
|
return {
|
|
149
162
|
type: "optional",
|
|
150
163
|
terms: visible.length === 1 ? visible[0] : [{
|
|
@@ -155,7 +168,7 @@ function resolveTerm(term, isHidden) {
|
|
|
155
168
|
}
|
|
156
169
|
const required = [];
|
|
157
170
|
for (const branch of branches) {
|
|
158
|
-
const branchProjection =
|
|
171
|
+
const branchProjection = projectBranch(branch, isHidden);
|
|
159
172
|
if (!branchProjection.visible || !branchProjection.omissible) {
|
|
160
173
|
required.push(branch);
|
|
161
174
|
continue;
|
package/dist/modifiers.cjs
CHANGED
|
@@ -943,7 +943,13 @@ function map(parser, transform) {
|
|
|
943
943
|
if (composed != null) mappedParser.dependencyMetadata = composed;
|
|
944
944
|
}
|
|
945
945
|
require_dependency_runtime.defineForwardedEffectfulSchedulingNodes(mappedParser, parser);
|
|
946
|
-
|
|
946
|
+
const innerFacts = require_empty_input.getEmptyInputFacts(parser);
|
|
947
|
+
require_empty_input.defineEmptyInputFacts(mappedParser, {
|
|
948
|
+
...innerFacts.step == null ? {} : { step: innerFacts.step },
|
|
949
|
+
...innerFacts.next == null ? {} : { next: innerFacts.next },
|
|
950
|
+
...innerFacts.afterStep === false ? { afterStep: false } : {},
|
|
951
|
+
...innerFacts.fromInitial === false ? { fromInitial: false } : {}
|
|
952
|
+
});
|
|
947
953
|
return fluent(mappedParser);
|
|
948
954
|
}
|
|
949
955
|
const deferredValueBrand = Symbol.for("@optique/core/deferredValue");
|
package/dist/modifiers.js
CHANGED
|
@@ -943,7 +943,13 @@ function map(parser, transform) {
|
|
|
943
943
|
if (composed != null) mappedParser.dependencyMetadata = composed;
|
|
944
944
|
}
|
|
945
945
|
defineForwardedEffectfulSchedulingNodes(mappedParser, parser);
|
|
946
|
-
|
|
946
|
+
const innerFacts = getEmptyInputFacts(parser);
|
|
947
|
+
defineEmptyInputFacts(mappedParser, {
|
|
948
|
+
...innerFacts.step == null ? {} : { step: innerFacts.step },
|
|
949
|
+
...innerFacts.next == null ? {} : { next: innerFacts.next },
|
|
950
|
+
...innerFacts.afterStep === false ? { afterStep: false } : {},
|
|
951
|
+
...innerFacts.fromInitial === false ? { fromInitial: false } : {}
|
|
952
|
+
});
|
|
947
953
|
return fluent(mappedParser);
|
|
948
954
|
}
|
|
949
955
|
const deferredValueBrand = Symbol.for("@optique/core/deferredValue");
|
package/dist/usage.cjs
CHANGED
|
@@ -209,7 +209,13 @@ function formatUsageLines(programName, usage, declared, options) {
|
|
|
209
209
|
if (options.expandCommands) {
|
|
210
210
|
let lastTerm = usage.at(-1);
|
|
211
211
|
const declaredLast = declared.at(-1);
|
|
212
|
-
if (lastTerm?.type === "optional" &&
|
|
212
|
+
if (lastTerm?.type === "optional" && declaredLast?.type === "exclusive") {
|
|
213
|
+
if (lastTerm.terms.length === 1 && lastTerm.terms[0].type === "exclusive") lastTerm = lastTerm.terms[0];
|
|
214
|
+
else if (lastTerm.terms[0]?.type === "command") lastTerm = {
|
|
215
|
+
type: "exclusive",
|
|
216
|
+
terms: [lastTerm.terms]
|
|
217
|
+
};
|
|
218
|
+
}
|
|
213
219
|
if (usage.length > 0 && usage.slice(0, -1).every((t) => t.type === "command") && lastTerm.type === "exclusive" && lastTerm.terms.every((t) => t.length > 0 && (t[0].type === "command" || t[0].type === "option" || t[0].type === "argument" || t[0].type === "optional" && t[0].terms.length === 1 && (t[0].terms[0].type === "command" || t[0].terms[0].type === "option" || t[0].terms[0].type === "argument")))) {
|
|
214
220
|
const declaredBranches = declaredLast?.type === "exclusive" && declaredLast.terms.length === lastTerm.terms.length ? declaredLast.terms : void 0;
|
|
215
221
|
const lines = [];
|
package/dist/usage.js
CHANGED
|
@@ -209,7 +209,13 @@ function formatUsageLines(programName, usage, declared, options) {
|
|
|
209
209
|
if (options.expandCommands) {
|
|
210
210
|
let lastTerm = usage.at(-1);
|
|
211
211
|
const declaredLast = declared.at(-1);
|
|
212
|
-
if (lastTerm?.type === "optional" &&
|
|
212
|
+
if (lastTerm?.type === "optional" && declaredLast?.type === "exclusive") {
|
|
213
|
+
if (lastTerm.terms.length === 1 && lastTerm.terms[0].type === "exclusive") lastTerm = lastTerm.terms[0];
|
|
214
|
+
else if (lastTerm.terms[0]?.type === "command") lastTerm = {
|
|
215
|
+
type: "exclusive",
|
|
216
|
+
terms: [lastTerm.terms]
|
|
217
|
+
};
|
|
218
|
+
}
|
|
213
219
|
if (usage.length > 0 && usage.slice(0, -1).every((t) => t.type === "command") && lastTerm.type === "exclusive" && lastTerm.terms.every((t) => t.length > 0 && (t[0].type === "command" || t[0].type === "option" || t[0].type === "argument" || t[0].type === "optional" && t[0].terms.length === 1 && (t[0].terms[0].type === "command" || t[0].terms[0].type === "option" || t[0].terms[0].type === "argument")))) {
|
|
214
220
|
const declaredBranches = declaredLast?.type === "exclusive" && declaredLast.terms.length === lastTerm.terms.length ? declaredLast.terms : void 0;
|
|
215
221
|
const lines = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.4.0-dev.
|
|
3
|
+
"version": "1.4.0-dev.2711",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
},
|
|
246
246
|
"sideEffects": false,
|
|
247
247
|
"devDependencies": {
|
|
248
|
-
"@optique/env": "1.4.0-dev.
|
|
248
|
+
"@optique/env": "1.4.0-dev.2711+fda80c51",
|
|
249
249
|
"@types/node": "^24.0.0",
|
|
250
250
|
"fast-check": "^4.7.0",
|
|
251
251
|
"tsdown": "^0.13.0",
|