@optique/core 1.1.9 → 1.1.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";
@@ -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(", ")})`;
@@ -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
- return {
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.9",
3
+ "version": "1.1.11",
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.9",
199
+ "@optique/env": "1.1.11",
200
200
  "@types/node": "^24.0.0",
201
201
  "fast-check": "^4.7.0",
202
202
  "tsdown": "^0.13.0",