@optique/core 1.4.0-dev.2622 → 1.4.0-dev.2625
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 +169 -91
- package/dist/constructs.js +169 -91
- package/dist/execution-context.cjs +2 -1
- package/dist/execution-context.js +3 -1
- package/dist/extension.cjs +15 -0
- package/dist/extension.d.cts +12 -1
- package/dist/extension.d.ts +12 -1
- package/dist/extension.js +15 -1
- package/dist/facade.cjs +3 -69
- package/dist/facade.js +1 -67
- package/dist/modifiers.cjs +5 -4
- package/dist/modifiers.js +5 -4
- package/dist/primitives.cjs +69 -27
- package/dist/primitives.d.cts +3 -3
- package/dist/primitives.d.ts +3 -3
- package/dist/primitives.js +69 -27
- package/dist/short-option.cjs +311 -0
- package/dist/short-option.js +297 -0
- package/dist/usage-internals.cjs +73 -0
- package/dist/usage-internals.js +71 -1
- package/package.json +2 -2
- package/skills/optique/SKILL.md +6 -6
package/dist/constructs.cjs
CHANGED
|
@@ -8,12 +8,13 @@ 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_command_alias = require('./internal/command-alias.cjs');
|
|
12
11
|
const require_execution_context = require('./execution-context.cjs');
|
|
12
|
+
const require_usage_internals = require('./usage-internals.cjs');
|
|
13
|
+
const require_short_option = require('./short-option.cjs');
|
|
14
|
+
const require_command_alias = require('./internal/command-alias.cjs');
|
|
13
15
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
14
16
|
const require_modifiers = require('./modifiers.cjs');
|
|
15
17
|
const require_suggestion = require('./suggestion.cjs');
|
|
16
|
-
const require_usage_internals = require('./usage-internals.cjs');
|
|
17
18
|
|
|
18
19
|
//#region src/constructs.ts
|
|
19
20
|
/**
|
|
@@ -48,7 +49,8 @@ function withoutRepublishInstruction(exec) {
|
|
|
48
49
|
}
|
|
49
50
|
function withChildContext$1(context, segment, state, parser, usage) {
|
|
50
51
|
const childState = parser == null ? state : require_annotation_state.getWrappedChildParseState(context.state, state, parser);
|
|
51
|
-
|
|
52
|
+
const child = require_execution_context.withChildContext(context, segment, childState, usage);
|
|
53
|
+
return parser == null ? child : require_short_option.withParserOptionScope(child, parser);
|
|
52
54
|
}
|
|
53
55
|
function isUnmatchedDependencyState(state, parser) {
|
|
54
56
|
if (state === void 0) return true;
|
|
@@ -1402,7 +1404,7 @@ function or(...args) {
|
|
|
1402
1404
|
let optionsTerminatorResult = null;
|
|
1403
1405
|
let provisionalAmbiguous = false;
|
|
1404
1406
|
for (const [parser, i] of orderedParsers) {
|
|
1405
|
-
const result = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1407
|
+
const result = parser.parse(withChildContext$1(require_short_option.forkOptionScope(context), i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1406
1408
|
if (isOptionsTerminatorOnlyResult(context, result)) {
|
|
1407
1409
|
if (activeState?.[0] === i && activeState[1].success && activeState[1].consumed.length > 0 && result.next.buffer.length < 1) return preserveExclusiveStateAfterOptionsTerminator(context, result);
|
|
1408
1410
|
optionsTerminatorResult ??= result;
|
|
@@ -1437,7 +1439,7 @@ function or(...args) {
|
|
|
1437
1439
|
return {
|
|
1438
1440
|
success: true,
|
|
1439
1441
|
next: {
|
|
1440
|
-
...context,
|
|
1442
|
+
...require_short_option.adoptOptionScope(context, result.next),
|
|
1441
1443
|
buffer: result.next.buffer,
|
|
1442
1444
|
optionsTerminated: result.next.optionsTerminated,
|
|
1443
1445
|
state: createExclusiveState(context.state, i, parser, result),
|
|
@@ -1473,7 +1475,7 @@ function or(...args) {
|
|
|
1473
1475
|
return {
|
|
1474
1476
|
success: true,
|
|
1475
1477
|
next: {
|
|
1476
|
-
...context,
|
|
1478
|
+
...require_short_option.adoptOptionScope(context, replayedResult.next),
|
|
1477
1479
|
buffer: replayedResult.next.buffer,
|
|
1478
1480
|
optionsTerminated: replayedResult.next.optionsTerminated,
|
|
1479
1481
|
state: createExclusiveState(context.state, i, parser, {
|
|
@@ -1492,7 +1494,7 @@ function or(...args) {
|
|
|
1492
1494
|
return {
|
|
1493
1495
|
success: true,
|
|
1494
1496
|
next: {
|
|
1495
|
-
...context,
|
|
1497
|
+
...require_short_option.adoptOptionScope(context, result.next),
|
|
1496
1498
|
buffer: result.next.buffer,
|
|
1497
1499
|
optionsTerminated: result.next.optionsTerminated,
|
|
1498
1500
|
state: createExclusiveState(context.state, i, parser, result),
|
|
@@ -1518,7 +1520,7 @@ function or(...args) {
|
|
|
1518
1520
|
success: true,
|
|
1519
1521
|
...zeroConsumedBranch.result.provisional ? { provisional: true } : {},
|
|
1520
1522
|
next: {
|
|
1521
|
-
...context,
|
|
1523
|
+
...require_short_option.adoptOptionScope(context, zeroConsumedBranch.result.next),
|
|
1522
1524
|
state: createExclusiveState(context.state, zeroConsumedBranch.index, zeroConsumedBranch.parser, zeroConsumedBranch.result),
|
|
1523
1525
|
...mergedExec != null ? {
|
|
1524
1526
|
exec: mergedExec,
|
|
@@ -1536,7 +1538,7 @@ function or(...args) {
|
|
|
1536
1538
|
success: true,
|
|
1537
1539
|
provisional: true,
|
|
1538
1540
|
next: {
|
|
1539
|
-
...context,
|
|
1541
|
+
...require_short_option.adoptOptionScope(context, provisionalConsuming.result.next),
|
|
1540
1542
|
buffer: provisionalConsuming.result.next.buffer,
|
|
1541
1543
|
optionsTerminated: provisionalConsuming.result.next.optionsTerminated,
|
|
1542
1544
|
state: createExclusiveState(context.state, provisionalConsuming.index, provisionalConsuming.parser, provisionalConsuming.result),
|
|
@@ -1551,7 +1553,7 @@ function or(...args) {
|
|
|
1551
1553
|
if (activeState != null && activeState[1].success) {
|
|
1552
1554
|
const previouslyConsumed = activeState[1].consumed;
|
|
1553
1555
|
const checkResult = provisionalConsuming.parser.parse({
|
|
1554
|
-
...withChildContext$1(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
1556
|
+
...withChildContext$1(require_short_option.forkOptionScope(context), provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
1555
1557
|
buffer: previouslyConsumed
|
|
1556
1558
|
});
|
|
1557
1559
|
const canConsumeShared = checkResult.success && checkResult.consumed.length === previouslyConsumed.length && checkResult.consumed.every((c, idx) => c === previouslyConsumed[idx]);
|
|
@@ -1570,7 +1572,7 @@ function or(...args) {
|
|
|
1570
1572
|
success: true,
|
|
1571
1573
|
provisional: true,
|
|
1572
1574
|
next: {
|
|
1573
|
-
...context,
|
|
1575
|
+
...require_short_option.adoptOptionScope(context, replayedResult.next),
|
|
1574
1576
|
buffer: replayedResult.next.buffer,
|
|
1575
1577
|
optionsTerminated: replayedResult.next.optionsTerminated,
|
|
1576
1578
|
state: createExclusiveState(context.state, provisionalConsuming.index, provisionalConsuming.parser, {
|
|
@@ -1605,7 +1607,7 @@ function or(...args) {
|
|
|
1605
1607
|
let optionsTerminatorResult = null;
|
|
1606
1608
|
let provisionalAmbiguous = false;
|
|
1607
1609
|
for (const [parser, i] of orderedParsers) {
|
|
1608
|
-
const resultOrPromise = parser.parse(withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1610
|
+
const resultOrPromise = parser.parse(withChildContext$1(require_short_option.forkOptionScope(context), i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser));
|
|
1609
1611
|
const result = await resultOrPromise;
|
|
1610
1612
|
if (isOptionsTerminatorOnlyResult(context, result)) {
|
|
1611
1613
|
if (activeState?.[0] === i && activeState[1].success && activeState[1].consumed.length > 0 && result.next.buffer.length < 1) return preserveExclusiveStateAfterOptionsTerminator(context, result);
|
|
@@ -1641,7 +1643,7 @@ function or(...args) {
|
|
|
1641
1643
|
return {
|
|
1642
1644
|
success: true,
|
|
1643
1645
|
next: {
|
|
1644
|
-
...context,
|
|
1646
|
+
...require_short_option.adoptOptionScope(context, result.next),
|
|
1645
1647
|
buffer: result.next.buffer,
|
|
1646
1648
|
optionsTerminated: result.next.optionsTerminated,
|
|
1647
1649
|
state: createExclusiveState(context.state, i, parser, result),
|
|
@@ -1679,7 +1681,7 @@ function or(...args) {
|
|
|
1679
1681
|
return {
|
|
1680
1682
|
success: true,
|
|
1681
1683
|
next: {
|
|
1682
|
-
...context,
|
|
1684
|
+
...require_short_option.adoptOptionScope(context, replayedResult.next),
|
|
1683
1685
|
buffer: replayedResult.next.buffer,
|
|
1684
1686
|
optionsTerminated: replayedResult.next.optionsTerminated,
|
|
1685
1687
|
state: createExclusiveState(context.state, i, parser, {
|
|
@@ -1698,7 +1700,7 @@ function or(...args) {
|
|
|
1698
1700
|
return {
|
|
1699
1701
|
success: true,
|
|
1700
1702
|
next: {
|
|
1701
|
-
...context,
|
|
1703
|
+
...require_short_option.adoptOptionScope(context, result.next),
|
|
1702
1704
|
buffer: result.next.buffer,
|
|
1703
1705
|
optionsTerminated: result.next.optionsTerminated,
|
|
1704
1706
|
state: createExclusiveState(context.state, i, parser, result),
|
|
@@ -1724,7 +1726,7 @@ function or(...args) {
|
|
|
1724
1726
|
success: true,
|
|
1725
1727
|
...zeroConsumedBranch.result.provisional ? { provisional: true } : {},
|
|
1726
1728
|
next: {
|
|
1727
|
-
...context,
|
|
1729
|
+
...require_short_option.adoptOptionScope(context, zeroConsumedBranch.result.next),
|
|
1728
1730
|
state: createExclusiveState(context.state, zeroConsumedBranch.index, zeroConsumedBranch.parser, zeroConsumedBranch.result),
|
|
1729
1731
|
...mergedExec != null ? {
|
|
1730
1732
|
exec: mergedExec,
|
|
@@ -1742,7 +1744,7 @@ function or(...args) {
|
|
|
1742
1744
|
success: true,
|
|
1743
1745
|
provisional: true,
|
|
1744
1746
|
next: {
|
|
1745
|
-
...context,
|
|
1747
|
+
...require_short_option.adoptOptionScope(context, provisionalConsuming.result.next),
|
|
1746
1748
|
buffer: provisionalConsuming.result.next.buffer,
|
|
1747
1749
|
optionsTerminated: provisionalConsuming.result.next.optionsTerminated,
|
|
1748
1750
|
state: createExclusiveState(context.state, provisionalConsuming.index, provisionalConsuming.parser, provisionalConsuming.result),
|
|
@@ -1757,7 +1759,7 @@ function or(...args) {
|
|
|
1757
1759
|
if (activeState != null && activeState[1].success) {
|
|
1758
1760
|
const previouslyConsumed = activeState[1].consumed;
|
|
1759
1761
|
const checkResult = await provisionalConsuming.parser.parse({
|
|
1760
|
-
...withChildContext$1(context, provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
1762
|
+
...withChildContext$1(require_short_option.forkOptionScope(context), provisionalConsuming.index, provisionalConsuming.parser.initialState, provisionalConsuming.parser),
|
|
1761
1763
|
buffer: previouslyConsumed
|
|
1762
1764
|
});
|
|
1763
1765
|
const canConsumeShared = checkResult.success && checkResult.consumed.length === previouslyConsumed.length && checkResult.consumed.every((c, idx) => c === previouslyConsumed[idx]);
|
|
@@ -1776,7 +1778,7 @@ function or(...args) {
|
|
|
1776
1778
|
success: true,
|
|
1777
1779
|
provisional: true,
|
|
1778
1780
|
next: {
|
|
1779
|
-
...context,
|
|
1781
|
+
...require_short_option.adoptOptionScope(context, replayedResult.next),
|
|
1780
1782
|
buffer: replayedResult.next.buffer,
|
|
1781
1783
|
optionsTerminated: replayedResult.next.optionsTerminated,
|
|
1782
1784
|
state: createExclusiveState(context.state, provisionalConsuming.index, provisionalConsuming.parser, {
|
|
@@ -1863,7 +1865,7 @@ function or(...args) {
|
|
|
1863
1865
|
if (singleDependencyMetadata != null) singleResult.dependencyMetadata = singleDependencyMetadata;
|
|
1864
1866
|
defineExclusiveSchedulingNodes(singleResult, parsers);
|
|
1865
1867
|
require_internal_parser.defineInheritedAnnotationParser(singleResult);
|
|
1866
|
-
return require_modifiers.fluent(singleResult);
|
|
1868
|
+
return require_modifiers.fluent(require_short_option.scopeParser(singleResult, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))));
|
|
1867
1869
|
}
|
|
1868
1870
|
/**
|
|
1869
1871
|
* @since 0.5.0
|
|
@@ -1912,7 +1914,7 @@ function createLongestMatch(...args) {
|
|
|
1912
1914
|
return {
|
|
1913
1915
|
success: true,
|
|
1914
1916
|
next: {
|
|
1915
|
-
...context,
|
|
1917
|
+
...require_short_option.adoptOptionScope(context, selectedResult.next),
|
|
1916
1918
|
buffer: selectedResult.next.buffer,
|
|
1917
1919
|
optionsTerminated: selectedResult.next.optionsTerminated,
|
|
1918
1920
|
state: createExclusiveState(context.state, match.index, parser, selectedResult),
|
|
@@ -1952,7 +1954,7 @@ function createLongestMatch(...args) {
|
|
|
1952
1954
|
const activeState = normalizeExclusiveState(context.state);
|
|
1953
1955
|
for (let i = 0; i < syncParsers.length; i++) {
|
|
1954
1956
|
const parser = syncParsers[i];
|
|
1955
|
-
const childContext = withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser);
|
|
1957
|
+
const childContext = withChildContext$1(require_short_option.forkOptionScope(context), i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser);
|
|
1956
1958
|
const result = parser.parse(childContext);
|
|
1957
1959
|
if (isOptionsTerminatorOnlyResult(context, result)) {
|
|
1958
1960
|
optionsTerminatorMatches.push({
|
|
@@ -1988,7 +1990,7 @@ function createLongestMatch(...args) {
|
|
|
1988
1990
|
const activeState = normalizeExclusiveState(context.state);
|
|
1989
1991
|
for (let i = 0; i < parsers.length; i++) {
|
|
1990
1992
|
const parser = parsers[i];
|
|
1991
|
-
const childContext = withChildContext$1(context, i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser);
|
|
1993
|
+
const childContext = withChildContext$1(require_short_option.forkOptionScope(context), i, activeState == null || activeState[0] !== i || !activeState[1].success ? parser.initialState : activeState[1].next.state, parser);
|
|
1992
1994
|
const resultOrPromise = parser.parse(childContext);
|
|
1993
1995
|
const result = await resultOrPromise;
|
|
1994
1996
|
if (isOptionsTerminatorOnlyResult(context, result)) {
|
|
@@ -2079,7 +2081,7 @@ function createLongestMatch(...args) {
|
|
|
2079
2081
|
if (multiDependencyMetadata != null) multiResult.dependencyMetadata = multiDependencyMetadata;
|
|
2080
2082
|
defineExclusiveSchedulingNodes(multiResult, parsers);
|
|
2081
2083
|
require_internal_parser.defineInheritedAnnotationParser(multiResult);
|
|
2082
|
-
return require_modifiers.fluent(multiResult);
|
|
2084
|
+
return require_modifiers.fluent(require_short_option.scopeParser(multiResult, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))));
|
|
2083
2085
|
}
|
|
2084
2086
|
/**
|
|
2085
2087
|
* Creates the initial parse error shared by object-like combinators.
|
|
@@ -2522,6 +2524,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2522
2524
|
next: context,
|
|
2523
2525
|
consumed: []
|
|
2524
2526
|
};
|
|
2527
|
+
require_short_option.adoptOptionScope(context, result.next);
|
|
2525
2528
|
const mergedExec = require_execution_context.mergeChildExec(context.exec, result.next.exec);
|
|
2526
2529
|
const nextState = result.next.state === fieldState ? context.state : {
|
|
2527
2530
|
...context.state,
|
|
@@ -2553,10 +2556,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2553
2556
|
parse(context) {
|
|
2554
2557
|
const fieldState = createFieldStateGetter(context.state, getObjectParseChildState)(field, parser);
|
|
2555
2558
|
return require_mode_dispatch.dispatchByMode(combinedMode, () => {
|
|
2556
|
-
const result = parser.parse(withChildContext$1(context, field, fieldState, parser));
|
|
2559
|
+
const result = parser.parse(withChildContext$1(require_short_option.forkOptionScope(context), field, fieldState, parser));
|
|
2557
2560
|
return adaptFieldLaneResult(context, field, parser, fieldState, result);
|
|
2558
2561
|
}, async () => {
|
|
2559
|
-
const result = await parser.parse(withChildContext$1(context, field, fieldState, parser));
|
|
2562
|
+
const result = await parser.parse(withChildContext$1(require_short_option.forkOptionScope(context), field, fieldState, parser));
|
|
2560
2563
|
return adaptFieldLaneResult(context, field, parser, fieldState, result);
|
|
2561
2564
|
});
|
|
2562
2565
|
}
|
|
@@ -2572,8 +2575,9 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2572
2575
|
madeProgress = false;
|
|
2573
2576
|
const getFieldState = createFieldStateGetter(currentContext.state, getObjectParseChildState);
|
|
2574
2577
|
for (const [field, parser] of parserPairs) {
|
|
2575
|
-
const result = parser.parse(withChildContext$1(currentContext, field, getFieldState(field, parser), parser));
|
|
2578
|
+
const result = parser.parse(withChildContext$1(require_short_option.forkOptionScope(currentContext), field, getFieldState(field, parser), parser));
|
|
2576
2579
|
if (result.success && result.consumed.length > 0) {
|
|
2580
|
+
require_short_option.adoptOptionScope(currentContext, result.next);
|
|
2577
2581
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2578
2582
|
currentContext = {
|
|
2579
2583
|
...currentContext,
|
|
@@ -2604,8 +2608,9 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2604
2608
|
const typedParser = parser;
|
|
2605
2609
|
if (parser.leadingNames.size > 0 || typedParser.acceptingAnyToken) continue;
|
|
2606
2610
|
const fieldState = getFieldState(field, parser);
|
|
2607
|
-
const result = typedParser.parse(withChildContext$1(currentContext, field, fieldState, parser));
|
|
2611
|
+
const result = typedParser.parse(withChildContext$1(require_short_option.forkOptionScope(currentContext), field, fieldState, parser));
|
|
2608
2612
|
if (result.success && result.consumed.length === 0 && result.next.state !== fieldState) {
|
|
2613
|
+
require_short_option.adoptOptionScope(currentContext, result.next);
|
|
2609
2614
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2610
2615
|
currentContext = {
|
|
2611
2616
|
...currentContext,
|
|
@@ -2678,9 +2683,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2678
2683
|
madeProgress = false;
|
|
2679
2684
|
const getFieldState = createFieldStateGetter(currentContext.state, getObjectParseChildState);
|
|
2680
2685
|
for (const [field, parser] of parserPairs) {
|
|
2681
|
-
const resultOrPromise = parser.parse(withChildContext$1(currentContext, field, getFieldState(field, parser), parser));
|
|
2686
|
+
const resultOrPromise = parser.parse(withChildContext$1(require_short_option.forkOptionScope(currentContext), field, getFieldState(field, parser), parser));
|
|
2682
2687
|
const result = await resultOrPromise;
|
|
2683
2688
|
if (result.success && result.consumed.length > 0) {
|
|
2689
|
+
require_short_option.adoptOptionScope(currentContext, result.next);
|
|
2684
2690
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2685
2691
|
currentContext = {
|
|
2686
2692
|
...currentContext,
|
|
@@ -2710,9 +2716,10 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2710
2716
|
if (consumedFields.has(field)) continue;
|
|
2711
2717
|
if (parser.leadingNames.size > 0 || parser.acceptingAnyToken) continue;
|
|
2712
2718
|
const fieldState = getFieldState(field, parser);
|
|
2713
|
-
const resultOrPromise = parser.parse(withChildContext$1(currentContext, field, fieldState, parser));
|
|
2719
|
+
const resultOrPromise = parser.parse(withChildContext$1(require_short_option.forkOptionScope(currentContext), field, fieldState, parser));
|
|
2714
2720
|
const result = await resultOrPromise;
|
|
2715
2721
|
if (result.success && result.consumed.length === 0 && result.next.state !== fieldState) {
|
|
2722
|
+
require_short_option.adoptOptionScope(currentContext, result.next);
|
|
2716
2723
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
2717
2724
|
currentContext = {
|
|
2718
2725
|
...currentContext,
|
|
@@ -3093,15 +3100,15 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3093
3100
|
});
|
|
3094
3101
|
require_internal_parser.defineParseLanes(objectParser, objectParseLanes);
|
|
3095
3102
|
require_internal_parser.defineInheritedAnnotationParser(objectParser);
|
|
3096
|
-
return require_modifiers.fluent(objectParser);
|
|
3103
|
+
return require_modifiers.fluent(require_short_option.scopeParser(objectParser, require_short_option.combinedOptionScope(parserPairs.map(([, p]) => p), parserPairs.map(([field]) => field)), void 0, true));
|
|
3097
3104
|
}
|
|
3098
3105
|
function isParserLike(value) {
|
|
3099
3106
|
return value != null && (typeof value === "object" || typeof value === "function") && "parse" in value && "$valueType" in value && "$stateType" in value;
|
|
3100
3107
|
}
|
|
3101
3108
|
function tokenMatchesLeadingName(token, candidates) {
|
|
3102
3109
|
if (token == null) return false;
|
|
3103
|
-
for (const name of candidates.optionNames) if (token === name) return true;
|
|
3104
|
-
for (const name of candidates.joinedOptionNames) if (name.startsWith("/") && token.startsWith(`${name}:`) || (name.startsWith("--") || name.startsWith("-") && name.length > 2) && token.startsWith(`${name}=`)) return true;
|
|
3110
|
+
for (const name of candidates.optionNames) if (token === name || name.startsWith("-") && !name.startsWith("--") && name.length > 2 && !/^-[^-]$/u.test(name) && token.startsWith(`${name}=`)) return true;
|
|
3111
|
+
for (const name of candidates.joinedOptionNames) if (/^-[^-]$/u.test(name) && token.startsWith(name) || name.startsWith("/") && token.startsWith(`${name}:`) || (name.startsWith("--") || name.startsWith("-") && name.length > 2 && !/^-[^-]$/u.test(name)) && token.startsWith(`${name}=`)) return true;
|
|
3105
3112
|
for (const name of candidates.commandNames) if (token === name) return true;
|
|
3106
3113
|
return false;
|
|
3107
3114
|
}
|
|
@@ -3327,6 +3334,7 @@ function advanceSeqSuggestContextSync(context, parsers, initialStates) {
|
|
|
3327
3334
|
while (currentContext.state.index < parsers.length) {
|
|
3328
3335
|
const index = currentContext.state.index;
|
|
3329
3336
|
const parser = parsers[index];
|
|
3337
|
+
currentContext = require_short_option.withParserOptionScope(currentContext, parser, index);
|
|
3330
3338
|
const parserState = getSeqChildState(currentContext.state, index, parser);
|
|
3331
3339
|
if (currentContext.buffer.length < 1) break;
|
|
3332
3340
|
if (shouldAdvanceSeqBeforeParse(parser, parserState, initialStates[index], currentContext, index, parsers)) {
|
|
@@ -3353,6 +3361,7 @@ async function advanceSeqSuggestContextAsync(context, parsers, initialStates) {
|
|
|
3353
3361
|
while (currentContext.state.index < parsers.length) {
|
|
3354
3362
|
const index = currentContext.state.index;
|
|
3355
3363
|
const parser = parsers[index];
|
|
3364
|
+
currentContext = require_short_option.withParserOptionScope(currentContext, parser, index);
|
|
3356
3365
|
const parserState = getSeqChildState(currentContext.state, index, parser);
|
|
3357
3366
|
if (currentContext.buffer.length < 1) break;
|
|
3358
3367
|
if (shouldAdvanceSeqBeforeParse(parser, parserState, initialStates[index], currentContext, index, parsers)) {
|
|
@@ -4109,7 +4118,7 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
4109
4118
|
enumerable: false
|
|
4110
4119
|
});
|
|
4111
4120
|
require_internal_parser.defineInheritedAnnotationParser(tupleParser);
|
|
4112
|
-
return require_modifiers.fluent(tupleParser);
|
|
4121
|
+
return require_modifiers.fluent(require_short_option.scopeParser(tupleParser, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))));
|
|
4113
4122
|
}
|
|
4114
4123
|
function seq(...rawArgs) {
|
|
4115
4124
|
const label = typeof rawArgs[0] === "string" ? rawArgs[0] : void 0;
|
|
@@ -4127,12 +4136,37 @@ function seq(...rawArgs) {
|
|
|
4127
4136
|
...result,
|
|
4128
4137
|
consumed: consumed.length + result.consumed
|
|
4129
4138
|
});
|
|
4139
|
+
const reachableSeqScope = (context) => {
|
|
4140
|
+
let end = Math.min(context.state.index + 1, parsers.length);
|
|
4141
|
+
while (end < parsers.length) {
|
|
4142
|
+
const index = end - 1;
|
|
4143
|
+
const child = parsers[index];
|
|
4144
|
+
if (context.buffer.length > 0 && !tokenMatchesLeadingName(context.buffer[0], leadingCandidatesAfter(parsers, end))) break;
|
|
4145
|
+
if (!parserCanSkipAt(child, getSeqChildState(context.state, index, child), context.exec, index)) break;
|
|
4146
|
+
end++;
|
|
4147
|
+
}
|
|
4148
|
+
return require_short_option.combinedOptionScope(parsers.slice(0, end), parsers.slice(0, end).map((_, index) => index));
|
|
4149
|
+
};
|
|
4150
|
+
const seqScope = require_short_option.selectableOptionScope((selections, arities, context, path = []) => {
|
|
4151
|
+
const initialContext = {
|
|
4152
|
+
state: context == null ? initialState : require_internal_annotations.inheritAnnotations(context.state, initialState),
|
|
4153
|
+
buffer: context?.buffer ?? [],
|
|
4154
|
+
usage: context?.usage ?? [],
|
|
4155
|
+
optionsTerminated: context?.optionsTerminated ?? false,
|
|
4156
|
+
exec: context?.exec == null ? void 0 : {
|
|
4157
|
+
...context.exec,
|
|
4158
|
+
path
|
|
4159
|
+
}
|
|
4160
|
+
};
|
|
4161
|
+
return reachableSeqScope(initialContext)(selections, arities, context, path);
|
|
4162
|
+
});
|
|
4130
4163
|
const parseSync = (context) => {
|
|
4131
4164
|
let currentContext = context;
|
|
4132
4165
|
const allConsumed = [];
|
|
4133
4166
|
while (currentContext.state.index < syncParsers.length) {
|
|
4134
4167
|
const index = currentContext.state.index;
|
|
4135
4168
|
const parser = syncParsers[index];
|
|
4169
|
+
seqScope.select(currentContext, reachableSeqScope(currentContext));
|
|
4136
4170
|
const parserState = getSeqChildState(currentContext.state, index, parser);
|
|
4137
4171
|
if (currentContext.buffer.length < 1) break;
|
|
4138
4172
|
if (shouldAdvanceSeqBeforeParse(parser, parserState, initialState.states[index], currentContext, index, syncParsers)) {
|
|
@@ -4141,13 +4175,14 @@ function seq(...rawArgs) {
|
|
|
4141
4175
|
currentContext = advanceSeqContext(currentContext, index + 1, consumedTerminator);
|
|
4142
4176
|
continue;
|
|
4143
4177
|
}
|
|
4144
|
-
const result = parser.parse(withChildContext$1(currentContext, index, parserState, parser));
|
|
4178
|
+
const result = parser.parse(withChildContext$1(require_short_option.forkOptionScope(currentContext), index, parserState, parser));
|
|
4145
4179
|
if (!result.success) {
|
|
4146
4180
|
if (result.consumed > 0) return withSeqConsumedDepth(result, allConsumed);
|
|
4147
4181
|
if (!parserCanSkipAt(parser, parserState, currentContext.exec, index)) return withSeqConsumedDepth(result, allConsumed);
|
|
4148
4182
|
currentContext = advanceSeqContext(currentContext, index + 1, false);
|
|
4149
4183
|
continue;
|
|
4150
4184
|
}
|
|
4185
|
+
require_short_option.adoptOptionScope(currentContext, result.next);
|
|
4151
4186
|
const states = updateSeqChildState(currentContext.state, index, result.next.state, parser);
|
|
4152
4187
|
const nextIndex = result.consumed.length > 0 ? index : index + 1;
|
|
4153
4188
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -4175,6 +4210,7 @@ function seq(...rawArgs) {
|
|
|
4175
4210
|
while (currentContext.state.index < parsers.length) {
|
|
4176
4211
|
const index = currentContext.state.index;
|
|
4177
4212
|
const parser = parsers[index];
|
|
4213
|
+
seqScope.select(currentContext, reachableSeqScope(currentContext));
|
|
4178
4214
|
const parserState = getSeqChildState(currentContext.state, index, parser);
|
|
4179
4215
|
if (currentContext.buffer.length < 1) break;
|
|
4180
4216
|
if (shouldAdvanceSeqBeforeParse(parser, parserState, initialState.states[index], currentContext, index, parsers)) {
|
|
@@ -4183,13 +4219,14 @@ function seq(...rawArgs) {
|
|
|
4183
4219
|
currentContext = advanceSeqContext(currentContext, index + 1, consumedTerminator);
|
|
4184
4220
|
continue;
|
|
4185
4221
|
}
|
|
4186
|
-
const result = await parser.parse(withChildContext$1(currentContext, index, parserState, parser));
|
|
4222
|
+
const result = await parser.parse(withChildContext$1(require_short_option.forkOptionScope(currentContext), index, parserState, parser));
|
|
4187
4223
|
if (!result.success) {
|
|
4188
4224
|
if (result.consumed > 0) return withSeqConsumedDepth(result, allConsumed);
|
|
4189
4225
|
if (!parserCanSkipAt(parser, parserState, currentContext.exec, index)) return withSeqConsumedDepth(result, allConsumed);
|
|
4190
4226
|
currentContext = advanceSeqContext(currentContext, index + 1, false);
|
|
4191
4227
|
continue;
|
|
4192
4228
|
}
|
|
4229
|
+
require_short_option.adoptOptionScope(currentContext, result.next);
|
|
4193
4230
|
const states = updateSeqChildState(currentContext.state, index, result.next.state, parser);
|
|
4194
4231
|
const nextIndex = result.consumed.length > 0 ? index : index + 1;
|
|
4195
4232
|
const mergedExec = require_execution_context.mergeChildExec(currentContext.exec, result.next.exec);
|
|
@@ -4443,7 +4480,9 @@ function seq(...rawArgs) {
|
|
|
4443
4480
|
enumerable: false
|
|
4444
4481
|
});
|
|
4445
4482
|
require_internal_parser.defineInheritedAnnotationParser(seqParser);
|
|
4446
|
-
return require_modifiers.fluent(seqParser)
|
|
4483
|
+
return require_modifiers.fluent(require_short_option.scopeParser(seqParser, seqScope.source, (context) => {
|
|
4484
|
+
seqScope.select(context, reachableSeqScope(context));
|
|
4485
|
+
}, true));
|
|
4447
4486
|
}
|
|
4448
4487
|
function merge(...args) {
|
|
4449
4488
|
const label = typeof args[0] === "string" ? args[0] : void 0;
|
|
@@ -5437,7 +5476,7 @@ function merge(...args) {
|
|
|
5437
5476
|
};
|
|
5438
5477
|
require_internal_parser.defineParseLanes(mergeParser, mergeParseLanes);
|
|
5439
5478
|
require_internal_parser.defineInheritedAnnotationParser(mergeParser);
|
|
5440
|
-
return require_modifiers.fluent(mergeParser);
|
|
5479
|
+
return require_modifiers.fluent(require_short_option.scopeParser(mergeParser, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))));
|
|
5441
5480
|
}
|
|
5442
5481
|
/**
|
|
5443
5482
|
* Builds a dependency registry from the pre-parsed context state and returns
|
|
@@ -6064,7 +6103,7 @@ function concat(...parsers) {
|
|
|
6064
6103
|
}
|
|
6065
6104
|
};
|
|
6066
6105
|
require_internal_parser.defineInheritedAnnotationParser(concatParser);
|
|
6067
|
-
return require_modifiers.fluent(concatParser);
|
|
6106
|
+
return require_modifiers.fluent(require_short_option.scopeParser(concatParser, require_short_option.combinedOptionScope(parsers, parsers.map((_, index) => index))));
|
|
6068
6107
|
}
|
|
6069
6108
|
function group(label, parser, options = {}) {
|
|
6070
6109
|
require_validate.validateLabel(label);
|
|
@@ -6174,7 +6213,7 @@ function group(label, parser, options = {}) {
|
|
|
6174
6213
|
configurable: true,
|
|
6175
6214
|
enumerable: false
|
|
6176
6215
|
});
|
|
6177
|
-
return require_modifiers.fluent(groupParser);
|
|
6216
|
+
return require_modifiers.fluent(require_short_option.scopeParser(groupParser, require_short_option.combinedOptionScope([parser])));
|
|
6178
6217
|
}
|
|
6179
6218
|
/**
|
|
6180
6219
|
* Creates a conditional parser that selects different branch parsers based on
|
|
@@ -6283,6 +6322,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6283
6322
|
const noMatchContext = analyzeNoMatchContext([discriminator, ...allBranchParsers]);
|
|
6284
6323
|
return options?.errors?.noMatch ? typeof options.errors.noMatch === "function" ? options.errors.noMatch(noMatchContext) : options.errors.noMatch : generateNoMatchError(noMatchContext);
|
|
6285
6324
|
};
|
|
6325
|
+
const optionScope = require_short_option.conditionalOptionScope(discriminator, defaultBranch, branchParsers.map(([, p]) => p));
|
|
6286
6326
|
const parseSync = (context) => {
|
|
6287
6327
|
const state = context.state ?? initialState;
|
|
6288
6328
|
const syncDiscriminator = discriminator;
|
|
@@ -6319,10 +6359,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6319
6359
|
const value = completionResult.value;
|
|
6320
6360
|
const branchParser = syncBranches[value];
|
|
6321
6361
|
if (branchParser) {
|
|
6362
|
+
const branchContext = require_short_option.forkOptionScope(context);
|
|
6363
|
+
optionScope.select(branchContext, branchParser);
|
|
6322
6364
|
const discriminatorExec = require_execution_context.mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
6323
6365
|
const branchParseResult = branchParser.parse({
|
|
6324
6366
|
...withChildContext$1({
|
|
6325
|
-
...
|
|
6367
|
+
...branchContext,
|
|
6326
6368
|
...discriminatorExec != null ? {
|
|
6327
6369
|
exec: discriminatorExec,
|
|
6328
6370
|
dependencyRegistry: discriminatorExec.dependencyRegistry
|
|
@@ -6332,6 +6374,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6332
6374
|
optionsTerminated: discriminatorResult.next.optionsTerminated
|
|
6333
6375
|
});
|
|
6334
6376
|
if (branchParseResult.success) {
|
|
6377
|
+
if (discriminatorResult.consumed.length > 0 || branchParseResult.consumed.length > 0) require_short_option.adoptOptionScope(context, branchParseResult.next);
|
|
6335
6378
|
const mergedExec = require_execution_context.mergeChildExec(discriminatorExec, branchParseResult.next.exec);
|
|
6336
6379
|
const isProvisional = branchParseResult.provisional || discriminatorResult.consumed.length === 0 && branchParseResult.consumed.length === 0 && (branchParser.leadingNames.size > 0 || branchParser.acceptingAnyToken);
|
|
6337
6380
|
return {
|
|
@@ -6356,26 +6399,29 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6356
6399
|
consumed: [...discriminatorResult.consumed, ...branchParseResult.consumed]
|
|
6357
6400
|
};
|
|
6358
6401
|
}
|
|
6359
|
-
if (discriminatorResult.consumed.length > 0)
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6402
|
+
if (discriminatorResult.consumed.length > 0) {
|
|
6403
|
+
optionScope.select(context, branchParser);
|
|
6404
|
+
return {
|
|
6405
|
+
success: true,
|
|
6406
|
+
next: {
|
|
6407
|
+
...discriminatorResult.next,
|
|
6408
|
+
state: {
|
|
6409
|
+
discriminatorState: annotatedDiscriminatorState,
|
|
6410
|
+
discriminatorValue: value,
|
|
6411
|
+
selectedBranch: {
|
|
6412
|
+
kind: "branch",
|
|
6413
|
+
key: value
|
|
6414
|
+
},
|
|
6415
|
+
branchState: require_annotation_state.getWrappedChildState(state, branchParser.initialState, branchParser)
|
|
6369
6416
|
},
|
|
6370
|
-
|
|
6417
|
+
...discriminatorExec != null ? {
|
|
6418
|
+
exec: discriminatorExec,
|
|
6419
|
+
dependencyRegistry: discriminatorExec.dependencyRegistry
|
|
6420
|
+
} : {}
|
|
6371
6421
|
},
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
} : {}
|
|
6376
|
-
},
|
|
6377
|
-
consumed: discriminatorResult.consumed
|
|
6378
|
-
};
|
|
6422
|
+
consumed: discriminatorResult.consumed
|
|
6423
|
+
};
|
|
6424
|
+
}
|
|
6379
6425
|
return branchParseResult;
|
|
6380
6426
|
}
|
|
6381
6427
|
}
|
|
@@ -6387,10 +6433,13 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6387
6433
|
}
|
|
6388
6434
|
const discriminatorConsumed = discriminatorResult.success ? discriminatorResult.consumed.length : discriminatorResult.consumed;
|
|
6389
6435
|
if (syncDefaultBranch !== void 0) {
|
|
6390
|
-
const
|
|
6436
|
+
const defaultContext = require_short_option.forkOptionScope(context);
|
|
6437
|
+
optionScope.select(defaultContext, syncDefaultBranch);
|
|
6438
|
+
const defaultResult = syncDefaultBranch.parse(withChildContext$1(defaultContext, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch, syncDefaultBranch.usage));
|
|
6391
6439
|
if (defaultResult.success && (defaultResult.consumed.length > 0 || discriminatorConsumed === 0 && context.buffer.length === 0)) {
|
|
6392
6440
|
const mergedExec = require_execution_context.mergeChildExec(context.exec, defaultResult.next.exec);
|
|
6393
6441
|
const commitDefault = defaultResult.consumed.length > 0 || context.buffer.length === 0;
|
|
6442
|
+
if (commitDefault) require_short_option.adoptOptionScope(context, defaultResult.next);
|
|
6394
6443
|
return {
|
|
6395
6444
|
success: true,
|
|
6396
6445
|
...defaultResult.provisional ? { provisional: true } : {},
|
|
@@ -6448,7 +6497,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6448
6497
|
if (discriminatorResult.consumed.length === 0 && discriminator.mode === "async") {
|
|
6449
6498
|
const discriminatorExec = require_execution_context.mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
6450
6499
|
const speculationContext = {
|
|
6451
|
-
...context,
|
|
6500
|
+
...require_short_option.withOptionScope(context, unionLeadingNames([...branchParsers.map(([, p]) => p), ...defaultBranch ? [defaultBranch] : []])),
|
|
6452
6501
|
buffer: discriminatorResult.next.buffer,
|
|
6453
6502
|
optionsTerminated: discriminatorResult.next.optionsTerminated,
|
|
6454
6503
|
...discriminatorExec != null ? {
|
|
@@ -6462,7 +6511,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6462
6511
|
let speculativeError;
|
|
6463
6512
|
let ambiguous = false;
|
|
6464
6513
|
for (const [key, bp] of branchParsers) {
|
|
6465
|
-
const branchResult = await bp.parse(withChildContext$1(speculationContext, "_branch", bp.initialState, bp, bp.usage));
|
|
6514
|
+
const branchResult = await bp.parse(withChildContext$1(require_short_option.forkOptionScope(speculationContext), "_branch", bp.initialState, bp, bp.usage));
|
|
6466
6515
|
if (branchResult.success && branchResult.consumed.length > 0) {
|
|
6467
6516
|
if (branchResult.provisional) {
|
|
6468
6517
|
if (provisionalHit == null && !provisionalAmbiguous) provisionalHit = {
|
|
@@ -6495,11 +6544,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6495
6544
|
if (branchResult.success) {
|
|
6496
6545
|
const annotatedDiscriminatorState$2 = require_annotation_state.getWrappedChildState(state, discriminatorResult.next.state, discriminator);
|
|
6497
6546
|
const mergedExec = require_execution_context.mergeChildExec(discriminatorExec, branchResult.next.exec);
|
|
6547
|
+
optionScope.select(context, bp);
|
|
6498
6548
|
return {
|
|
6499
6549
|
success: true,
|
|
6500
6550
|
provisional: true,
|
|
6501
6551
|
next: {
|
|
6502
|
-
...branchResult.next,
|
|
6552
|
+
...require_short_option.restoreOptionScope(branchResult.next, context),
|
|
6503
6553
|
state: {
|
|
6504
6554
|
...state,
|
|
6505
6555
|
discriminatorState: annotatedDiscriminatorState$2,
|
|
@@ -6521,14 +6571,15 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6521
6571
|
}
|
|
6522
6572
|
let deferredBranchState = state.branchState;
|
|
6523
6573
|
if (defaultBranch !== void 0 && !ambiguous && !provisionalAmbiguous) {
|
|
6524
|
-
const defaultResult = await defaultBranch.parse(withChildContext$1(speculationContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
6574
|
+
const defaultResult = await defaultBranch.parse(withChildContext$1(require_short_option.forkOptionScope(speculationContext), "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
6525
6575
|
if (defaultResult.success && defaultResult.consumed.length > 0) {
|
|
6526
6576
|
const defaultExec = require_execution_context.mergeChildExec(discriminatorExec ?? context.exec, defaultResult.next.exec);
|
|
6577
|
+
optionScope.select(context, defaultBranch);
|
|
6527
6578
|
return {
|
|
6528
6579
|
success: true,
|
|
6529
6580
|
...defaultResult.provisional ? { provisional: true } : {},
|
|
6530
6581
|
next: {
|
|
6531
|
-
...defaultResult.next,
|
|
6582
|
+
...require_short_option.restoreOptionScope(defaultResult.next, context),
|
|
6532
6583
|
state: {
|
|
6533
6584
|
...state,
|
|
6534
6585
|
selectedBranch: { kind: "default" },
|
|
@@ -6551,7 +6602,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6551
6602
|
success: true,
|
|
6552
6603
|
provisional: true,
|
|
6553
6604
|
next: {
|
|
6554
|
-
...speculationContext,
|
|
6605
|
+
...require_short_option.restoreOptionScope(speculationContext, context),
|
|
6555
6606
|
state: {
|
|
6556
6607
|
...state,
|
|
6557
6608
|
discriminatorState: annotatedDiscriminatorState$1,
|
|
@@ -6567,10 +6618,12 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6567
6618
|
const value = completionResult.value;
|
|
6568
6619
|
const branchParser = branches[value];
|
|
6569
6620
|
if (branchParser) {
|
|
6621
|
+
const branchContext = require_short_option.forkOptionScope(context);
|
|
6622
|
+
optionScope.select(branchContext, branchParser);
|
|
6570
6623
|
const discriminatorExec = require_execution_context.mergeChildExec(context.exec, discriminatorResult.next.exec);
|
|
6571
6624
|
const branchParseResult = await branchParser.parse({
|
|
6572
6625
|
...withChildContext$1({
|
|
6573
|
-
...
|
|
6626
|
+
...branchContext,
|
|
6574
6627
|
...discriminatorExec != null ? {
|
|
6575
6628
|
exec: discriminatorExec,
|
|
6576
6629
|
dependencyRegistry: discriminatorExec.dependencyRegistry
|
|
@@ -6580,6 +6633,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6580
6633
|
optionsTerminated: discriminatorResult.next.optionsTerminated
|
|
6581
6634
|
});
|
|
6582
6635
|
if (branchParseResult.success) {
|
|
6636
|
+
if (discriminatorResult.consumed.length > 0 || branchParseResult.consumed.length > 0) require_short_option.adoptOptionScope(context, branchParseResult.next);
|
|
6583
6637
|
const mergedExec = require_execution_context.mergeChildExec(discriminatorExec, branchParseResult.next.exec);
|
|
6584
6638
|
return {
|
|
6585
6639
|
success: true,
|
|
@@ -6603,26 +6657,29 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6603
6657
|
consumed: [...discriminatorResult.consumed, ...branchParseResult.consumed]
|
|
6604
6658
|
};
|
|
6605
6659
|
}
|
|
6606
|
-
if (discriminatorResult.consumed.length > 0)
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6660
|
+
if (discriminatorResult.consumed.length > 0) {
|
|
6661
|
+
optionScope.select(context, branchParser);
|
|
6662
|
+
return {
|
|
6663
|
+
success: true,
|
|
6664
|
+
next: {
|
|
6665
|
+
...discriminatorResult.next,
|
|
6666
|
+
state: {
|
|
6667
|
+
discriminatorState: annotatedDiscriminatorState,
|
|
6668
|
+
discriminatorValue: value,
|
|
6669
|
+
selectedBranch: {
|
|
6670
|
+
kind: "branch",
|
|
6671
|
+
key: value
|
|
6672
|
+
},
|
|
6673
|
+
branchState: require_annotation_state.getWrappedChildState(state, branchParser.initialState, branchParser)
|
|
6616
6674
|
},
|
|
6617
|
-
|
|
6675
|
+
...discriminatorExec != null ? {
|
|
6676
|
+
exec: discriminatorExec,
|
|
6677
|
+
dependencyRegistry: discriminatorExec.dependencyRegistry
|
|
6678
|
+
} : {}
|
|
6618
6679
|
},
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
} : {}
|
|
6623
|
-
},
|
|
6624
|
-
consumed: discriminatorResult.consumed
|
|
6625
|
-
};
|
|
6680
|
+
consumed: discriminatorResult.consumed
|
|
6681
|
+
};
|
|
6682
|
+
}
|
|
6626
6683
|
return branchParseResult;
|
|
6627
6684
|
}
|
|
6628
6685
|
}
|
|
@@ -6634,10 +6691,13 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
6634
6691
|
}
|
|
6635
6692
|
const discriminatorConsumed = discriminatorResult.success ? discriminatorResult.consumed.length : discriminatorResult.consumed;
|
|
6636
6693
|
if (defaultBranch !== void 0) {
|
|
6637
|
-
const
|
|
6694
|
+
const defaultContext = require_short_option.forkOptionScope(context);
|
|
6695
|
+
optionScope.select(defaultContext, defaultBranch);
|
|
6696
|
+
const defaultResult = await defaultBranch.parse(withChildContext$1(defaultContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch, defaultBranch.usage));
|
|
6638
6697
|
if (defaultResult.success && (defaultResult.consumed.length > 0 || discriminatorConsumed === 0 && context.buffer.length === 0)) {
|
|
6639
6698
|
const mergedExec = require_execution_context.mergeChildExec(context.exec, defaultResult.next.exec);
|
|
6640
6699
|
const commitDefault = defaultResult.consumed.length > 0 || context.buffer.length === 0;
|
|
6700
|
+
if (commitDefault) require_short_option.adoptOptionScope(context, defaultResult.next);
|
|
6641
6701
|
return {
|
|
6642
6702
|
success: true,
|
|
6643
6703
|
...defaultResult.provisional ? { provisional: true } : {},
|
|
@@ -7296,8 +7356,14 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
7296
7356
|
} : void 0, "_discriminator"));
|
|
7297
7357
|
if (discComplete.success && syncBranches[discComplete.value] !== void 0) {
|
|
7298
7358
|
const resolvedBranch = syncBranches[discComplete.value];
|
|
7299
|
-
|
|
7300
|
-
|
|
7359
|
+
const branchContext = require_short_option.forkOptionScope(suggestContext);
|
|
7360
|
+
optionScope.select(branchContext, resolvedBranch);
|
|
7361
|
+
yield* resolvedBranch.suggest(withChildContext$1(branchContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
7362
|
+
} else if (syncDefaultBranch !== void 0) {
|
|
7363
|
+
const defaultContext = require_short_option.forkOptionScope(suggestContext);
|
|
7364
|
+
optionScope.select(defaultContext, syncDefaultBranch);
|
|
7365
|
+
yield* syncDefaultBranch.suggest(withChildContext$1(defaultContext, "_branch", state.branchState ?? syncDefaultBranch.initialState, syncDefaultBranch), prefix);
|
|
7366
|
+
}
|
|
7301
7367
|
} else {
|
|
7302
7368
|
const branchParser = state.selectedBranch.kind === "default" ? syncDefaultBranch : syncBranches[state.selectedBranch.key];
|
|
7303
7369
|
const runtime = require_dependency_runtime.createDependencyRuntimeContext(context.dependencyRegistry?.clone());
|
|
@@ -7350,12 +7416,18 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
7350
7416
|
} : void 0, "_discriminator"));
|
|
7351
7417
|
if (discComplete.success && branches[discComplete.value] !== void 0) {
|
|
7352
7418
|
const resolvedBranch = branches[discComplete.value];
|
|
7353
|
-
|
|
7419
|
+
const branchContext = require_short_option.forkOptionScope(suggestContext);
|
|
7420
|
+
optionScope.select(branchContext, resolvedBranch);
|
|
7421
|
+
yield* resolvedBranch.suggest(withChildContext$1(branchContext, "_branch", state.branchState ?? resolvedBranch.initialState, resolvedBranch), prefix);
|
|
7354
7422
|
discResolved = true;
|
|
7355
7423
|
}
|
|
7356
7424
|
}
|
|
7357
7425
|
if (!discResolved) {
|
|
7358
|
-
if (defaultBranch !== void 0)
|
|
7426
|
+
if (defaultBranch !== void 0) {
|
|
7427
|
+
const defaultContext = require_short_option.forkOptionScope(suggestContext);
|
|
7428
|
+
optionScope.select(defaultContext, defaultBranch);
|
|
7429
|
+
yield* defaultBranch.suggest(withChildContext$1(defaultContext, "_branch", state.branchState ?? defaultBranch.initialState, defaultBranch), prefix);
|
|
7430
|
+
}
|
|
7359
7431
|
}
|
|
7360
7432
|
} else {
|
|
7361
7433
|
const branchParser = state.selectedBranch.kind === "default" ? defaultBranch : branches[state.selectedBranch.key];
|
|
@@ -7501,7 +7573,13 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
7501
7573
|
configurable: true,
|
|
7502
7574
|
enumerable: false
|
|
7503
7575
|
});
|
|
7504
|
-
return require_modifiers.fluent(conditionalParser)
|
|
7576
|
+
return require_modifiers.fluent(require_short_option.scopeParser(conditionalParser, optionScope.source, (context) => {
|
|
7577
|
+
const selected = context.state?.selectedBranch;
|
|
7578
|
+
if (selected != null) {
|
|
7579
|
+
const branch = selected.kind === "default" ? defaultBranch : branches[selected.key];
|
|
7580
|
+
if (branch != null) optionScope.select(context, branch);
|
|
7581
|
+
}
|
|
7582
|
+
}));
|
|
7505
7583
|
}
|
|
7506
7584
|
|
|
7507
7585
|
//#endregion
|