@optique/core 0.6.8 → 0.6.9-dev.197

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.
@@ -647,8 +647,16 @@ function merge(...args) {
647
647
  });
648
648
  },
649
649
  getDocFragments(state, _defaultValue) {
650
- const fragments = parsers.flatMap((p) => {
651
- const parserState = p.initialState === void 0 ? { kind: "unavailable" } : state.kind === "unavailable" ? { kind: "unavailable" } : {
650
+ const fragments = parsers.flatMap((p, i) => {
651
+ let parserState;
652
+ if (p.initialState === void 0) {
653
+ const key = `__parser_${i}`;
654
+ if (state.kind === "available" && state.state && typeof state.state === "object" && key in state.state) parserState = {
655
+ kind: "available",
656
+ state: state.state[key]
657
+ };
658
+ else parserState = { kind: "unavailable" };
659
+ } else parserState = state.kind === "unavailable" ? { kind: "unavailable" } : {
652
660
  kind: "available",
653
661
  state: state.state
654
662
  };
@@ -647,8 +647,16 @@ function merge(...args) {
647
647
  });
648
648
  },
649
649
  getDocFragments(state, _defaultValue) {
650
- const fragments = parsers.flatMap((p) => {
651
- const parserState = p.initialState === void 0 ? { kind: "unavailable" } : state.kind === "unavailable" ? { kind: "unavailable" } : {
650
+ const fragments = parsers.flatMap((p, i) => {
651
+ let parserState;
652
+ if (p.initialState === void 0) {
653
+ const key = `__parser_${i}`;
654
+ if (state.kind === "available" && state.state && typeof state.state === "object" && key in state.state) parserState = {
655
+ kind: "available",
656
+ state: state.state[key]
657
+ };
658
+ else parserState = { kind: "unavailable" };
659
+ } else parserState = state.kind === "unavailable" ? { kind: "unavailable" } : {
652
660
  kind: "available",
653
661
  state: state.state
654
662
  };
package/dist/parser.cjs CHANGED
@@ -149,16 +149,15 @@ function getDocPage(parser, args = []) {
149
149
  }
150
150
  if (entries.length > 0) sections.push({ entries });
151
151
  const usage = [...require_usage.normalizeUsage(parser.usage)];
152
- let i = 0;
153
- for (const arg of args) {
152
+ for (const arg of args) for (let i = 0; i < usage.length; i++) {
154
153
  const term = usage[i];
155
- if (usage.length > i && term.type === "exclusive") for (const termGroup of term.terms) {
154
+ if (term.type !== "exclusive") continue;
155
+ for (const termGroup of term.terms) {
156
156
  const firstTerm = termGroup[0];
157
157
  if (firstTerm?.type !== "command" || firstTerm.name !== arg) continue;
158
158
  usage.splice(i, 1, ...termGroup);
159
159
  break;
160
160
  }
161
- i++;
162
161
  }
163
162
  return {
164
163
  usage,
package/dist/parser.js CHANGED
@@ -149,16 +149,15 @@ function getDocPage(parser, args = []) {
149
149
  }
150
150
  if (entries.length > 0) sections.push({ entries });
151
151
  const usage = [...normalizeUsage(parser.usage)];
152
- let i = 0;
153
- for (const arg of args) {
152
+ for (const arg of args) for (let i = 0; i < usage.length; i++) {
154
153
  const term = usage[i];
155
- if (usage.length > i && term.type === "exclusive") for (const termGroup of term.terms) {
154
+ if (term.type !== "exclusive") continue;
155
+ for (const termGroup of term.terms) {
156
156
  const firstTerm = termGroup[0];
157
157
  if (firstTerm?.type !== "command" || firstTerm.name !== arg) continue;
158
158
  usage.splice(i, 1, ...termGroup);
159
159
  break;
160
160
  }
161
- i++;
162
161
  }
163
162
  return {
164
163
  usage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "0.6.8",
3
+ "version": "0.6.9-dev.197+945d8f0c",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",