@optique/core 1.4.0-dev.2683 → 1.4.0-dev.2709
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/constructs.cjs +43 -16
- package/dist/constructs.js +43 -16
- package/dist/doc.cjs +11 -3
- package/dist/doc.js +12 -4
- package/dist/internal/empty-input.cjs +368 -0
- package/dist/internal/empty-input.js +355 -0
- package/dist/internal/usage.cjs +235 -0
- package/dist/internal/usage.d.cts +42 -0
- package/dist/internal/usage.d.ts +42 -0
- package/dist/internal/usage.js +233 -0
- package/dist/message.cjs +32 -5
- package/dist/message.js +33 -6
- package/dist/modifiers.cjs +43 -6
- package/dist/modifiers.js +43 -6
- package/dist/primitives.cjs +19 -4
- package/dist/primitives.js +19 -4
- package/dist/terminal-internal.cjs +4 -1
- package/dist/terminal-internal.d.cts +5 -0
- package/dist/terminal-internal.d.ts +5 -0
- package/dist/terminal-internal.js +4 -1
- package/dist/terminal-separators.cjs +13 -0
- package/dist/terminal-separators.js +12 -0
- package/dist/terminal.cjs +4 -1
- package/dist/terminal.js +5 -1
- package/dist/text-layout.cjs +14 -1
- package/dist/text-layout.d.cts +8 -1
- package/dist/text-layout.d.ts +8 -1
- package/dist/text-layout.js +13 -1
- package/dist/usage.cjs +41 -13
- package/dist/usage.d.cts +20 -0
- package/dist/usage.d.ts +20 -0
- package/dist/usage.js +41 -13
- package/package.json +10 -2
package/dist/constructs.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const require_internal_dependency = require('./internal/dependency.cjs');
|
|
|
8
8
|
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
9
9
|
const require_internal_parser = require('./internal/parser.cjs');
|
|
10
10
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
11
|
+
const require_empty_input = require('./internal/empty-input.cjs');
|
|
11
12
|
const require_execution_context = require('./execution-context.cjs');
|
|
12
13
|
const require_usage_internals = require('./usage-internals.cjs');
|
|
13
14
|
const require_short_option = require('./short-option.cjs');
|
|
@@ -890,7 +891,8 @@ function applyHiddenToUsageTerm(term, hidden) {
|
|
|
890
891
|
if (term.type === "multiple") return {
|
|
891
892
|
type: "multiple",
|
|
892
893
|
terms: applyHiddenToUsage(term.terms, hidden),
|
|
893
|
-
min: term.min
|
|
894
|
+
min: term.min,
|
|
895
|
+
...term.acceptsEmpty == null ? {} : { acceptsEmpty: term.acceptsEmpty }
|
|
894
896
|
};
|
|
895
897
|
if (term.type === "sequence") return {
|
|
896
898
|
type: "sequence",
|
|
@@ -898,7 +900,8 @@ function applyHiddenToUsageTerm(term, hidden) {
|
|
|
898
900
|
};
|
|
899
901
|
if (term.type === "exclusive") return {
|
|
900
902
|
type: "exclusive",
|
|
901
|
-
terms: term.terms.map((u) => applyHiddenToUsage(u, hidden))
|
|
903
|
+
terms: term.terms.map((u) => applyHiddenToUsage(u, hidden)),
|
|
904
|
+
...term.acceptsEmpty == null ? {} : { acceptsEmpty: term.acceptsEmpty }
|
|
902
905
|
};
|
|
903
906
|
if (term.type === "argument" || term.type === "option" || term.type === "command" || term.type === "passthrough") return {
|
|
904
907
|
...term,
|
|
@@ -962,7 +965,7 @@ function isOptionRequiringValue(usage, token) {
|
|
|
962
965
|
} else if (term.type === "optional" || term.type === "multiple" || term.type === "sequence") {
|
|
963
966
|
if (traverse(term.terms)) return true;
|
|
964
967
|
} else if (term.type === "exclusive") {
|
|
965
|
-
for (const exclusiveUsage of term.terms) if (traverse(exclusiveUsage)) return true;
|
|
968
|
+
for (const exclusiveUsage$1 of term.terms) if (traverse(exclusiveUsage$1)) return true;
|
|
966
969
|
}
|
|
967
970
|
return false;
|
|
968
971
|
}
|
|
@@ -1202,6 +1205,28 @@ function preserveExclusiveStateAfterOptionsTerminator(context, result) {
|
|
|
1202
1205
|
};
|
|
1203
1206
|
}
|
|
1204
1207
|
/**
|
|
1208
|
+
* Describes the branches of an exclusive combinator for the empty-input
|
|
1209
|
+
* rules.
|
|
1210
|
+
*/
|
|
1211
|
+
function getExclusiveBranches(parsers) {
|
|
1212
|
+
return parsers.map((parser) => ({
|
|
1213
|
+
facts: require_empty_input.getEmptyInputFacts(parser),
|
|
1214
|
+
matchesTokens: parser.leadingNames.size > 0 || parser.acceptingAnyToken
|
|
1215
|
+
}));
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Builds the exclusive usage term of `or()` and `longestMatch()`, recording
|
|
1219
|
+
* whether the combinator accepts an empty argument list when known.
|
|
1220
|
+
*/
|
|
1221
|
+
function exclusiveUsage(parsers, facts) {
|
|
1222
|
+
const acceptsEmpty = require_empty_input.acceptsEmptyInput(facts);
|
|
1223
|
+
return [{
|
|
1224
|
+
type: "exclusive",
|
|
1225
|
+
terms: parsers.map((p) => p.usage),
|
|
1226
|
+
...acceptsEmpty == null ? {} : { acceptsEmpty }
|
|
1227
|
+
}];
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1205
1230
|
* Creates a complete() method shared by or() and longestMatch().
|
|
1206
1231
|
* @internal
|
|
1207
1232
|
*/
|
|
@@ -1914,15 +1939,13 @@ function or(...args) {
|
|
|
1914
1939
|
if (optionsTerminatorResult != null) return preserveExclusiveStateAfterOptionsTerminator(context, optionsTerminatorResult);
|
|
1915
1940
|
return error;
|
|
1916
1941
|
};
|
|
1942
|
+
const emptyInputFacts = require_empty_input.orFacts(getExclusiveBranches(parsers));
|
|
1917
1943
|
const singleResult = {
|
|
1918
1944
|
mode: combinedMode,
|
|
1919
1945
|
$valueType: [],
|
|
1920
1946
|
$stateType: [],
|
|
1921
1947
|
priority: Math.max(...parsers.map((p) => p.priority)),
|
|
1922
|
-
usage:
|
|
1923
|
-
type: "exclusive",
|
|
1924
|
-
terms: parsers.map((p) => p.usage)
|
|
1925
|
-
}],
|
|
1948
|
+
usage: exclusiveUsage(parsers, emptyInputFacts),
|
|
1926
1949
|
leadingNames: unionLeadingNames(parsers),
|
|
1927
1950
|
acceptingAnyToken: parsers.some((p) => p.acceptingAnyToken),
|
|
1928
1951
|
initialState: void 0,
|
|
@@ -1984,7 +2007,7 @@ function or(...args) {
|
|
|
1984
2007
|
defineExclusiveSchedulingNodes(singleResult, parsers);
|
|
1985
2008
|
require_internal_parser.defineInheritedAnnotationParser(singleResult);
|
|
1986
2009
|
require_passthrough.defineReachableChildren(singleResult, parsers, (state) => selectExclusiveChildren(parsers, state, true));
|
|
1987
|
-
return require_modifiers.fluent(require_short_option.scopeParser(singleResult, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))));
|
|
2010
|
+
return require_modifiers.fluent(require_empty_input.withEmptyInputFacts(require_short_option.scopeParser(singleResult, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))), emptyInputFacts));
|
|
1988
2011
|
}
|
|
1989
2012
|
/**
|
|
1990
2013
|
* @since 0.5.0
|
|
@@ -2162,15 +2185,13 @@ function createLongestMatch(...args) {
|
|
|
2162
2185
|
if (bestMatch != null) return commitLongestMatch(context, bestMatch, void 0, consumingFailure);
|
|
2163
2186
|
return error;
|
|
2164
2187
|
};
|
|
2188
|
+
const emptyInputFacts = require_empty_input.longestMatchFacts(getExclusiveBranches(parsers));
|
|
2165
2189
|
const multiResult = {
|
|
2166
2190
|
mode: combinedMode,
|
|
2167
2191
|
$valueType: [],
|
|
2168
2192
|
$stateType: [],
|
|
2169
2193
|
priority: Math.max(...parsers.map((p) => p.priority)),
|
|
2170
|
-
usage:
|
|
2171
|
-
type: "exclusive",
|
|
2172
|
-
terms: parsers.map((p) => p.usage)
|
|
2173
|
-
}],
|
|
2194
|
+
usage: exclusiveUsage(parsers, emptyInputFacts),
|
|
2174
2195
|
leadingNames: unionLeadingNames(parsers),
|
|
2175
2196
|
acceptingAnyToken: parsers.some((p) => p.acceptingAnyToken),
|
|
2176
2197
|
initialState: void 0,
|
|
@@ -2230,7 +2251,7 @@ function createLongestMatch(...args) {
|
|
|
2230
2251
|
defineExclusiveSchedulingNodes(multiResult, parsers);
|
|
2231
2252
|
require_internal_parser.defineInheritedAnnotationParser(multiResult);
|
|
2232
2253
|
require_passthrough.defineReachableChildren(multiResult, parsers, (state) => selectExclusiveChildren(parsers, state, false));
|
|
2233
|
-
return require_modifiers.fluent(require_short_option.scopeParser(multiResult, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))));
|
|
2254
|
+
return require_modifiers.fluent(require_empty_input.withEmptyInputFacts(require_short_option.scopeParser(multiResult, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))), emptyInputFacts));
|
|
2234
2255
|
}
|
|
2235
2256
|
/**
|
|
2236
2257
|
* Creates the initial parse error shared by object-like combinators.
|
|
@@ -3288,7 +3309,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3288
3309
|
state: require_annotation_state.getWrappedChildParseState(state, getFieldState(field, parser), parser)
|
|
3289
3310
|
}));
|
|
3290
3311
|
});
|
|
3291
|
-
return require_modifiers.fluent(require_short_option.scopeParser(objectParser, require_short_option.combinedOptionScope(parserPairs.map(([, p]) => p), parserPairs.map(([field]) => field)), void 0, true))
|
|
3312
|
+
return require_modifiers.fluent(require_empty_input.withEmptyInputFacts(require_short_option.scopeParser(objectParser, require_short_option.combinedOptionScope(parserPairs.map(([, p]) => p), parserPairs.map(([field]) => field)), void 0, true), combinedMode === "sync" ? require_empty_input.objectFacts(parserPairs.map(([, p]) => ({
|
|
3313
|
+
facts: require_empty_input.getEmptyInputFacts(p),
|
|
3314
|
+
matchesTokens: p.leadingNames.size > 0 || p.acceptingAnyToken
|
|
3315
|
+
})), parserPairs.map(([field]) => field)) : {}));
|
|
3292
3316
|
}
|
|
3293
3317
|
function isParserLike(value) {
|
|
3294
3318
|
return value != null && (typeof value === "object" || typeof value === "function") && "parse" in value && "$valueType" in value && "$stateType" in value;
|
|
@@ -4339,7 +4363,10 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
4339
4363
|
parser,
|
|
4340
4364
|
state: require_annotation_state.getWrappedChildParseState(state, state[index], parser)
|
|
4341
4365
|
})));
|
|
4342
|
-
return require_modifiers.fluent(require_short_option.scopeParser(tupleParser, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))))
|
|
4366
|
+
return require_modifiers.fluent(require_empty_input.withEmptyInputFacts(require_short_option.scopeParser(tupleParser, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))), require_empty_input.tupleFacts(parsers.map((p) => ({
|
|
4367
|
+
facts: require_empty_input.getEmptyInputFacts(p),
|
|
4368
|
+
matchesTokens: p.leadingNames.size > 0 || p.acceptingAnyToken
|
|
4369
|
+
})))));
|
|
4343
4370
|
}
|
|
4344
4371
|
function seq(...rawArgs) {
|
|
4345
4372
|
const label = typeof rawArgs[0] === "string" ? rawArgs[0] : void 0;
|
|
@@ -6510,7 +6537,7 @@ function group(label, parser, options = {}) {
|
|
|
6510
6537
|
parser,
|
|
6511
6538
|
state
|
|
6512
6539
|
}]);
|
|
6513
|
-
return require_modifiers.fluent(require_short_option.scopeParser(groupParser, require_short_option.combinedOptionScope([parser])));
|
|
6540
|
+
return require_modifiers.fluent(require_empty_input.withEmptyInputFacts(require_short_option.scopeParser(groupParser, require_short_option.combinedOptionScope([parser])), require_empty_input.getEmptyInputFacts(parser)));
|
|
6514
6541
|
}
|
|
6515
6542
|
/**
|
|
6516
6543
|
* Creates a conditional parser that selects different branch parsers based on
|
package/dist/constructs.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createDependencySourceState, dependencyId, isDependencySourceState, isP
|
|
|
8
8
|
import { buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, completeEffectfulSourcesAsync, createDependencyRuntimeContext, effectfulSchedulingNodesKey, exclusiveSourceScopeKey, extractRawInputFromState, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, forkRuntimeForCommittedSubtree, getDefaultDependencySnapshot, guaranteedStaticSourceIdsKey, hasInactiveCompletion, isMatchedState, recordSourceScope, releaseUncollectedSourceValues, replaceCachedBarrierFailure, resolveDerivedSourceValues, resolveDerivedSourceValuesAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync, serializeSchedulingPath, sourceCollectionExpansionKey, staticSourceScopeKey } from "./dependency-runtime.js";
|
|
9
9
|
import { defineInheritedAnnotationParser, defineParseLanes, getOwnParseLanes, getParserSuggestRuntimeNodes, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
10
10
|
import { annotationViewTargets, getWrappedChildParseState, getWrappedChildState, reconcileObjectChildState, unwrapAnnotationView } from "./annotation-state.js";
|
|
11
|
+
import { acceptsEmptyInput, getEmptyInputFacts, longestMatchFacts, objectFacts, orFacts, tupleFacts, withEmptyInputFacts } from "./internal/empty-input.js";
|
|
11
12
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
12
13
|
import { collectLeadingCandidates } from "./usage-internals.js";
|
|
13
14
|
import { adoptOptionScope, combinedOptionScope, conditionalOptionScope, forkOptionScope, restoreOptionScope, scopeParser, selectableOptionScope, withOptionScope, withParserOptionScope } from "./short-option.js";
|
|
@@ -890,7 +891,8 @@ function applyHiddenToUsageTerm(term, hidden) {
|
|
|
890
891
|
if (term.type === "multiple") return {
|
|
891
892
|
type: "multiple",
|
|
892
893
|
terms: applyHiddenToUsage(term.terms, hidden),
|
|
893
|
-
min: term.min
|
|
894
|
+
min: term.min,
|
|
895
|
+
...term.acceptsEmpty == null ? {} : { acceptsEmpty: term.acceptsEmpty }
|
|
894
896
|
};
|
|
895
897
|
if (term.type === "sequence") return {
|
|
896
898
|
type: "sequence",
|
|
@@ -898,7 +900,8 @@ function applyHiddenToUsageTerm(term, hidden) {
|
|
|
898
900
|
};
|
|
899
901
|
if (term.type === "exclusive") return {
|
|
900
902
|
type: "exclusive",
|
|
901
|
-
terms: term.terms.map((u) => applyHiddenToUsage(u, hidden))
|
|
903
|
+
terms: term.terms.map((u) => applyHiddenToUsage(u, hidden)),
|
|
904
|
+
...term.acceptsEmpty == null ? {} : { acceptsEmpty: term.acceptsEmpty }
|
|
902
905
|
};
|
|
903
906
|
if (term.type === "argument" || term.type === "option" || term.type === "command" || term.type === "passthrough") return {
|
|
904
907
|
...term,
|
|
@@ -962,7 +965,7 @@ function isOptionRequiringValue(usage, token) {
|
|
|
962
965
|
} else if (term.type === "optional" || term.type === "multiple" || term.type === "sequence") {
|
|
963
966
|
if (traverse(term.terms)) return true;
|
|
964
967
|
} else if (term.type === "exclusive") {
|
|
965
|
-
for (const exclusiveUsage of term.terms) if (traverse(exclusiveUsage)) return true;
|
|
968
|
+
for (const exclusiveUsage$1 of term.terms) if (traverse(exclusiveUsage$1)) return true;
|
|
966
969
|
}
|
|
967
970
|
return false;
|
|
968
971
|
}
|
|
@@ -1202,6 +1205,28 @@ function preserveExclusiveStateAfterOptionsTerminator(context, result) {
|
|
|
1202
1205
|
};
|
|
1203
1206
|
}
|
|
1204
1207
|
/**
|
|
1208
|
+
* Describes the branches of an exclusive combinator for the empty-input
|
|
1209
|
+
* rules.
|
|
1210
|
+
*/
|
|
1211
|
+
function getExclusiveBranches(parsers) {
|
|
1212
|
+
return parsers.map((parser) => ({
|
|
1213
|
+
facts: getEmptyInputFacts(parser),
|
|
1214
|
+
matchesTokens: parser.leadingNames.size > 0 || parser.acceptingAnyToken
|
|
1215
|
+
}));
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Builds the exclusive usage term of `or()` and `longestMatch()`, recording
|
|
1219
|
+
* whether the combinator accepts an empty argument list when known.
|
|
1220
|
+
*/
|
|
1221
|
+
function exclusiveUsage(parsers, facts) {
|
|
1222
|
+
const acceptsEmpty = acceptsEmptyInput(facts);
|
|
1223
|
+
return [{
|
|
1224
|
+
type: "exclusive",
|
|
1225
|
+
terms: parsers.map((p) => p.usage),
|
|
1226
|
+
...acceptsEmpty == null ? {} : { acceptsEmpty }
|
|
1227
|
+
}];
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1205
1230
|
* Creates a complete() method shared by or() and longestMatch().
|
|
1206
1231
|
* @internal
|
|
1207
1232
|
*/
|
|
@@ -1914,15 +1939,13 @@ function or(...args) {
|
|
|
1914
1939
|
if (optionsTerminatorResult != null) return preserveExclusiveStateAfterOptionsTerminator(context, optionsTerminatorResult);
|
|
1915
1940
|
return error;
|
|
1916
1941
|
};
|
|
1942
|
+
const emptyInputFacts = orFacts(getExclusiveBranches(parsers));
|
|
1917
1943
|
const singleResult = {
|
|
1918
1944
|
mode: combinedMode,
|
|
1919
1945
|
$valueType: [],
|
|
1920
1946
|
$stateType: [],
|
|
1921
1947
|
priority: Math.max(...parsers.map((p) => p.priority)),
|
|
1922
|
-
usage:
|
|
1923
|
-
type: "exclusive",
|
|
1924
|
-
terms: parsers.map((p) => p.usage)
|
|
1925
|
-
}],
|
|
1948
|
+
usage: exclusiveUsage(parsers, emptyInputFacts),
|
|
1926
1949
|
leadingNames: unionLeadingNames(parsers),
|
|
1927
1950
|
acceptingAnyToken: parsers.some((p) => p.acceptingAnyToken),
|
|
1928
1951
|
initialState: void 0,
|
|
@@ -1984,7 +2007,7 @@ function or(...args) {
|
|
|
1984
2007
|
defineExclusiveSchedulingNodes(singleResult, parsers);
|
|
1985
2008
|
defineInheritedAnnotationParser(singleResult);
|
|
1986
2009
|
defineReachableChildren(singleResult, parsers, (state) => selectExclusiveChildren(parsers, state, true));
|
|
1987
|
-
return fluent(scopeParser(singleResult, combinedOptionScope(parsers, parsers.map((_, index) => index))));
|
|
2010
|
+
return fluent(withEmptyInputFacts(scopeParser(singleResult, combinedOptionScope(parsers, parsers.map((_, index) => index))), emptyInputFacts));
|
|
1988
2011
|
}
|
|
1989
2012
|
/**
|
|
1990
2013
|
* @since 0.5.0
|
|
@@ -2162,15 +2185,13 @@ function createLongestMatch(...args) {
|
|
|
2162
2185
|
if (bestMatch != null) return commitLongestMatch(context, bestMatch, void 0, consumingFailure);
|
|
2163
2186
|
return error;
|
|
2164
2187
|
};
|
|
2188
|
+
const emptyInputFacts = longestMatchFacts(getExclusiveBranches(parsers));
|
|
2165
2189
|
const multiResult = {
|
|
2166
2190
|
mode: combinedMode,
|
|
2167
2191
|
$valueType: [],
|
|
2168
2192
|
$stateType: [],
|
|
2169
2193
|
priority: Math.max(...parsers.map((p) => p.priority)),
|
|
2170
|
-
usage:
|
|
2171
|
-
type: "exclusive",
|
|
2172
|
-
terms: parsers.map((p) => p.usage)
|
|
2173
|
-
}],
|
|
2194
|
+
usage: exclusiveUsage(parsers, emptyInputFacts),
|
|
2174
2195
|
leadingNames: unionLeadingNames(parsers),
|
|
2175
2196
|
acceptingAnyToken: parsers.some((p) => p.acceptingAnyToken),
|
|
2176
2197
|
initialState: void 0,
|
|
@@ -2230,7 +2251,7 @@ function createLongestMatch(...args) {
|
|
|
2230
2251
|
defineExclusiveSchedulingNodes(multiResult, parsers);
|
|
2231
2252
|
defineInheritedAnnotationParser(multiResult);
|
|
2232
2253
|
defineReachableChildren(multiResult, parsers, (state) => selectExclusiveChildren(parsers, state, false));
|
|
2233
|
-
return fluent(scopeParser(multiResult, combinedOptionScope(parsers, parsers.map((_, index) => index))));
|
|
2254
|
+
return fluent(withEmptyInputFacts(scopeParser(multiResult, combinedOptionScope(parsers, parsers.map((_, index) => index))), emptyInputFacts));
|
|
2234
2255
|
}
|
|
2235
2256
|
/**
|
|
2236
2257
|
* Creates the initial parse error shared by object-like combinators.
|
|
@@ -3288,7 +3309,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3288
3309
|
state: getWrappedChildParseState(state, getFieldState(field, parser), parser)
|
|
3289
3310
|
}));
|
|
3290
3311
|
});
|
|
3291
|
-
return fluent(scopeParser(objectParser, combinedOptionScope(parserPairs.map(([, p]) => p), parserPairs.map(([field]) => field)), void 0, true))
|
|
3312
|
+
return fluent(withEmptyInputFacts(scopeParser(objectParser, combinedOptionScope(parserPairs.map(([, p]) => p), parserPairs.map(([field]) => field)), void 0, true), combinedMode === "sync" ? objectFacts(parserPairs.map(([, p]) => ({
|
|
3313
|
+
facts: getEmptyInputFacts(p),
|
|
3314
|
+
matchesTokens: p.leadingNames.size > 0 || p.acceptingAnyToken
|
|
3315
|
+
})), parserPairs.map(([field]) => field)) : {}));
|
|
3292
3316
|
}
|
|
3293
3317
|
function isParserLike(value) {
|
|
3294
3318
|
return value != null && (typeof value === "object" || typeof value === "function") && "parse" in value && "$valueType" in value && "$stateType" in value;
|
|
@@ -4339,7 +4363,10 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
4339
4363
|
parser,
|
|
4340
4364
|
state: getWrappedChildParseState(state, state[index], parser)
|
|
4341
4365
|
})));
|
|
4342
|
-
return fluent(scopeParser(tupleParser, combinedOptionScope(parsers, parsers.map((_, index) => index))))
|
|
4366
|
+
return fluent(withEmptyInputFacts(scopeParser(tupleParser, combinedOptionScope(parsers, parsers.map((_, index) => index))), tupleFacts(parsers.map((p) => ({
|
|
4367
|
+
facts: getEmptyInputFacts(p),
|
|
4368
|
+
matchesTokens: p.leadingNames.size > 0 || p.acceptingAnyToken
|
|
4369
|
+
})))));
|
|
4343
4370
|
}
|
|
4344
4371
|
function seq(...rawArgs) {
|
|
4345
4372
|
const label = typeof rawArgs[0] === "string" ? rawArgs[0] : void 0;
|
|
@@ -6510,7 +6537,7 @@ function group(label, parser, options = {}) {
|
|
|
6510
6537
|
parser,
|
|
6511
6538
|
state
|
|
6512
6539
|
}]);
|
|
6513
|
-
return fluent(scopeParser(groupParser, combinedOptionScope([parser])));
|
|
6540
|
+
return fluent(withEmptyInputFacts(scopeParser(groupParser, combinedOptionScope([parser])), getEmptyInputFacts(parser)));
|
|
6514
6541
|
}
|
|
6515
6542
|
/**
|
|
6516
6543
|
* Creates a conditional parser that selects different branch parsers based on
|
package/dist/doc.cjs
CHANGED
|
@@ -553,8 +553,16 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
553
553
|
column: extraTermOffset
|
|
554
554
|
}).cursor;
|
|
555
555
|
const appendAnnotation = (content, layout, style, ambient, quotes) => {
|
|
556
|
-
|
|
557
|
-
|
|
556
|
+
let prefixText = layout.prefix;
|
|
557
|
+
let prefix = require_text_layout.placeText(prefixText, cursor, descColumnWidth, 1);
|
|
558
|
+
if (prefix.text !== layout.prefix) {
|
|
559
|
+
description += "\n";
|
|
560
|
+
prefixText = require_text_layout.trimLeadingSpace(layout.prefix);
|
|
561
|
+
prefix = require_text_layout.placeText(prefixText, {
|
|
562
|
+
line: "",
|
|
563
|
+
column: 0
|
|
564
|
+
});
|
|
565
|
+
}
|
|
558
566
|
const rendered = formatMessage(content, {
|
|
559
567
|
colors: options.colors ? { resetSuffix: style } : false,
|
|
560
568
|
quotes,
|
|
@@ -562,7 +570,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
562
570
|
initialWidth: descColumnWidth != null || layout.prefixMetrics.lineCount > 1 ? prefix.cursor.column : void 0
|
|
563
571
|
}, ambient);
|
|
564
572
|
const suffix = require_text_layout.placeText(layout.suffix, require_text_layout.placeText(rendered, prefix.cursor).cursor, descColumnWidth);
|
|
565
|
-
const annotationText = `${
|
|
573
|
+
const annotationText = `${prefixText}${rendered}${opaqueFormatter && options.colors ? style : ""}${suffix.text}`;
|
|
566
574
|
description += options.colors ? `${style}${annotationText}${style ? "\x1B[0m" : ""}` : annotationText;
|
|
567
575
|
cursor = suffix.cursor;
|
|
568
576
|
};
|
package/dist/doc.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cacheTerminalTheme, renderTerminalTerm, styleCode } from "./terminal-internal.js";
|
|
2
|
-
import { measureAnnotation, measureText, placeText, spaceAfterLabel } from "./text-layout.js";
|
|
2
|
+
import { measureAnnotation, measureText, placeText, spaceAfterLabel, trimLeadingSpace } from "./text-layout.js";
|
|
3
3
|
import { validateLabel, validateProgramName } from "./validate.js";
|
|
4
4
|
import { cloneUsageTerm, formatUsage, formatUsageTerm, isDocHidden } from "./usage.js";
|
|
5
5
|
import { hasAutomaticWidth, minimumUsageWidth, reportAutomaticWidth } from "./terminal-width.js";
|
|
@@ -553,8 +553,16 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
553
553
|
column: extraTermOffset
|
|
554
554
|
}).cursor;
|
|
555
555
|
const appendAnnotation = (content, layout, style, ambient, quotes) => {
|
|
556
|
-
|
|
557
|
-
|
|
556
|
+
let prefixText = layout.prefix;
|
|
557
|
+
let prefix = placeText(prefixText, cursor, descColumnWidth, 1);
|
|
558
|
+
if (prefix.text !== layout.prefix) {
|
|
559
|
+
description += "\n";
|
|
560
|
+
prefixText = trimLeadingSpace(layout.prefix);
|
|
561
|
+
prefix = placeText(prefixText, {
|
|
562
|
+
line: "",
|
|
563
|
+
column: 0
|
|
564
|
+
});
|
|
565
|
+
}
|
|
558
566
|
const rendered = formatMessage(content, {
|
|
559
567
|
colors: options.colors ? { resetSuffix: style } : false,
|
|
560
568
|
quotes,
|
|
@@ -562,7 +570,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
562
570
|
initialWidth: descColumnWidth != null || layout.prefixMetrics.lineCount > 1 ? prefix.cursor.column : void 0
|
|
563
571
|
}, ambient);
|
|
564
572
|
const suffix = placeText(layout.suffix, placeText(rendered, prefix.cursor).cursor, descColumnWidth);
|
|
565
|
-
const annotationText = `${
|
|
573
|
+
const annotationText = `${prefixText}${rendered}${opaqueFormatter && options.colors ? style : ""}${suffix.text}`;
|
|
566
574
|
description += options.colors ? `${style}${annotationText}${style ? "\x1B[0m" : ""}` : annotationText;
|
|
567
575
|
cursor = suffix.cursor;
|
|
568
576
|
};
|