@optique/core 1.0.0-dev.1751 → 1.0.0-dev.1758

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.
@@ -788,13 +788,28 @@ function multiple(parser, options = {}) {
788
788
  let itemIndex = canExtendCurrent ? context.state.length - 1 : context.state.length;
789
789
  const currentItemStateWithAnnotations = canExtendCurrent ? currentItemState : require_annotations.inheritAnnotations(context.state, syncParser.initialState);
790
790
  let result = parseSyncWithUnwrappedFallback(withChildContext(context, itemIndex, currentItemStateWithAnnotations));
791
- if (!result.success) if (!added && canOpenFreshItem && result.consumed === 0) {
792
- const nextInitialState = require_annotations.inheritAnnotations(context.state, syncParser.initialState);
793
- itemIndex = context.state.length;
794
- result = parseSyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
795
- if (!result.success) return result;
796
- added = true;
797
- } else return result;
791
+ if (!result.success) {
792
+ if (result.consumed !== 0) return result;
793
+ if (!added && canOpenFreshItem) {
794
+ const nextInitialState = require_annotations.inheritAnnotations(context.state, syncParser.initialState);
795
+ itemIndex = context.state.length;
796
+ result = parseSyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
797
+ if (!result.success) {
798
+ if (min === 0 && context.buffer.length === 0 && result.consumed === 0) return {
799
+ success: true,
800
+ next: context,
801
+ consumed: []
802
+ };
803
+ return result;
804
+ }
805
+ added = true;
806
+ } else if (min === 0 && context.buffer.length === 0) return {
807
+ success: true,
808
+ next: context,
809
+ consumed: []
810
+ };
811
+ else return result;
812
+ }
798
813
  const mergedExec = mergeChildExec(context.exec, result.next.exec);
799
814
  if (added && result.consumed.length === 0 && result.next.optionsTerminated === context.optionsTerminated && isUnstartedMultipleItemState(result.next.state, currentItemStateWithAnnotations)) return {
800
815
  success: true,
@@ -853,13 +868,28 @@ function multiple(parser, options = {}) {
853
868
  let itemIndex = canExtendCurrent ? context.state.length - 1 : context.state.length;
854
869
  const currentItemStateWithAnnotations = canExtendCurrent ? currentItemState : require_annotations.inheritAnnotations(context.state, parser.initialState);
855
870
  let result = await parseAsyncWithUnwrappedFallback(withChildContext(context, itemIndex, currentItemStateWithAnnotations));
856
- if (!result.success) if (!added && canOpenFreshItem && result.consumed === 0) {
857
- const nextInitialState = require_annotations.inheritAnnotations(context.state, parser.initialState);
858
- itemIndex = context.state.length;
859
- result = await parseAsyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
860
- if (!result.success) return result;
861
- added = true;
862
- } else return result;
871
+ if (!result.success) {
872
+ if (result.consumed !== 0) return result;
873
+ if (!added && canOpenFreshItem) {
874
+ const nextInitialState = require_annotations.inheritAnnotations(context.state, parser.initialState);
875
+ itemIndex = context.state.length;
876
+ result = await parseAsyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
877
+ if (!result.success) {
878
+ if (min === 0 && context.buffer.length === 0 && result.consumed === 0) return {
879
+ success: true,
880
+ next: context,
881
+ consumed: []
882
+ };
883
+ return result;
884
+ }
885
+ added = true;
886
+ } else if (min === 0 && context.buffer.length === 0) return {
887
+ success: true,
888
+ next: context,
889
+ consumed: []
890
+ };
891
+ else return result;
892
+ }
863
893
  const mergedExec = mergeChildExec(context.exec, result.next.exec);
864
894
  if (added && result.consumed.length === 0 && result.next.optionsTerminated === context.optionsTerminated && isUnstartedMultipleItemState(result.next.state, currentItemStateWithAnnotations)) return {
865
895
  success: true,
package/dist/modifiers.js CHANGED
@@ -788,13 +788,28 @@ function multiple(parser, options = {}) {
788
788
  let itemIndex = canExtendCurrent ? context.state.length - 1 : context.state.length;
789
789
  const currentItemStateWithAnnotations = canExtendCurrent ? currentItemState : inheritAnnotations(context.state, syncParser.initialState);
790
790
  let result = parseSyncWithUnwrappedFallback(withChildContext(context, itemIndex, currentItemStateWithAnnotations));
791
- if (!result.success) if (!added && canOpenFreshItem && result.consumed === 0) {
792
- const nextInitialState = inheritAnnotations(context.state, syncParser.initialState);
793
- itemIndex = context.state.length;
794
- result = parseSyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
795
- if (!result.success) return result;
796
- added = true;
797
- } else return result;
791
+ if (!result.success) {
792
+ if (result.consumed !== 0) return result;
793
+ if (!added && canOpenFreshItem) {
794
+ const nextInitialState = inheritAnnotations(context.state, syncParser.initialState);
795
+ itemIndex = context.state.length;
796
+ result = parseSyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
797
+ if (!result.success) {
798
+ if (min === 0 && context.buffer.length === 0 && result.consumed === 0) return {
799
+ success: true,
800
+ next: context,
801
+ consumed: []
802
+ };
803
+ return result;
804
+ }
805
+ added = true;
806
+ } else if (min === 0 && context.buffer.length === 0) return {
807
+ success: true,
808
+ next: context,
809
+ consumed: []
810
+ };
811
+ else return result;
812
+ }
798
813
  const mergedExec = mergeChildExec(context.exec, result.next.exec);
799
814
  if (added && result.consumed.length === 0 && result.next.optionsTerminated === context.optionsTerminated && isUnstartedMultipleItemState(result.next.state, currentItemStateWithAnnotations)) return {
800
815
  success: true,
@@ -853,13 +868,28 @@ function multiple(parser, options = {}) {
853
868
  let itemIndex = canExtendCurrent ? context.state.length - 1 : context.state.length;
854
869
  const currentItemStateWithAnnotations = canExtendCurrent ? currentItemState : inheritAnnotations(context.state, parser.initialState);
855
870
  let result = await parseAsyncWithUnwrappedFallback(withChildContext(context, itemIndex, currentItemStateWithAnnotations));
856
- if (!result.success) if (!added && canOpenFreshItem && result.consumed === 0) {
857
- const nextInitialState = inheritAnnotations(context.state, parser.initialState);
858
- itemIndex = context.state.length;
859
- result = await parseAsyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
860
- if (!result.success) return result;
861
- added = true;
862
- } else return result;
871
+ if (!result.success) {
872
+ if (result.consumed !== 0) return result;
873
+ if (!added && canOpenFreshItem) {
874
+ const nextInitialState = inheritAnnotations(context.state, parser.initialState);
875
+ itemIndex = context.state.length;
876
+ result = await parseAsyncWithUnwrappedFallback(withChildContext(context, itemIndex, nextInitialState));
877
+ if (!result.success) {
878
+ if (min === 0 && context.buffer.length === 0 && result.consumed === 0) return {
879
+ success: true,
880
+ next: context,
881
+ consumed: []
882
+ };
883
+ return result;
884
+ }
885
+ added = true;
886
+ } else if (min === 0 && context.buffer.length === 0) return {
887
+ success: true,
888
+ next: context,
889
+ consumed: []
890
+ };
891
+ else return result;
892
+ }
863
893
  const mergedExec = mergeChildExec(context.exec, result.next.exec);
864
894
  if (added && result.consumed.length === 0 && result.next.optionsTerminated === context.optionsTerminated && isUnstartedMultipleItemState(result.next.state, currentItemStateWithAnnotations)) return {
865
895
  success: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1751+ba8aadea",
3
+ "version": "1.0.0-dev.1758+0d05b449",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",