@optique/core 0.8.8-dev.282 → 0.8.9-dev.349

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/parser.cjs CHANGED
@@ -178,11 +178,9 @@ function getDocPage(parser, args = []) {
178
178
  const term = usage[i];
179
179
  if (term.type === "exclusive") {
180
180
  const found = findCommandInExclusive(term, arg);
181
- if (found) {
182
- usage.splice(i, 1, ...found);
183
- i += found.length;
184
- } else i++;
185
- } else i++;
181
+ if (found) usage.splice(i, 1, ...found);
182
+ }
183
+ i++;
186
184
  }
187
185
  return {
188
186
  usage,
package/dist/parser.js CHANGED
@@ -178,11 +178,9 @@ function getDocPage(parser, args = []) {
178
178
  const term = usage[i];
179
179
  if (term.type === "exclusive") {
180
180
  const found = findCommandInExclusive(term, arg);
181
- if (found) {
182
- usage.splice(i, 1, ...found);
183
- i += found.length;
184
- } else i++;
185
- } else i++;
181
+ if (found) usage.splice(i, 1, ...found);
182
+ }
183
+ i++;
186
184
  }
187
185
  return {
188
186
  usage,
@@ -665,8 +665,16 @@ function command(name, parser, options = {}) {
665
665
  success: false,
666
666
  error: options.errors?.notFound ?? require_message.message`Command ${require_message.optionName(name)} was not matched.`
667
667
  };
668
- else if (state[0] === "matched") return parser.complete(parser.initialState);
669
- else if (state[0] === "parsing") return parser.complete(state[1]);
668
+ else if (state[0] === "matched") {
669
+ const parseResult = parser.parse({
670
+ buffer: [],
671
+ optionsTerminated: false,
672
+ usage: [],
673
+ state: parser.initialState
674
+ });
675
+ if (parseResult.success) return parser.complete(parseResult.next.state);
676
+ return parser.complete(parser.initialState);
677
+ } else if (state[0] === "parsing") return parser.complete(state[1]);
670
678
  return {
671
679
  success: false,
672
680
  error: options.errors?.invalidState ?? require_message.message`Invalid command state during completion.`
@@ -665,8 +665,16 @@ function command(name, parser, options = {}) {
665
665
  success: false,
666
666
  error: options.errors?.notFound ?? message`Command ${optionName(name)} was not matched.`
667
667
  };
668
- else if (state[0] === "matched") return parser.complete(parser.initialState);
669
- else if (state[0] === "parsing") return parser.complete(state[1]);
668
+ else if (state[0] === "matched") {
669
+ const parseResult = parser.parse({
670
+ buffer: [],
671
+ optionsTerminated: false,
672
+ usage: [],
673
+ state: parser.initialState
674
+ });
675
+ if (parseResult.success) return parser.complete(parseResult.next.state);
676
+ return parser.complete(parser.initialState);
677
+ } else if (state[0] === "parsing") return parser.complete(state[1]);
670
678
  return {
671
679
  success: false,
672
680
  error: options.errors?.invalidState ?? message`Invalid command state during completion.`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "0.8.8-dev.282+8476af58",
3
+ "version": "0.8.9-dev.349+356beecf",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",