(
raw: string,
opts?: { quiet?: boolean },
)
| 680 | } |
| 681 | |
| 682 | export function parseValueToken( |
| 683 | raw: string, |
| 684 | opts?: { quiet?: boolean }, |
| 685 | ): ParsedValueToken | null { |
| 686 | if (!raw) return null; |
| 687 | const quiet = opts?.quiet ?? false; |
| 688 | |
| 689 | const parts = splitPipeParts(raw); |
| 690 | const variablePart = (parts.shift() ?? "").trim(); |
| 691 | if (!variablePart) return null; |
| 692 | |
| 693 | const suggestedValues = splitQuotedCommaList(variablePart) |
| 694 | .map((value) => value.trim()) |
| 695 | .filter(Boolean); |
| 696 | const hasOptions = suggestedValues.length > 1; |
| 697 | |
| 698 | const { |
| 699 | remaining: optionParts, |
| 700 | optional: bareOptional, |
| 701 | trim: bareTrim, |
| 702 | } = extractBareValueFlags(parts); |
| 703 | const options = parseOptions(optionParts, hasOptions, true, quiet); |
| 704 | let { label, caseStyle, defaultValue, allowCustomInput } = options; |
| 705 | let multiSelect = options.multiSelect ?? false; |
| 706 | const multiEmit: MultiEmit = options.multiEmit ?? "text"; |
| 707 | const optional = options.optionalExplicit ?? bareOptional; |
| 708 | const trim = options.trimExplicit ?? bareTrim; |
| 709 | |
| 710 | if (!options.usesOptions) { |
| 711 | const legacyDefault = defaultValue; |
| 712 | allowCustomInput = hasOptions && legacyDefault.toLowerCase() === "custom"; |
| 713 | defaultValue = allowCustomInput ? "" : legacyDefault; |
| 714 | } |
| 715 | |
| 716 | // Option-list defaults may contain a comma, which is only expressible as a |
| 717 | // quoted value (|default:"a, b"); unwrap it so it matches its now-unquoted |
| 718 | // option in both the preflight form and the runtime empty-submission fallback. |
| 719 | if (hasOptions && defaultValue) { |
| 720 | defaultValue = unwrapQuotedValue(defaultValue); |
| 721 | } |
| 722 | |
| 723 | const tokenDisplay = `{{VALUE:${raw}}}`; |
| 724 | const inputTypeOverride = resolveInputType( |
| 725 | options.inputTypeOverride, |
| 726 | { |
| 727 | tokenDisplay, |
| 728 | hasOptions, |
| 729 | allowCustomInput, |
| 730 | }, |
| 731 | quiet, |
| 732 | ); |
| 733 | const numericInput = resolveNumericInput( |
| 734 | options, |
| 735 | tokenDisplay, |
| 736 | inputTypeOverride, |
| 737 | quiet, |
| 738 | ); |
| 739 | let displayValues: string[] | undefined; |
no test coverage detected