@optique/core 0.9.0-dev.274 → 0.9.0-dev.278

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.
@@ -401,18 +401,30 @@ function multiple(parser, options = {}) {
401
401
  },
402
402
  suggest(context, prefix) {
403
403
  const innerState = context.state.length > 0 ? context.state.at(-1) : parser.initialState;
404
+ const selectedValues = /* @__PURE__ */ new Set();
405
+ for (const s of context.state) {
406
+ const completed = syncParser.complete(s);
407
+ if (completed.success) {
408
+ const valueStr = String(completed.value);
409
+ selectedValues.add(valueStr);
410
+ }
411
+ }
412
+ const shouldInclude = (suggestion) => {
413
+ if (suggestion.kind === "literal") return !selectedValues.has(suggestion.text);
414
+ return true;
415
+ };
404
416
  if (isAsync) return async function* () {
405
417
  const suggestions = parser.suggest({
406
418
  ...context,
407
419
  state: innerState
408
420
  }, prefix);
409
- for await (const s of suggestions) yield s;
421
+ for await (const s of suggestions) if (shouldInclude(s)) yield s;
410
422
  }();
411
423
  return function* () {
412
- yield* syncParser.suggest({
424
+ for (const s of syncParser.suggest({
413
425
  ...context,
414
426
  state: innerState
415
- }, prefix);
427
+ }, prefix)) if (shouldInclude(s)) yield s;
416
428
  }();
417
429
  },
418
430
  getDocFragments(state, defaultValue) {
package/dist/modifiers.js CHANGED
@@ -401,18 +401,30 @@ function multiple(parser, options = {}) {
401
401
  },
402
402
  suggest(context, prefix) {
403
403
  const innerState = context.state.length > 0 ? context.state.at(-1) : parser.initialState;
404
+ const selectedValues = /* @__PURE__ */ new Set();
405
+ for (const s of context.state) {
406
+ const completed = syncParser.complete(s);
407
+ if (completed.success) {
408
+ const valueStr = String(completed.value);
409
+ selectedValues.add(valueStr);
410
+ }
411
+ }
412
+ const shouldInclude = (suggestion) => {
413
+ if (suggestion.kind === "literal") return !selectedValues.has(suggestion.text);
414
+ return true;
415
+ };
404
416
  if (isAsync) return async function* () {
405
417
  const suggestions = parser.suggest({
406
418
  ...context,
407
419
  state: innerState
408
420
  }, prefix);
409
- for await (const s of suggestions) yield s;
421
+ for await (const s of suggestions) if (shouldInclude(s)) yield s;
410
422
  }();
411
423
  return function* () {
412
- yield* syncParser.suggest({
424
+ for (const s of syncParser.suggest({
413
425
  ...context,
414
426
  state: innerState
415
- }, prefix);
427
+ }, prefix)) if (shouldInclude(s)) yield s;
416
428
  }();
417
429
  },
418
430
  getDocFragments(state, defaultValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "0.9.0-dev.274+cbf6ff12",
3
+ "version": "0.9.0-dev.278+042f5c3b",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",