(
rawOptions: string,
opts?: { quiet?: boolean },
)
| 860 | } |
| 861 | |
| 862 | export function parseAnonymousValueOptions( |
| 863 | rawOptions: string, |
| 864 | opts?: { quiet?: boolean }, |
| 865 | ): { |
| 866 | label?: string; |
| 867 | caseStyle?: string; |
| 868 | defaultValue: string; |
| 869 | inputTypeOverride?: ValueInputType; |
| 870 | numericConfig?: NumericInputConfig; |
| 871 | sliderConfig?: SliderConfig; |
| 872 | optional: boolean; |
| 873 | trim: boolean; |
| 874 | } { |
| 875 | const quiet = opts?.quiet ?? false; |
| 876 | const normalized = stripLeadingPipe(rawOptions); |
| 877 | const allParts = splitPipeParts(normalized) |
| 878 | .map((part) => part.trim()) |
| 879 | .filter(Boolean); |
| 880 | |
| 881 | const { |
| 882 | remaining: parts, |
| 883 | optional: bareOptional, |
| 884 | trim: bareTrim, |
| 885 | } = extractBareValueFlags(allParts); |
| 886 | |
| 887 | if (parts.length === 0) { |
| 888 | return { defaultValue: "", optional: bareOptional, trim: bareTrim }; |
| 889 | } |
| 890 | |
| 891 | const options = parseOptions(parts, false, false); |
| 892 | const tokenDisplay = `{{VALUE${rawOptions}}}`; |
| 893 | if (options.displayValuesRaw !== undefined) { |
| 894 | throw new Error( |
| 895 | `QuickAdd: VALUE option "text" is only supported for option-list tokens in "${tokenDisplay}".`, |
| 896 | ); |
| 897 | } |
| 898 | let { label, caseStyle, defaultValue } = options; |
| 899 | if (!options.usesOptions) { |
| 900 | defaultValue = defaultValue.trim(); |
| 901 | } |
| 902 | |
| 903 | // Warn on an unrecognized |case style (typo) so the anonymous form gets the |
| 904 | // same feedback as the named/single form (parseValueToken). Gated on quiet |
| 905 | // so the prompt-context pre-pass (which also calls this) does not double the |
| 906 | // notice — mirroring parseValueToken's quiet handling. |
| 907 | if (caseStyle && !isSupportedCaseStyle(caseStyle)) { |
| 908 | if (!quiet) |
| 909 | log.logWarning( |
| 910 | `QuickAdd: Unsupported |case style "${caseStyle}" in token "${tokenDisplay}". Supported styles: ${SUPPORTED_CASE_STYLES.join(", ")}.`, |
| 911 | ); |
| 912 | caseStyle = undefined; |
| 913 | } |
| 914 | |
| 915 | const inputTypeOverride = resolveInputType(options.inputTypeOverride, { |
| 916 | tokenDisplay, |
| 917 | hasOptions: false, |
| 918 | allowCustomInput: options.allowCustomInput, |
| 919 | }); |
no test coverage detected