@optique/core 1.2.9 → 1.2.11

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.
@@ -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";
@@ -640,10 +641,10 @@ function option(...args) {
640
641
  return suggestOptionSync(optionNames$1, valueParser, isSuggestionHidden(options.hidden), options.description, context, prefix);
641
642
  },
642
643
  getDocFragments(_state, defaultValue) {
643
- if (isDocHidden(options.hidden)) return {
644
+ if (isDocHidden(options.hidden)) return withCommandDocMetadata({
644
645
  fragments: [],
645
646
  description: options.description
646
- };
647
+ }, {});
647
648
  const choicesMessage = valueParser?.choices != null && valueParser.choices.length > 0 ? valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
648
649
  fallback: "",
649
650
  type: "unit"
@@ -659,10 +660,10 @@ function option(...args) {
659
660
  default: defaultValue != null && valueParser != null ? message`${valueParser.format(defaultValue)}` : void 0,
660
661
  choices: choicesMessage
661
662
  }];
662
- return {
663
+ return withCommandDocMetadata({
663
664
  fragments,
664
665
  description: options.description
665
- };
666
+ }, {});
666
667
  },
667
668
  [Symbol.for("Deno.customInspect")]() {
668
669
  return `option(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
@@ -931,10 +932,10 @@ function flag(...args) {
931
932
  return suggestions;
932
933
  },
933
934
  getDocFragments(_state, _defaultValue) {
934
- if (isDocHidden(options.hidden)) return {
935
+ if (isDocHidden(options.hidden)) return withCommandDocMetadata({
935
936
  fragments: [],
936
937
  description: options.description
937
- };
938
+ }, {});
938
939
  const fragments = [{
939
940
  type: "entry",
940
941
  term: {
@@ -943,10 +944,10 @@ function flag(...args) {
943
944
  },
944
945
  description: options.description
945
946
  }];
946
- return {
947
+ return withCommandDocMetadata({
947
948
  fragments,
948
949
  description: options.description
949
- };
950
+ }, {});
950
951
  },
951
952
  [Symbol.for("Deno.customInspect")]() {
952
953
  return `flag(${optionNames$1.map((o) => JSON.stringify(o)).join(", ")})`;
@@ -1303,10 +1304,10 @@ function argument(valueParser, options = {}) {
1303
1304
  return suggestArgumentSync(valueParser, isSuggestionHidden(options.hidden), prefix, context.dependencyRegistry, context.exec);
1304
1305
  },
1305
1306
  getDocFragments(_state, defaultValue) {
1306
- if (isDocHidden(options.hidden)) return {
1307
+ if (isDocHidden(options.hidden)) return withCommandDocMetadata({
1307
1308
  fragments: [],
1308
1309
  description: options.description
1309
- };
1310
+ }, {});
1310
1311
  const choicesMessage = valueParser.choices != null && valueParser.choices.length > 0 ? valueSet(valueParser.choices.map((c) => valueParser.format(c)), {
1311
1312
  fallback: "",
1312
1313
  type: "unit"
@@ -1318,10 +1319,10 @@ function argument(valueParser, options = {}) {
1318
1319
  default: defaultValue == null ? void 0 : message`${valueParser.format(defaultValue)}`,
1319
1320
  choices: choicesMessage
1320
1321
  }];
1321
- return {
1322
+ return withCommandDocMetadata({
1322
1323
  fragments,
1323
1324
  description: options.description
1324
- };
1325
+ }, {});
1325
1326
  },
1326
1327
  [Symbol.for("Deno.customInspect")]() {
1327
1328
  return `argument()`;
@@ -1672,11 +1673,11 @@ function command(name, parser, options = {}) {
1672
1673
  getDocFragments(state, defaultValue) {
1673
1674
  const commandState = state.kind === "available" ? normalizeCommandState(state.state) : void 0;
1674
1675
  if (state.kind === "unavailable" || typeof commandState === "undefined") {
1675
- if (isDocHidden(options.hidden)) return {
1676
+ if (isDocHidden(options.hidden)) return withCommandDocMetadata({
1676
1677
  fragments: [],
1677
1678
  description: options.description
1678
- };
1679
- return {
1679
+ }, {});
1680
+ return withCommandDocMetadata({
1680
1681
  description: options.description,
1681
1682
  fragments: [{
1682
1683
  type: "entry",
@@ -1686,7 +1687,7 @@ function command(name, parser, options = {}) {
1686
1687
  },
1687
1688
  description: options.brief ?? options.description
1688
1689
  }]
1689
- };
1690
+ }, {});
1690
1691
  }
1691
1692
  const innerState = commandState[0] === "parsing" ? {
1692
1693
  kind: "available",
@@ -1696,12 +1697,18 @@ function command(name, parser, options = {}) {
1696
1697
  state: getCommandChildState(state.state, parser.initialState, parser)
1697
1698
  };
1698
1699
  const innerFragments = parser.getDocFragments(innerState, defaultValue);
1699
- return {
1700
+ const innerMetadata = getCommandDocMetadata(innerFragments) ?? innerFragments;
1701
+ return withCommandDocMetadata({
1700
1702
  ...innerFragments,
1701
1703
  brief: innerFragments.brief ?? options.brief,
1702
1704
  description: innerFragments.description ?? options.description,
1703
1705
  footer: innerFragments.footer ?? options.footer
1704
- };
1706
+ }, {
1707
+ origin: "command",
1708
+ brief: innerMetadata?.brief ?? options.brief,
1709
+ description: innerMetadata?.description ?? options.description,
1710
+ footer: innerMetadata?.footer ?? options.footer
1711
+ });
1705
1712
  },
1706
1713
  [Symbol.for("Deno.customInspect")]() {
1707
1714
  return `command(${JSON.stringify(name)})`;
@@ -1902,18 +1909,18 @@ function passThrough(options = {}) {
1902
1909
  return [];
1903
1910
  },
1904
1911
  getDocFragments(_state, _defaultValue) {
1905
- if (isDocHidden(options.hidden)) return {
1912
+ if (isDocHidden(options.hidden)) return withCommandDocMetadata({
1906
1913
  fragments: [],
1907
1914
  description: options.description
1908
- };
1909
- return {
1915
+ }, {});
1916
+ return withCommandDocMetadata({
1910
1917
  fragments: [{
1911
1918
  type: "entry",
1912
1919
  term: { type: "passthrough" },
1913
1920
  description: options.description
1914
1921
  }],
1915
1922
  description: options.description
1916
- };
1923
+ }, {});
1917
1924
  },
1918
1925
  [Symbol.for("Deno.customInspect")]() {
1919
1926
  return `passThrough(${format})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -221,7 +221,7 @@
221
221
  },
222
222
  "sideEffects": false,
223
223
  "devDependencies": {
224
- "@optique/env": "1.2.9",
224
+ "@optique/env": "1.2.11",
225
225
  "@types/node": "^24.0.0",
226
226
  "fast-check": "^4.7.0",
227
227
  "tsdown": "^0.13.0",