@optique/core 1.1.10 → 1.1.12
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 +49 -23
- package/dist/constructs.js +49 -23
- package/dist/internal/command-doc-metadata.cjs +90 -0
- package/dist/internal/command-doc-metadata.js +87 -0
- package/dist/modifiers.cjs +3 -2
- package/dist/modifiers.js +3 -2
- package/dist/primitives.cjs +33 -26
- package/dist/primitives.js +33 -26
- package/package.json +2 -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_command_doc_metadata = require('./internal/command-doc-metadata.cjs');
|
|
11
12
|
const require_passthrough = require('./internal/passthrough.cjs');
|
|
12
13
|
const require_command_alias = require('./internal/command-alias.cjs');
|
|
13
14
|
const require_execution_context = require('./execution-context.cjs');
|
|
@@ -1350,6 +1351,7 @@ function or(...args) {
|
|
|
1350
1351
|
},
|
|
1351
1352
|
suggest: createExclusiveSuggest(parsers, combinedMode),
|
|
1352
1353
|
getDocFragments(state, _defaultValue) {
|
|
1354
|
+
let commandMetadata;
|
|
1353
1355
|
let brief;
|
|
1354
1356
|
let description;
|
|
1355
1357
|
let footer;
|
|
@@ -1362,18 +1364,19 @@ function or(...args) {
|
|
|
1362
1364
|
state: parserResult.next.state
|
|
1363
1365
|
} : { kind: "unavailable" };
|
|
1364
1366
|
const docFragments = parsers[index].getDocFragments(innerState, void 0);
|
|
1367
|
+
commandMetadata = require_command_doc_metadata.getCommandDocMetadata(docFragments);
|
|
1365
1368
|
brief = docFragments.brief;
|
|
1366
1369
|
description = docFragments.description;
|
|
1367
1370
|
footer = docFragments.footer;
|
|
1368
1371
|
fragments = docFragments.fragments;
|
|
1369
1372
|
}
|
|
1370
1373
|
if (state.kind === "unavailable" || state.state == null) fragments = require_doc.deduplicateDocFragments(fragments);
|
|
1371
|
-
return {
|
|
1374
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1372
1375
|
brief,
|
|
1373
1376
|
description,
|
|
1374
1377
|
footer,
|
|
1375
1378
|
fragments
|
|
1376
|
-
};
|
|
1379
|
+
}, commandMetadata);
|
|
1377
1380
|
}
|
|
1378
1381
|
};
|
|
1379
1382
|
const singleDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
@@ -1581,6 +1584,7 @@ function createLongestMatch(...args) {
|
|
|
1581
1584
|
},
|
|
1582
1585
|
suggest: createExclusiveSuggest(parsers, combinedMode),
|
|
1583
1586
|
getDocFragments(state, _defaultValue) {
|
|
1587
|
+
let commandMetadata;
|
|
1584
1588
|
let brief;
|
|
1585
1589
|
let description;
|
|
1586
1590
|
let footer;
|
|
@@ -1596,6 +1600,7 @@ function createLongestMatch(...args) {
|
|
|
1596
1600
|
kind: "available",
|
|
1597
1601
|
state: result.next.state
|
|
1598
1602
|
});
|
|
1603
|
+
commandMetadata = require_command_doc_metadata.getCommandDocMetadata(docResult);
|
|
1599
1604
|
brief = docResult.brief;
|
|
1600
1605
|
description = docResult.description;
|
|
1601
1606
|
footer = docResult.footer;
|
|
@@ -1606,12 +1611,12 @@ function createLongestMatch(...args) {
|
|
|
1606
1611
|
shouldDeduplicate = true;
|
|
1607
1612
|
}
|
|
1608
1613
|
}
|
|
1609
|
-
return {
|
|
1614
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1610
1615
|
brief,
|
|
1611
1616
|
description,
|
|
1612
1617
|
fragments: shouldDeduplicate ? require_doc.deduplicateDocFragments(fragments) : fragments,
|
|
1613
1618
|
footer
|
|
1614
|
-
};
|
|
1619
|
+
}, commandMetadata);
|
|
1615
1620
|
}
|
|
1616
1621
|
};
|
|
1617
1622
|
const multiDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
@@ -2583,12 +2588,15 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2583
2588
|
}, () => suggestObjectAsync(context, prefix, parserPairs));
|
|
2584
2589
|
},
|
|
2585
2590
|
getDocFragments(state, defaultValue) {
|
|
2591
|
+
let commandMetadata;
|
|
2586
2592
|
const fragments = parserPairs.flatMap(([field, p]) => {
|
|
2587
2593
|
const fieldState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
2588
2594
|
kind: "available",
|
|
2589
2595
|
state: state.state[field]
|
|
2590
2596
|
};
|
|
2591
|
-
|
|
2597
|
+
const docs = p.getDocFragments(fieldState, defaultValue?.[field]);
|
|
2598
|
+
commandMetadata = require_command_doc_metadata.collectCommandDocMetadata(commandMetadata, docs);
|
|
2599
|
+
return docs.fragments;
|
|
2592
2600
|
});
|
|
2593
2601
|
const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
|
|
2594
2602
|
const entries = hiddenAwareFragments.filter((d) => d.type === "entry");
|
|
@@ -2603,10 +2611,13 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2603
2611
|
entries
|
|
2604
2612
|
};
|
|
2605
2613
|
sections.push(section);
|
|
2606
|
-
return
|
|
2607
|
-
...
|
|
2608
|
-
|
|
2609
|
-
|
|
2614
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
2615
|
+
...commandMetadata,
|
|
2616
|
+
fragments: sections.map((s) => ({
|
|
2617
|
+
...s,
|
|
2618
|
+
type: "section"
|
|
2619
|
+
}))
|
|
2620
|
+
}, commandMetadata);
|
|
2610
2621
|
}
|
|
2611
2622
|
};
|
|
2612
2623
|
const fieldNormalizers = [];
|
|
@@ -3599,12 +3610,15 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3599
3610
|
return require_mode_dispatch.dispatchIterableByMode(combinedMode, () => suggestTupleSync(context, prefix, syncParsers), () => suggestTupleAsync(context, prefix, parsers));
|
|
3600
3611
|
},
|
|
3601
3612
|
getDocFragments(state, defaultValue) {
|
|
3613
|
+
let commandMetadata;
|
|
3602
3614
|
const fragments = syncParsers.flatMap((p, i) => {
|
|
3603
3615
|
const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
3604
3616
|
kind: "available",
|
|
3605
3617
|
state: state.state[i]
|
|
3606
3618
|
};
|
|
3607
|
-
|
|
3619
|
+
const docs = p.getDocFragments(indexState, defaultValue?.[i]);
|
|
3620
|
+
commandMetadata = require_command_doc_metadata.collectCommandDocMetadata(commandMetadata, docs);
|
|
3621
|
+
return docs.fragments;
|
|
3608
3622
|
});
|
|
3609
3623
|
const entries = fragments.filter((d) => d.type === "entry");
|
|
3610
3624
|
const sections = [];
|
|
@@ -3618,10 +3632,13 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3618
3632
|
entries
|
|
3619
3633
|
};
|
|
3620
3634
|
sections.push(section);
|
|
3621
|
-
return
|
|
3622
|
-
...
|
|
3623
|
-
|
|
3624
|
-
|
|
3635
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
3636
|
+
...commandMetadata,
|
|
3637
|
+
fragments: sections.map((s) => ({
|
|
3638
|
+
...s,
|
|
3639
|
+
type: "section"
|
|
3640
|
+
}))
|
|
3641
|
+
}, commandMetadata);
|
|
3625
3642
|
},
|
|
3626
3643
|
[Symbol.for("Deno.customInspect")]() {
|
|
3627
3644
|
const parsersStr = parsers.length === 1 ? `[1 parser]` : `[${parsers.length} parsers]`;
|
|
@@ -4847,6 +4864,7 @@ function merge(...args) {
|
|
|
4847
4864
|
}();
|
|
4848
4865
|
},
|
|
4849
4866
|
getDocFragments(state, _defaultValue) {
|
|
4867
|
+
let commandMetadata;
|
|
4850
4868
|
let brief;
|
|
4851
4869
|
let description;
|
|
4852
4870
|
let footer;
|
|
@@ -4864,6 +4882,7 @@ function merge(...args) {
|
|
|
4864
4882
|
state: state.state
|
|
4865
4883
|
};
|
|
4866
4884
|
const docFragments = p.getDocFragments(parserState, void 0);
|
|
4885
|
+
commandMetadata = require_command_doc_metadata.collectCommandDocMetadata(commandMetadata, docFragments, true);
|
|
4867
4886
|
brief ??= docFragments.brief;
|
|
4868
4887
|
description ??= docFragments.description;
|
|
4869
4888
|
footer ??= docFragments.footer;
|
|
@@ -4883,7 +4902,7 @@ function merge(...args) {
|
|
|
4883
4902
|
entries
|
|
4884
4903
|
};
|
|
4885
4904
|
sections.push(labeledSection);
|
|
4886
|
-
return {
|
|
4905
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
4887
4906
|
brief,
|
|
4888
4907
|
description,
|
|
4889
4908
|
footer,
|
|
@@ -4891,9 +4910,9 @@ function merge(...args) {
|
|
|
4891
4910
|
...s,
|
|
4892
4911
|
type: "section"
|
|
4893
4912
|
}))
|
|
4894
|
-
};
|
|
4913
|
+
}, commandMetadata);
|
|
4895
4914
|
}
|
|
4896
|
-
return {
|
|
4915
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
4897
4916
|
brief,
|
|
4898
4917
|
description,
|
|
4899
4918
|
footer,
|
|
@@ -4904,7 +4923,7 @@ function merge(...args) {
|
|
|
4904
4923
|
type: "section",
|
|
4905
4924
|
entries
|
|
4906
4925
|
}]
|
|
4907
|
-
};
|
|
4926
|
+
}, commandMetadata);
|
|
4908
4927
|
}
|
|
4909
4928
|
};
|
|
4910
4929
|
require_internal_parser.defineParseLanes(mergeParser, mergeParseLanes);
|
|
@@ -5520,12 +5539,15 @@ function concat(...parsers) {
|
|
|
5520
5539
|
}();
|
|
5521
5540
|
},
|
|
5522
5541
|
getDocFragments(state, _defaultValue) {
|
|
5542
|
+
let commandMetadata;
|
|
5523
5543
|
const fragments = syncParsers.flatMap((p, index) => {
|
|
5524
5544
|
const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
5525
5545
|
kind: "available",
|
|
5526
5546
|
state: state.state[index]
|
|
5527
5547
|
};
|
|
5528
|
-
|
|
5548
|
+
const docs = p.getDocFragments(indexState, void 0);
|
|
5549
|
+
commandMetadata = require_command_doc_metadata.collectCommandDocMetadata(commandMetadata, docs);
|
|
5550
|
+
return docs.fragments;
|
|
5529
5551
|
});
|
|
5530
5552
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
5531
5553
|
const sections = [];
|
|
@@ -5542,7 +5564,10 @@ function concat(...parsers) {
|
|
|
5542
5564
|
type: "section",
|
|
5543
5565
|
entries
|
|
5544
5566
|
});
|
|
5545
|
-
return {
|
|
5567
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
5568
|
+
...commandMetadata,
|
|
5569
|
+
fragments: result
|
|
5570
|
+
}, commandMetadata);
|
|
5546
5571
|
}
|
|
5547
5572
|
};
|
|
5548
5573
|
require_internal_parser.defineInheritedAnnotationParser(concatParser);
|
|
@@ -5578,7 +5603,8 @@ function group(label, parser, options = {}) {
|
|
|
5578
5603
|
return parser.suggest(context, prefix);
|
|
5579
5604
|
},
|
|
5580
5605
|
getDocFragments: (state, defaultValue) => {
|
|
5581
|
-
const
|
|
5606
|
+
const docs = parser.getDocFragments(state, defaultValue);
|
|
5607
|
+
const { brief, description, footer, fragments } = docs;
|
|
5582
5608
|
const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
|
|
5583
5609
|
const allEntries = [];
|
|
5584
5610
|
const titledSections = [];
|
|
@@ -5601,7 +5627,7 @@ function group(label, parser, options = {}) {
|
|
|
5601
5627
|
title: label,
|
|
5602
5628
|
entries: allEntries
|
|
5603
5629
|
} : { entries: allEntries };
|
|
5604
|
-
return {
|
|
5630
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
5605
5631
|
brief,
|
|
5606
5632
|
description,
|
|
5607
5633
|
footer,
|
|
@@ -5612,7 +5638,7 @@ function group(label, parser, options = {}) {
|
|
|
5612
5638
|
type: "section",
|
|
5613
5639
|
...labeledSection
|
|
5614
5640
|
}]
|
|
5615
|
-
};
|
|
5641
|
+
}, require_command_doc_metadata.getCommandDocMetadata(docs));
|
|
5616
5642
|
}
|
|
5617
5643
|
};
|
|
5618
5644
|
require_internal_parser.defineParseLanes(groupParser, require_internal_parser.getOwnParseLanes(parser));
|
package/dist/constructs.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createDependencySourceState, dependencyId, isDependencySourceState, isP
|
|
|
8
8
|
import { buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, createDependencyRuntimeContext, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync } 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 { collectCommandDocMetadata, getCommandDocMetadata, withCommandDocMetadata } from "./internal/command-doc-metadata.js";
|
|
11
12
|
import { combineOptionMatches, combinePassThroughPriorities, defineOptionMatch, definePassThroughPriority, delegateKnownCompletion, getKnownCompletion, getOptionMatch, getPassThroughFailureHint, getPassThroughPriority, hasPassThroughUsage, matchesOptionToken, retainConsumingFailure, retainConsumingFailureHint, withPassThroughFailure } from "./internal/passthrough.js";
|
|
12
13
|
import { allowDuplicateLeadingCommandNamesKey } from "./internal/command-alias.js";
|
|
13
14
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
@@ -1350,6 +1351,7 @@ function or(...args) {
|
|
|
1350
1351
|
},
|
|
1351
1352
|
suggest: createExclusiveSuggest(parsers, combinedMode),
|
|
1352
1353
|
getDocFragments(state, _defaultValue) {
|
|
1354
|
+
let commandMetadata;
|
|
1353
1355
|
let brief;
|
|
1354
1356
|
let description;
|
|
1355
1357
|
let footer;
|
|
@@ -1362,18 +1364,19 @@ function or(...args) {
|
|
|
1362
1364
|
state: parserResult.next.state
|
|
1363
1365
|
} : { kind: "unavailable" };
|
|
1364
1366
|
const docFragments = parsers[index].getDocFragments(innerState, void 0);
|
|
1367
|
+
commandMetadata = getCommandDocMetadata(docFragments);
|
|
1365
1368
|
brief = docFragments.brief;
|
|
1366
1369
|
description = docFragments.description;
|
|
1367
1370
|
footer = docFragments.footer;
|
|
1368
1371
|
fragments = docFragments.fragments;
|
|
1369
1372
|
}
|
|
1370
1373
|
if (state.kind === "unavailable" || state.state == null) fragments = deduplicateDocFragments(fragments);
|
|
1371
|
-
return {
|
|
1374
|
+
return withCommandDocMetadata({
|
|
1372
1375
|
brief,
|
|
1373
1376
|
description,
|
|
1374
1377
|
footer,
|
|
1375
1378
|
fragments
|
|
1376
|
-
};
|
|
1379
|
+
}, commandMetadata);
|
|
1377
1380
|
}
|
|
1378
1381
|
};
|
|
1379
1382
|
const singleDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
@@ -1581,6 +1584,7 @@ function createLongestMatch(...args) {
|
|
|
1581
1584
|
},
|
|
1582
1585
|
suggest: createExclusiveSuggest(parsers, combinedMode),
|
|
1583
1586
|
getDocFragments(state, _defaultValue) {
|
|
1587
|
+
let commandMetadata;
|
|
1584
1588
|
let brief;
|
|
1585
1589
|
let description;
|
|
1586
1590
|
let footer;
|
|
@@ -1596,6 +1600,7 @@ function createLongestMatch(...args) {
|
|
|
1596
1600
|
kind: "available",
|
|
1597
1601
|
state: result.next.state
|
|
1598
1602
|
});
|
|
1603
|
+
commandMetadata = getCommandDocMetadata(docResult);
|
|
1599
1604
|
brief = docResult.brief;
|
|
1600
1605
|
description = docResult.description;
|
|
1601
1606
|
footer = docResult.footer;
|
|
@@ -1606,12 +1611,12 @@ function createLongestMatch(...args) {
|
|
|
1606
1611
|
shouldDeduplicate = true;
|
|
1607
1612
|
}
|
|
1608
1613
|
}
|
|
1609
|
-
return {
|
|
1614
|
+
return withCommandDocMetadata({
|
|
1610
1615
|
brief,
|
|
1611
1616
|
description,
|
|
1612
1617
|
fragments: shouldDeduplicate ? deduplicateDocFragments(fragments) : fragments,
|
|
1613
1618
|
footer
|
|
1614
|
-
};
|
|
1619
|
+
}, commandMetadata);
|
|
1615
1620
|
}
|
|
1616
1621
|
};
|
|
1617
1622
|
const multiDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
@@ -2583,12 +2588,15 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2583
2588
|
}, () => suggestObjectAsync(context, prefix, parserPairs));
|
|
2584
2589
|
},
|
|
2585
2590
|
getDocFragments(state, defaultValue) {
|
|
2591
|
+
let commandMetadata;
|
|
2586
2592
|
const fragments = parserPairs.flatMap(([field, p]) => {
|
|
2587
2593
|
const fieldState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
2588
2594
|
kind: "available",
|
|
2589
2595
|
state: state.state[field]
|
|
2590
2596
|
};
|
|
2591
|
-
|
|
2597
|
+
const docs = p.getDocFragments(fieldState, defaultValue?.[field]);
|
|
2598
|
+
commandMetadata = collectCommandDocMetadata(commandMetadata, docs);
|
|
2599
|
+
return docs.fragments;
|
|
2592
2600
|
});
|
|
2593
2601
|
const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
|
|
2594
2602
|
const entries = hiddenAwareFragments.filter((d) => d.type === "entry");
|
|
@@ -2603,10 +2611,13 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
2603
2611
|
entries
|
|
2604
2612
|
};
|
|
2605
2613
|
sections.push(section);
|
|
2606
|
-
return
|
|
2607
|
-
...
|
|
2608
|
-
|
|
2609
|
-
|
|
2614
|
+
return withCommandDocMetadata({
|
|
2615
|
+
...commandMetadata,
|
|
2616
|
+
fragments: sections.map((s) => ({
|
|
2617
|
+
...s,
|
|
2618
|
+
type: "section"
|
|
2619
|
+
}))
|
|
2620
|
+
}, commandMetadata);
|
|
2610
2621
|
}
|
|
2611
2622
|
};
|
|
2612
2623
|
const fieldNormalizers = [];
|
|
@@ -3599,12 +3610,15 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3599
3610
|
return dispatchIterableByMode(combinedMode, () => suggestTupleSync(context, prefix, syncParsers), () => suggestTupleAsync(context, prefix, parsers));
|
|
3600
3611
|
},
|
|
3601
3612
|
getDocFragments(state, defaultValue) {
|
|
3613
|
+
let commandMetadata;
|
|
3602
3614
|
const fragments = syncParsers.flatMap((p, i) => {
|
|
3603
3615
|
const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
3604
3616
|
kind: "available",
|
|
3605
3617
|
state: state.state[i]
|
|
3606
3618
|
};
|
|
3607
|
-
|
|
3619
|
+
const docs = p.getDocFragments(indexState, defaultValue?.[i]);
|
|
3620
|
+
commandMetadata = collectCommandDocMetadata(commandMetadata, docs);
|
|
3621
|
+
return docs.fragments;
|
|
3608
3622
|
});
|
|
3609
3623
|
const entries = fragments.filter((d) => d.type === "entry");
|
|
3610
3624
|
const sections = [];
|
|
@@ -3618,10 +3632,13 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3618
3632
|
entries
|
|
3619
3633
|
};
|
|
3620
3634
|
sections.push(section);
|
|
3621
|
-
return
|
|
3622
|
-
...
|
|
3623
|
-
|
|
3624
|
-
|
|
3635
|
+
return withCommandDocMetadata({
|
|
3636
|
+
...commandMetadata,
|
|
3637
|
+
fragments: sections.map((s) => ({
|
|
3638
|
+
...s,
|
|
3639
|
+
type: "section"
|
|
3640
|
+
}))
|
|
3641
|
+
}, commandMetadata);
|
|
3625
3642
|
},
|
|
3626
3643
|
[Symbol.for("Deno.customInspect")]() {
|
|
3627
3644
|
const parsersStr = parsers.length === 1 ? `[1 parser]` : `[${parsers.length} parsers]`;
|
|
@@ -4847,6 +4864,7 @@ function merge(...args) {
|
|
|
4847
4864
|
}();
|
|
4848
4865
|
},
|
|
4849
4866
|
getDocFragments(state, _defaultValue) {
|
|
4867
|
+
let commandMetadata;
|
|
4850
4868
|
let brief;
|
|
4851
4869
|
let description;
|
|
4852
4870
|
let footer;
|
|
@@ -4864,6 +4882,7 @@ function merge(...args) {
|
|
|
4864
4882
|
state: state.state
|
|
4865
4883
|
};
|
|
4866
4884
|
const docFragments = p.getDocFragments(parserState, void 0);
|
|
4885
|
+
commandMetadata = collectCommandDocMetadata(commandMetadata, docFragments, true);
|
|
4867
4886
|
brief ??= docFragments.brief;
|
|
4868
4887
|
description ??= docFragments.description;
|
|
4869
4888
|
footer ??= docFragments.footer;
|
|
@@ -4883,7 +4902,7 @@ function merge(...args) {
|
|
|
4883
4902
|
entries
|
|
4884
4903
|
};
|
|
4885
4904
|
sections.push(labeledSection);
|
|
4886
|
-
return {
|
|
4905
|
+
return withCommandDocMetadata({
|
|
4887
4906
|
brief,
|
|
4888
4907
|
description,
|
|
4889
4908
|
footer,
|
|
@@ -4891,9 +4910,9 @@ function merge(...args) {
|
|
|
4891
4910
|
...s,
|
|
4892
4911
|
type: "section"
|
|
4893
4912
|
}))
|
|
4894
|
-
};
|
|
4913
|
+
}, commandMetadata);
|
|
4895
4914
|
}
|
|
4896
|
-
return {
|
|
4915
|
+
return withCommandDocMetadata({
|
|
4897
4916
|
brief,
|
|
4898
4917
|
description,
|
|
4899
4918
|
footer,
|
|
@@ -4904,7 +4923,7 @@ function merge(...args) {
|
|
|
4904
4923
|
type: "section",
|
|
4905
4924
|
entries
|
|
4906
4925
|
}]
|
|
4907
|
-
};
|
|
4926
|
+
}, commandMetadata);
|
|
4908
4927
|
}
|
|
4909
4928
|
};
|
|
4910
4929
|
defineParseLanes(mergeParser, mergeParseLanes);
|
|
@@ -5520,12 +5539,15 @@ function concat(...parsers) {
|
|
|
5520
5539
|
}();
|
|
5521
5540
|
},
|
|
5522
5541
|
getDocFragments(state, _defaultValue) {
|
|
5542
|
+
let commandMetadata;
|
|
5523
5543
|
const fragments = syncParsers.flatMap((p, index) => {
|
|
5524
5544
|
const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
5525
5545
|
kind: "available",
|
|
5526
5546
|
state: state.state[index]
|
|
5527
5547
|
};
|
|
5528
|
-
|
|
5548
|
+
const docs = p.getDocFragments(indexState, void 0);
|
|
5549
|
+
commandMetadata = collectCommandDocMetadata(commandMetadata, docs);
|
|
5550
|
+
return docs.fragments;
|
|
5529
5551
|
});
|
|
5530
5552
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
5531
5553
|
const sections = [];
|
|
@@ -5542,7 +5564,10 @@ function concat(...parsers) {
|
|
|
5542
5564
|
type: "section",
|
|
5543
5565
|
entries
|
|
5544
5566
|
});
|
|
5545
|
-
return {
|
|
5567
|
+
return withCommandDocMetadata({
|
|
5568
|
+
...commandMetadata,
|
|
5569
|
+
fragments: result
|
|
5570
|
+
}, commandMetadata);
|
|
5546
5571
|
}
|
|
5547
5572
|
};
|
|
5548
5573
|
defineInheritedAnnotationParser(concatParser);
|
|
@@ -5578,7 +5603,8 @@ function group(label, parser, options = {}) {
|
|
|
5578
5603
|
return parser.suggest(context, prefix);
|
|
5579
5604
|
},
|
|
5580
5605
|
getDocFragments: (state, defaultValue) => {
|
|
5581
|
-
const
|
|
5606
|
+
const docs = parser.getDocFragments(state, defaultValue);
|
|
5607
|
+
const { brief, description, footer, fragments } = docs;
|
|
5582
5608
|
const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
|
|
5583
5609
|
const allEntries = [];
|
|
5584
5610
|
const titledSections = [];
|
|
@@ -5601,7 +5627,7 @@ function group(label, parser, options = {}) {
|
|
|
5601
5627
|
title: label,
|
|
5602
5628
|
entries: allEntries
|
|
5603
5629
|
} : { entries: allEntries };
|
|
5604
|
-
return {
|
|
5630
|
+
return withCommandDocMetadata({
|
|
5605
5631
|
brief,
|
|
5606
5632
|
description,
|
|
5607
5633
|
footer,
|
|
@@ -5612,7 +5638,7 @@ function group(label, parser, options = {}) {
|
|
|
5612
5638
|
type: "section",
|
|
5613
5639
|
...labeledSection
|
|
5614
5640
|
}]
|
|
5615
|
-
};
|
|
5641
|
+
}, getCommandDocMetadata(docs));
|
|
5616
5642
|
}
|
|
5617
5643
|
};
|
|
5618
5644
|
defineParseLanes(groupParser, getOwnParseLanes(parser));
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/internal/command-doc-metadata.ts
|
|
3
|
+
function withOrigin(metadata, origin) {
|
|
4
|
+
const result = { ...metadata };
|
|
5
|
+
Object.defineProperty(result, "origin", {
|
|
6
|
+
value: origin,
|
|
7
|
+
enumerable: false
|
|
8
|
+
});
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
const commandDocMetadata = Symbol.for("@optique/core/commandDocMetadata");
|
|
12
|
+
const commandDocCarrier = Symbol.for("@optique/core/commandDocMetadataCarrier");
|
|
13
|
+
/**
|
|
14
|
+
* Reads effective page metadata, including custom collection-level fields.
|
|
15
|
+
* @param docs The child's documentation.
|
|
16
|
+
* @returns Its selected-command metadata, if any.
|
|
17
|
+
*/
|
|
18
|
+
function getCommandDocMetadata(docs) {
|
|
19
|
+
const carrier = docs.fragments[commandDocCarrier];
|
|
20
|
+
if (carrier != null) {
|
|
21
|
+
const brief = docs.brief === carrier.brief ? carrier.metadata.brief : docs.brief;
|
|
22
|
+
const origin = carrier.metadata.origin ?? "entry";
|
|
23
|
+
const customPage = origin === "entry" && (docs.brief !== carrier.brief || docs.footer !== carrier.footer);
|
|
24
|
+
const description = origin === "entry" && !customPage || docs.description === carrier.description ? carrier.metadata.description : docs.description;
|
|
25
|
+
const footer = docs.footer === carrier.footer ? carrier.metadata.footer : docs.footer;
|
|
26
|
+
return withOrigin({
|
|
27
|
+
...brief == null ? {} : { brief },
|
|
28
|
+
...description == null ? {} : { description },
|
|
29
|
+
...footer == null ? {} : { footer }
|
|
30
|
+
}, customPage ? "custom" : origin);
|
|
31
|
+
}
|
|
32
|
+
const metadata = docs[commandDocMetadata];
|
|
33
|
+
if (metadata != null) return metadata;
|
|
34
|
+
return docs.brief != null || docs.description != null || docs.footer != null ? withOrigin({
|
|
35
|
+
brief: docs.brief,
|
|
36
|
+
description: docs.description,
|
|
37
|
+
footer: docs.footer
|
|
38
|
+
}, "custom") : void 0;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Preserves selected-command metadata when rebuilding documentation fragments.
|
|
42
|
+
* @param docs The rebuilt documentation.
|
|
43
|
+
* @param metadata The selected-command metadata to preserve.
|
|
44
|
+
* @returns Documentation with the internal metadata attached.
|
|
45
|
+
*/
|
|
46
|
+
function withCommandDocMetadata(docs, metadata) {
|
|
47
|
+
if (metadata == null) return docs;
|
|
48
|
+
metadata = withOrigin(metadata, metadata.origin ?? "entry");
|
|
49
|
+
const fragments = [...docs.fragments];
|
|
50
|
+
Object.defineProperty(fragments, commandDocCarrier, { value: {
|
|
51
|
+
metadata,
|
|
52
|
+
brief: docs.brief,
|
|
53
|
+
description: docs.description,
|
|
54
|
+
footer: docs.footer
|
|
55
|
+
} });
|
|
56
|
+
const result = {
|
|
57
|
+
...docs,
|
|
58
|
+
fragments
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(result, commandDocMetadata, { value: metadata });
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Collects selected-command metadata in documentation traversal order.
|
|
65
|
+
* @param current Metadata from earlier children.
|
|
66
|
+
* @param docs The next child's documentation.
|
|
67
|
+
* @param includeCustom Whether to retain custom page fields inside merge().
|
|
68
|
+
* @returns The first defined value from children with the same origin.
|
|
69
|
+
*/
|
|
70
|
+
function collectCommandDocMetadata(current, docs, includeCustom = false) {
|
|
71
|
+
const next = getCommandDocMetadata(docs);
|
|
72
|
+
if (next == null) return current;
|
|
73
|
+
const origin = next.origin ?? "entry";
|
|
74
|
+
if (origin === "entry" || origin === "custom" && !includeCustom) return current ?? withOrigin({}, "entry");
|
|
75
|
+
if (current?.origin === "command" && origin !== "command") return current;
|
|
76
|
+
if (current?.origin !== origin) current = void 0;
|
|
77
|
+
const brief = current?.brief ?? next.brief;
|
|
78
|
+
const description = current?.description ?? next.description;
|
|
79
|
+
const footer = current?.footer ?? next.footer;
|
|
80
|
+
return withOrigin({
|
|
81
|
+
...brief == null ? {} : { brief },
|
|
82
|
+
...description == null ? {} : { description },
|
|
83
|
+
...footer == null ? {} : { footer }
|
|
84
|
+
}, origin);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.collectCommandDocMetadata = collectCommandDocMetadata;
|
|
89
|
+
exports.getCommandDocMetadata = getCommandDocMetadata;
|
|
90
|
+
exports.withCommandDocMetadata = withCommandDocMetadata;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region src/internal/command-doc-metadata.ts
|
|
2
|
+
function withOrigin(metadata, origin) {
|
|
3
|
+
const result = { ...metadata };
|
|
4
|
+
Object.defineProperty(result, "origin", {
|
|
5
|
+
value: origin,
|
|
6
|
+
enumerable: false
|
|
7
|
+
});
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
const commandDocMetadata = Symbol.for("@optique/core/commandDocMetadata");
|
|
11
|
+
const commandDocCarrier = Symbol.for("@optique/core/commandDocMetadataCarrier");
|
|
12
|
+
/**
|
|
13
|
+
* Reads effective page metadata, including custom collection-level fields.
|
|
14
|
+
* @param docs The child's documentation.
|
|
15
|
+
* @returns Its selected-command metadata, if any.
|
|
16
|
+
*/
|
|
17
|
+
function getCommandDocMetadata(docs) {
|
|
18
|
+
const carrier = docs.fragments[commandDocCarrier];
|
|
19
|
+
if (carrier != null) {
|
|
20
|
+
const brief = docs.brief === carrier.brief ? carrier.metadata.brief : docs.brief;
|
|
21
|
+
const origin = carrier.metadata.origin ?? "entry";
|
|
22
|
+
const customPage = origin === "entry" && (docs.brief !== carrier.brief || docs.footer !== carrier.footer);
|
|
23
|
+
const description = origin === "entry" && !customPage || docs.description === carrier.description ? carrier.metadata.description : docs.description;
|
|
24
|
+
const footer = docs.footer === carrier.footer ? carrier.metadata.footer : docs.footer;
|
|
25
|
+
return withOrigin({
|
|
26
|
+
...brief == null ? {} : { brief },
|
|
27
|
+
...description == null ? {} : { description },
|
|
28
|
+
...footer == null ? {} : { footer }
|
|
29
|
+
}, customPage ? "custom" : origin);
|
|
30
|
+
}
|
|
31
|
+
const metadata = docs[commandDocMetadata];
|
|
32
|
+
if (metadata != null) return metadata;
|
|
33
|
+
return docs.brief != null || docs.description != null || docs.footer != null ? withOrigin({
|
|
34
|
+
brief: docs.brief,
|
|
35
|
+
description: docs.description,
|
|
36
|
+
footer: docs.footer
|
|
37
|
+
}, "custom") : void 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Preserves selected-command metadata when rebuilding documentation fragments.
|
|
41
|
+
* @param docs The rebuilt documentation.
|
|
42
|
+
* @param metadata The selected-command metadata to preserve.
|
|
43
|
+
* @returns Documentation with the internal metadata attached.
|
|
44
|
+
*/
|
|
45
|
+
function withCommandDocMetadata(docs, metadata) {
|
|
46
|
+
if (metadata == null) return docs;
|
|
47
|
+
metadata = withOrigin(metadata, metadata.origin ?? "entry");
|
|
48
|
+
const fragments = [...docs.fragments];
|
|
49
|
+
Object.defineProperty(fragments, commandDocCarrier, { value: {
|
|
50
|
+
metadata,
|
|
51
|
+
brief: docs.brief,
|
|
52
|
+
description: docs.description,
|
|
53
|
+
footer: docs.footer
|
|
54
|
+
} });
|
|
55
|
+
const result = {
|
|
56
|
+
...docs,
|
|
57
|
+
fragments
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(result, commandDocMetadata, { value: metadata });
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Collects selected-command metadata in documentation traversal order.
|
|
64
|
+
* @param current Metadata from earlier children.
|
|
65
|
+
* @param docs The next child's documentation.
|
|
66
|
+
* @param includeCustom Whether to retain custom page fields inside merge().
|
|
67
|
+
* @returns The first defined value from children with the same origin.
|
|
68
|
+
*/
|
|
69
|
+
function collectCommandDocMetadata(current, docs, includeCustom = false) {
|
|
70
|
+
const next = getCommandDocMetadata(docs);
|
|
71
|
+
if (next == null) return current;
|
|
72
|
+
const origin = next.origin ?? "entry";
|
|
73
|
+
if (origin === "entry" || origin === "custom" && !includeCustom) return current ?? withOrigin({}, "entry");
|
|
74
|
+
if (current?.origin === "command" && origin !== "command") return current;
|
|
75
|
+
if (current?.origin !== origin) current = void 0;
|
|
76
|
+
const brief = current?.brief ?? next.brief;
|
|
77
|
+
const description = current?.description ?? next.description;
|
|
78
|
+
const footer = current?.footer ?? next.footer;
|
|
79
|
+
return withOrigin({
|
|
80
|
+
...brief == null ? {} : { brief },
|
|
81
|
+
...description == null ? {} : { description },
|
|
82
|
+
...footer == null ? {} : { footer }
|
|
83
|
+
}, origin);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { collectCommandDocMetadata, getCommandDocMetadata, withCommandDocMetadata };
|
package/dist/modifiers.cjs
CHANGED
|
@@ -3,6 +3,7 @@ const require_message = require('./message.cjs');
|
|
|
3
3
|
const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
4
4
|
const require_internal_parser = require('./internal/parser.cjs');
|
|
5
5
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
6
|
+
const require_command_doc_metadata = require('./internal/command-doc-metadata.cjs');
|
|
6
7
|
const require_passthrough = require('./internal/passthrough.cjs');
|
|
7
8
|
const require_execution_context = require('./execution-context.cjs');
|
|
8
9
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
@@ -636,10 +637,10 @@ function withDefault(parser, defaultValue, options) {
|
|
|
636
637
|
};
|
|
637
638
|
return fragment;
|
|
638
639
|
});
|
|
639
|
-
return {
|
|
640
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
640
641
|
...fragments,
|
|
641
642
|
fragments: modifiedFragments
|
|
642
|
-
};
|
|
643
|
+
}, require_command_doc_metadata.getCommandDocMetadata(fragments));
|
|
643
644
|
}
|
|
644
645
|
return fragments;
|
|
645
646
|
}
|
package/dist/modifiers.js
CHANGED
|
@@ -3,6 +3,7 @@ import { formatMessage, message, text } from "./message.js";
|
|
|
3
3
|
import { dispatchByMode, dispatchIterableByMode, mapModeValue, wrapForMode } from "./internal/mode-dispatch.js";
|
|
4
4
|
import { defineInheritedAnnotationParser, defineParseLanes, defineSourceBindingOnlyAnnotationCompletionParser, getOwnParseLanes, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
5
5
|
import { getDelegatedAnnotationState, hasDelegatedAnnotationCarrier, isAnnotationWrappedInitialState, normalizeDelegatedAnnotationState, normalizeNestedDelegatedAnnotationState } from "./annotation-state.js";
|
|
6
|
+
import { getCommandDocMetadata, withCommandDocMetadata } from "./internal/command-doc-metadata.js";
|
|
6
7
|
import { defineKnownCompletionLookup, defineOptionMatch, definePassThroughPriority, getKnownCompletion, getOptionMatch, getPassThroughPriority } from "./internal/passthrough.js";
|
|
7
8
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
8
9
|
import { completeOrExtractPhase2Seed, extractPhase2Seed, extractPhase2SeedKey, phase2SeedFromValueResult } from "./phase2-seed.js";
|
|
@@ -636,10 +637,10 @@ function withDefault(parser, defaultValue, options) {
|
|
|
636
637
|
};
|
|
637
638
|
return fragment;
|
|
638
639
|
});
|
|
639
|
-
return {
|
|
640
|
+
return withCommandDocMetadata({
|
|
640
641
|
...fragments,
|
|
641
642
|
fragments: modifiedFragments
|
|
642
|
-
};
|
|
643
|
+
}, getCommandDocMetadata(fragments));
|
|
643
644
|
}
|
|
644
645
|
return fragments;
|
|
645
646
|
}
|
package/dist/primitives.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
|
6
6
|
const require_internal_dependency = require('./internal/dependency.cjs');
|
|
7
7
|
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
8
8
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
9
|
+
const require_command_doc_metadata = require('./internal/command-doc-metadata.cjs');
|
|
9
10
|
const require_passthrough = require('./internal/passthrough.cjs');
|
|
10
11
|
const require_command_alias = require('./internal/command-alias.cjs');
|
|
11
12
|
const require_execution_context = require('./execution-context.cjs');
|
|
@@ -250,7 +251,7 @@ function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry,
|
|
|
250
251
|
* @internal
|
|
251
252
|
*/
|
|
252
253
|
function* suggestOptionSync(optionNames$1, valueParser, hidden, description, context, prefix) {
|
|
253
|
-
if (hidden) return;
|
|
254
|
+
if (hidden || context.optionsTerminated) return;
|
|
254
255
|
const equalsIndex = prefix.indexOf("=");
|
|
255
256
|
if (equalsIndex >= 0) {
|
|
256
257
|
const optionPart = prefix.slice(0, equalsIndex);
|
|
@@ -335,7 +336,7 @@ async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependenc
|
|
|
335
336
|
* @internal
|
|
336
337
|
*/
|
|
337
338
|
async function* suggestOptionAsync(optionNames$1, valueParser, hidden, description, context, prefix) {
|
|
338
|
-
if (hidden) return;
|
|
339
|
+
if (hidden || context.optionsTerminated) return;
|
|
339
340
|
const equalsIndex = prefix.indexOf("=");
|
|
340
341
|
if (equalsIndex >= 0) {
|
|
341
342
|
const optionPart = prefix.slice(0, equalsIndex);
|
|
@@ -639,10 +640,10 @@ function option(...args) {
|
|
|
639
640
|
return suggestOptionSync(optionNames$1, valueParser, require_usage.isSuggestionHidden(options.hidden), options.description, context, prefix);
|
|
640
641
|
},
|
|
641
642
|
getDocFragments(_state, defaultValue) {
|
|
642
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
643
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
643
644
|
fragments: [],
|
|
644
645
|
description: options.description
|
|
645
|
-
};
|
|
646
|
+
}, {});
|
|
646
647
|
const choicesMessage = valueParser?.choices != null && valueParser.choices.length > 0 ? require_message.valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
|
|
647
648
|
fallback: "",
|
|
648
649
|
type: "unit"
|
|
@@ -658,10 +659,10 @@ function option(...args) {
|
|
|
658
659
|
default: defaultValue != null && valueParser != null ? require_message.message`${valueParser.format(defaultValue)}` : void 0,
|
|
659
660
|
choices: choicesMessage
|
|
660
661
|
}];
|
|
661
|
-
return {
|
|
662
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
662
663
|
fragments,
|
|
663
664
|
description: options.description
|
|
664
|
-
};
|
|
665
|
+
}, {});
|
|
665
666
|
},
|
|
666
667
|
[Symbol.for("Deno.customInspect")]() {
|
|
667
668
|
return `option(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
|
|
@@ -914,8 +915,8 @@ function flag(...args) {
|
|
|
914
915
|
error: require_message.message`${require_message.optionNames(optionNames$1)}: ${state.error}`
|
|
915
916
|
};
|
|
916
917
|
},
|
|
917
|
-
suggest(
|
|
918
|
-
if (require_usage.isSuggestionHidden(options.hidden)) return [];
|
|
918
|
+
suggest(context, prefix) {
|
|
919
|
+
if (require_usage.isSuggestionHidden(options.hidden) || context.optionsTerminated) return [];
|
|
919
920
|
const suggestions = [];
|
|
920
921
|
if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/") || prefix.startsWith("+")) {
|
|
921
922
|
for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
|
|
@@ -930,10 +931,10 @@ function flag(...args) {
|
|
|
930
931
|
return suggestions;
|
|
931
932
|
},
|
|
932
933
|
getDocFragments(_state, _defaultValue) {
|
|
933
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
934
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
934
935
|
fragments: [],
|
|
935
936
|
description: options.description
|
|
936
|
-
};
|
|
937
|
+
}, {});
|
|
937
938
|
const fragments = [{
|
|
938
939
|
type: "entry",
|
|
939
940
|
term: {
|
|
@@ -942,10 +943,10 @@ function flag(...args) {
|
|
|
942
943
|
},
|
|
943
944
|
description: options.description
|
|
944
945
|
}];
|
|
945
|
-
return {
|
|
946
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
946
947
|
fragments,
|
|
947
948
|
description: options.description
|
|
948
|
-
};
|
|
949
|
+
}, {});
|
|
949
950
|
},
|
|
950
951
|
[Symbol.for("Deno.customInspect")]() {
|
|
951
952
|
return `flag(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
|
|
@@ -1302,10 +1303,10 @@ function argument(valueParser, options = {}) {
|
|
|
1302
1303
|
return suggestArgumentSync(valueParser, require_usage.isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry, context.exec);
|
|
1303
1304
|
},
|
|
1304
1305
|
getDocFragments(_state, defaultValue) {
|
|
1305
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
1306
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
1306
1307
|
fragments: [],
|
|
1307
1308
|
description: options.description
|
|
1308
|
-
};
|
|
1309
|
+
}, {});
|
|
1309
1310
|
const choicesMessage = valueParser.choices != null && valueParser.choices.length > 0 ? require_message.valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
|
|
1310
1311
|
fallback: "",
|
|
1311
1312
|
type: "unit"
|
|
@@ -1317,10 +1318,10 @@ function argument(valueParser, options = {}) {
|
|
|
1317
1318
|
default: defaultValue == null ? void 0 : require_message.message`${valueParser.format(defaultValue)}`,
|
|
1318
1319
|
choices: choicesMessage
|
|
1319
1320
|
}];
|
|
1320
|
-
return {
|
|
1321
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1321
1322
|
fragments,
|
|
1322
1323
|
description: options.description
|
|
1323
|
-
};
|
|
1324
|
+
}, {});
|
|
1324
1325
|
},
|
|
1325
1326
|
[Symbol.for("Deno.customInspect")]() {
|
|
1326
1327
|
return `argument()`;
|
|
@@ -1671,11 +1672,11 @@ function command(name, parser, options = {}) {
|
|
|
1671
1672
|
getDocFragments(state, defaultValue) {
|
|
1672
1673
|
const commandState = state.kind === "available" ? normalizeCommandState(state.state) : void 0;
|
|
1673
1674
|
if (state.kind === "unavailable" || typeof commandState === "undefined") {
|
|
1674
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
1675
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
1675
1676
|
fragments: [],
|
|
1676
1677
|
description: options.description
|
|
1677
|
-
};
|
|
1678
|
-
return {
|
|
1678
|
+
}, {});
|
|
1679
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1679
1680
|
description: options.description,
|
|
1680
1681
|
fragments: [{
|
|
1681
1682
|
type: "entry",
|
|
@@ -1685,7 +1686,7 @@ function command(name, parser, options = {}) {
|
|
|
1685
1686
|
},
|
|
1686
1687
|
description: options.brief ?? options.description
|
|
1687
1688
|
}]
|
|
1688
|
-
};
|
|
1689
|
+
}, {});
|
|
1689
1690
|
}
|
|
1690
1691
|
const innerState = commandState[0] === "parsing" ? {
|
|
1691
1692
|
kind: "available",
|
|
@@ -1695,12 +1696,18 @@ function command(name, parser, options = {}) {
|
|
|
1695
1696
|
state: getCommandChildState(state.state, parser.initialState, parser)
|
|
1696
1697
|
};
|
|
1697
1698
|
const innerFragments = parser.getDocFragments(innerState, defaultValue);
|
|
1698
|
-
|
|
1699
|
+
const innerMetadata = require_command_doc_metadata.getCommandDocMetadata(innerFragments) ?? innerFragments;
|
|
1700
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1699
1701
|
...innerFragments,
|
|
1700
1702
|
brief: innerFragments.brief ?? options.brief,
|
|
1701
1703
|
description: innerFragments.description ?? options.description,
|
|
1702
1704
|
footer: innerFragments.footer ?? options.footer
|
|
1703
|
-
}
|
|
1705
|
+
}, {
|
|
1706
|
+
origin: "command",
|
|
1707
|
+
brief: innerMetadata?.brief ?? options.brief,
|
|
1708
|
+
description: innerMetadata?.description ?? options.description,
|
|
1709
|
+
footer: innerMetadata?.footer ?? options.footer
|
|
1710
|
+
});
|
|
1704
1711
|
},
|
|
1705
1712
|
[Symbol.for("Deno.customInspect")]() {
|
|
1706
1713
|
return `command(${JSON.stringify(name)})`;
|
|
@@ -1901,18 +1908,18 @@ function passThrough(options = {}) {
|
|
|
1901
1908
|
return [];
|
|
1902
1909
|
},
|
|
1903
1910
|
getDocFragments(_state, _defaultValue) {
|
|
1904
|
-
if (require_usage.isDocHidden(options.hidden)) return {
|
|
1911
|
+
if (require_usage.isDocHidden(options.hidden)) return require_command_doc_metadata.withCommandDocMetadata({
|
|
1905
1912
|
fragments: [],
|
|
1906
1913
|
description: options.description
|
|
1907
|
-
};
|
|
1908
|
-
return {
|
|
1914
|
+
}, {});
|
|
1915
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1909
1916
|
fragments: [{
|
|
1910
1917
|
type: "entry",
|
|
1911
1918
|
term: { type: "passthrough" },
|
|
1912
1919
|
description: options.description
|
|
1913
1920
|
}],
|
|
1914
1921
|
description: options.description
|
|
1915
|
-
};
|
|
1922
|
+
}, {});
|
|
1916
1923
|
},
|
|
1917
1924
|
[Symbol.for("Deno.customInspect")]() {
|
|
1918
1925
|
return `passThrough(${format})`;
|
package/dist/primitives.js
CHANGED
|
@@ -6,6 +6,7 @@ import { dispatchByMode, dispatchIterableByMode, wrapForMode } from "./internal/
|
|
|
6
6
|
import { getDefaultValuesFunction, getDependencyIds, getSnapshottedDefaultDependencyValues, isDerivedValueParser, suggestWithDependency } from "./internal/dependency.js";
|
|
7
7
|
import { replayDerivedParser, replayDerivedParserAsync } from "./dependency-runtime.js";
|
|
8
8
|
import { getWrappedChildParseState, getWrappedChildState, isAnnotationWrappedInitialState, normalizeInjectedAnnotationState } from "./annotation-state.js";
|
|
9
|
+
import { getCommandDocMetadata, withCommandDocMetadata } from "./internal/command-doc-metadata.js";
|
|
9
10
|
import { defineKnownCompletion, defineOptionMatch, definePassThroughPriority, getOptionMatch, getPassThroughFailure, getPassThroughPriority } from "./internal/passthrough.js";
|
|
10
11
|
import { hiddenCommandAliasesKey } from "./internal/command-alias.js";
|
|
11
12
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
@@ -250,7 +251,7 @@ function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry,
|
|
|
250
251
|
* @internal
|
|
251
252
|
*/
|
|
252
253
|
function* suggestOptionSync(optionNames$1, valueParser, hidden, description, context, prefix) {
|
|
253
|
-
if (hidden) return;
|
|
254
|
+
if (hidden || context.optionsTerminated) return;
|
|
254
255
|
const equalsIndex = prefix.indexOf("=");
|
|
255
256
|
if (equalsIndex >= 0) {
|
|
256
257
|
const optionPart = prefix.slice(0, equalsIndex);
|
|
@@ -335,7 +336,7 @@ async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependenc
|
|
|
335
336
|
* @internal
|
|
336
337
|
*/
|
|
337
338
|
async function* suggestOptionAsync(optionNames$1, valueParser, hidden, description, context, prefix) {
|
|
338
|
-
if (hidden) return;
|
|
339
|
+
if (hidden || context.optionsTerminated) return;
|
|
339
340
|
const equalsIndex = prefix.indexOf("=");
|
|
340
341
|
if (equalsIndex >= 0) {
|
|
341
342
|
const optionPart = prefix.slice(0, equalsIndex);
|
|
@@ -639,10 +640,10 @@ function option(...args) {
|
|
|
639
640
|
return suggestOptionSync(optionNames$1, valueParser, isSuggestionHidden(options.hidden), options.description, context, prefix);
|
|
640
641
|
},
|
|
641
642
|
getDocFragments(_state, defaultValue) {
|
|
642
|
-
if (isDocHidden(options.hidden)) return {
|
|
643
|
+
if (isDocHidden(options.hidden)) return withCommandDocMetadata({
|
|
643
644
|
fragments: [],
|
|
644
645
|
description: options.description
|
|
645
|
-
};
|
|
646
|
+
}, {});
|
|
646
647
|
const choicesMessage = valueParser?.choices != null && valueParser.choices.length > 0 ? valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
|
|
647
648
|
fallback: "",
|
|
648
649
|
type: "unit"
|
|
@@ -658,10 +659,10 @@ function option(...args) {
|
|
|
658
659
|
default: defaultValue != null && valueParser != null ? message`${valueParser.format(defaultValue)}` : void 0,
|
|
659
660
|
choices: choicesMessage
|
|
660
661
|
}];
|
|
661
|
-
return {
|
|
662
|
+
return withCommandDocMetadata({
|
|
662
663
|
fragments,
|
|
663
664
|
description: options.description
|
|
664
|
-
};
|
|
665
|
+
}, {});
|
|
665
666
|
},
|
|
666
667
|
[Symbol.for("Deno.customInspect")]() {
|
|
667
668
|
return `option(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
|
|
@@ -914,8 +915,8 @@ function flag(...args) {
|
|
|
914
915
|
error: message`${optionNames(optionNames$1)}: ${state.error}`
|
|
915
916
|
};
|
|
916
917
|
},
|
|
917
|
-
suggest(
|
|
918
|
-
if (isSuggestionHidden(options.hidden)) return [];
|
|
918
|
+
suggest(context, prefix) {
|
|
919
|
+
if (isSuggestionHidden(options.hidden) || context.optionsTerminated) return [];
|
|
919
920
|
const suggestions = [];
|
|
920
921
|
if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/") || prefix.startsWith("+")) {
|
|
921
922
|
for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
|
|
@@ -930,10 +931,10 @@ function flag(...args) {
|
|
|
930
931
|
return suggestions;
|
|
931
932
|
},
|
|
932
933
|
getDocFragments(_state, _defaultValue) {
|
|
933
|
-
if (isDocHidden(options.hidden)) return {
|
|
934
|
+
if (isDocHidden(options.hidden)) return withCommandDocMetadata({
|
|
934
935
|
fragments: [],
|
|
935
936
|
description: options.description
|
|
936
|
-
};
|
|
937
|
+
}, {});
|
|
937
938
|
const fragments = [{
|
|
938
939
|
type: "entry",
|
|
939
940
|
term: {
|
|
@@ -942,10 +943,10 @@ function flag(...args) {
|
|
|
942
943
|
},
|
|
943
944
|
description: options.description
|
|
944
945
|
}];
|
|
945
|
-
return {
|
|
946
|
+
return withCommandDocMetadata({
|
|
946
947
|
fragments,
|
|
947
948
|
description: options.description
|
|
948
|
-
};
|
|
949
|
+
}, {});
|
|
949
950
|
},
|
|
950
951
|
[Symbol.for("Deno.customInspect")]() {
|
|
951
952
|
return `flag(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
|
|
@@ -1302,10 +1303,10 @@ function argument(valueParser, options = {}) {
|
|
|
1302
1303
|
return suggestArgumentSync(valueParser, isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry, context.exec);
|
|
1303
1304
|
},
|
|
1304
1305
|
getDocFragments(_state, defaultValue) {
|
|
1305
|
-
if (isDocHidden(options.hidden)) return {
|
|
1306
|
+
if (isDocHidden(options.hidden)) return withCommandDocMetadata({
|
|
1306
1307
|
fragments: [],
|
|
1307
1308
|
description: options.description
|
|
1308
|
-
};
|
|
1309
|
+
}, {});
|
|
1309
1310
|
const choicesMessage = valueParser.choices != null && valueParser.choices.length > 0 ? valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
|
|
1310
1311
|
fallback: "",
|
|
1311
1312
|
type: "unit"
|
|
@@ -1317,10 +1318,10 @@ function argument(valueParser, options = {}) {
|
|
|
1317
1318
|
default: defaultValue == null ? void 0 : message`${valueParser.format(defaultValue)}`,
|
|
1318
1319
|
choices: choicesMessage
|
|
1319
1320
|
}];
|
|
1320
|
-
return {
|
|
1321
|
+
return withCommandDocMetadata({
|
|
1321
1322
|
fragments,
|
|
1322
1323
|
description: options.description
|
|
1323
|
-
};
|
|
1324
|
+
}, {});
|
|
1324
1325
|
},
|
|
1325
1326
|
[Symbol.for("Deno.customInspect")]() {
|
|
1326
1327
|
return `argument()`;
|
|
@@ -1671,11 +1672,11 @@ function command(name, parser, options = {}) {
|
|
|
1671
1672
|
getDocFragments(state, defaultValue) {
|
|
1672
1673
|
const commandState = state.kind === "available" ? normalizeCommandState(state.state) : void 0;
|
|
1673
1674
|
if (state.kind === "unavailable" || typeof commandState === "undefined") {
|
|
1674
|
-
if (isDocHidden(options.hidden)) return {
|
|
1675
|
+
if (isDocHidden(options.hidden)) return withCommandDocMetadata({
|
|
1675
1676
|
fragments: [],
|
|
1676
1677
|
description: options.description
|
|
1677
|
-
};
|
|
1678
|
-
return {
|
|
1678
|
+
}, {});
|
|
1679
|
+
return withCommandDocMetadata({
|
|
1679
1680
|
description: options.description,
|
|
1680
1681
|
fragments: [{
|
|
1681
1682
|
type: "entry",
|
|
@@ -1685,7 +1686,7 @@ function command(name, parser, options = {}) {
|
|
|
1685
1686
|
},
|
|
1686
1687
|
description: options.brief ?? options.description
|
|
1687
1688
|
}]
|
|
1688
|
-
};
|
|
1689
|
+
}, {});
|
|
1689
1690
|
}
|
|
1690
1691
|
const innerState = commandState[0] === "parsing" ? {
|
|
1691
1692
|
kind: "available",
|
|
@@ -1695,12 +1696,18 @@ function command(name, parser, options = {}) {
|
|
|
1695
1696
|
state: getCommandChildState(state.state, parser.initialState, parser)
|
|
1696
1697
|
};
|
|
1697
1698
|
const innerFragments = parser.getDocFragments(innerState, defaultValue);
|
|
1698
|
-
|
|
1699
|
+
const innerMetadata = getCommandDocMetadata(innerFragments) ?? innerFragments;
|
|
1700
|
+
return withCommandDocMetadata({
|
|
1699
1701
|
...innerFragments,
|
|
1700
1702
|
brief: innerFragments.brief ?? options.brief,
|
|
1701
1703
|
description: innerFragments.description ?? options.description,
|
|
1702
1704
|
footer: innerFragments.footer ?? options.footer
|
|
1703
|
-
}
|
|
1705
|
+
}, {
|
|
1706
|
+
origin: "command",
|
|
1707
|
+
brief: innerMetadata?.brief ?? options.brief,
|
|
1708
|
+
description: innerMetadata?.description ?? options.description,
|
|
1709
|
+
footer: innerMetadata?.footer ?? options.footer
|
|
1710
|
+
});
|
|
1704
1711
|
},
|
|
1705
1712
|
[Symbol.for("Deno.customInspect")]() {
|
|
1706
1713
|
return `command(${JSON.stringify(name)})`;
|
|
@@ -1901,18 +1908,18 @@ function passThrough(options = {}) {
|
|
|
1901
1908
|
return [];
|
|
1902
1909
|
},
|
|
1903
1910
|
getDocFragments(_state, _defaultValue) {
|
|
1904
|
-
if (isDocHidden(options.hidden)) return {
|
|
1911
|
+
if (isDocHidden(options.hidden)) return withCommandDocMetadata({
|
|
1905
1912
|
fragments: [],
|
|
1906
1913
|
description: options.description
|
|
1907
|
-
};
|
|
1908
|
-
return {
|
|
1914
|
+
}, {});
|
|
1915
|
+
return withCommandDocMetadata({
|
|
1909
1916
|
fragments: [{
|
|
1910
1917
|
type: "entry",
|
|
1911
1918
|
term: { type: "passthrough" },
|
|
1912
1919
|
description: options.description
|
|
1913
1920
|
}],
|
|
1914
1921
|
description: options.description
|
|
1915
|
-
};
|
|
1922
|
+
}, {});
|
|
1916
1923
|
},
|
|
1917
1924
|
[Symbol.for("Deno.customInspect")]() {
|
|
1918
1925
|
return `passThrough(${format})`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
},
|
|
197
197
|
"sideEffects": false,
|
|
198
198
|
"devDependencies": {
|
|
199
|
-
"@optique/env": "1.1.
|
|
199
|
+
"@optique/env": "1.1.12",
|
|
200
200
|
"@types/node": "^24.0.0",
|
|
201
201
|
"fast-check": "^4.7.0",
|
|
202
202
|
"tsdown": "^0.13.0",
|