@optique/env 1.0.8 → 1.0.10-dev.2593

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/index.cjs CHANGED
@@ -122,14 +122,16 @@ function bindEnv(parser, options) {
122
122
  },
123
123
  parse: (context) => {
124
124
  const annotations = (0, __optique_core_annotations.getAnnotations)(context.state);
125
- const innerState = isEnvBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : parser.initialState : context.state;
125
+ const hadCliValue = isEnvBindState(context.state) && context.state.hasCliValue;
126
+ const innerState = isEnvBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : (0, __optique_core_extension.inheritAnnotations)(context.state, parser.initialState) : context.state;
126
127
  const innerContext = innerState !== context.state ? {
127
128
  ...context,
128
129
  state: innerState
129
130
  } : context;
130
131
  const processResult = (result) => {
131
132
  if (result.success) {
132
- const cliConsumed = result.consumed.length > 0;
133
+ const terminatorOnly = result.consumed.length === 1 && result.consumed[0] === "--" && !context.optionsTerminated && result.next.optionsTerminated;
134
+ const cliConsumed = hadCliValue || result.consumed.length > 0 && !terminatorOnly;
133
135
  const nextState$1 = (0, __optique_core_extension.injectAnnotations)({
134
136
  [envBindStateKey]: true,
135
137
  hasCliValue: cliConsumed,
@@ -146,6 +148,11 @@ function bindEnv(parser, options) {
146
148
  };
147
149
  }
148
150
  if (result.consumed > 0) return result;
151
+ if (hadCliValue) return {
152
+ success: true,
153
+ next: context,
154
+ consumed: []
155
+ };
149
156
  const nextState = (0, __optique_core_extension.injectAnnotations)({
150
157
  [envBindStateKey]: true,
151
158
  hasCliValue: false
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getAnnotations } from "@optique/core/annotations";
2
- import { defineTraits, delegateSuggestNodes, dispatchByMode, getTraits, injectAnnotations, isInjectedAnnotationState, mapModeValue, mapSourceMetadata, wrapForMode } from "@optique/core/extension";
2
+ import { defineTraits, delegateSuggestNodes, dispatchByMode, getTraits, inheritAnnotations, injectAnnotations, isInjectedAnnotationState, mapModeValue, mapSourceMetadata, wrapForMode } from "@optique/core/extension";
3
3
  import { envVar, message, valueSet } from "@optique/core/message";
4
4
  import { ensureNonEmptyString, isValueParser } from "@optique/core/valueparser";
5
5
 
@@ -99,14 +99,16 @@ function bindEnv(parser, options) {
99
99
  },
100
100
  parse: (context) => {
101
101
  const annotations = getAnnotations(context.state);
102
- const innerState = isEnvBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : parser.initialState : context.state;
102
+ const hadCliValue = isEnvBindState(context.state) && context.state.hasCliValue;
103
+ const innerState = isEnvBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : inheritAnnotations(context.state, parser.initialState) : context.state;
103
104
  const innerContext = innerState !== context.state ? {
104
105
  ...context,
105
106
  state: innerState
106
107
  } : context;
107
108
  const processResult = (result) => {
108
109
  if (result.success) {
109
- const cliConsumed = result.consumed.length > 0;
110
+ const terminatorOnly = result.consumed.length === 1 && result.consumed[0] === "--" && !context.optionsTerminated && result.next.optionsTerminated;
111
+ const cliConsumed = hadCliValue || result.consumed.length > 0 && !terminatorOnly;
110
112
  const nextState$1 = injectAnnotations({
111
113
  [envBindStateKey]: true,
112
114
  hasCliValue: cliConsumed,
@@ -123,6 +125,11 @@ function bindEnv(parser, options) {
123
125
  };
124
126
  }
125
127
  if (result.consumed > 0) return result;
128
+ if (hadCliValue) return {
129
+ success: true,
130
+ next: context,
131
+ consumed: []
132
+ };
126
133
  const nextState = injectAnnotations({
127
134
  [envBindStateKey]: true,
128
135
  hasCliValue: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/env",
3
- "version": "1.0.8",
3
+ "version": "1.0.10-dev.2593",
4
4
  "description": "Environment variable support for Optique",
5
5
  "keywords": [
6
6
  "CLI",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "sideEffects": false,
56
56
  "dependencies": {
57
- "@optique/core": "1.0.8"
57
+ "@optique/core": "1.0.10-dev.2593+f609d3eb"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/node": "^20.19.9",