* Fetch the input name that the user wants to export. * @param inputName - The name of the input to load. * @returns
(inputName?: string)
| 172 | * @returns |
| 173 | */ |
| 174 | async function requireInput(inputName?: string): Promise<string> | never { |
| 175 | if (!inputName) { |
| 176 | const res = await prompts({ |
| 177 | type: 'autocomplete', |
| 178 | name: 'inputName', |
| 179 | message: 'What input do you want to export?', |
| 180 | choices: Object.keys(inputs).map((i) => ({ |
| 181 | title: i, |
| 182 | value: i, |
| 183 | })), |
| 184 | }) |
| 185 | inputName = res.inputName |
| 186 | } |
| 187 | if (!inputName || !(inputName in inputs)) { |
| 188 | error( |
| 189 | `Cannot export “${inputName}” because it is not part of the @formkit/inputs package.` |
| 190 | ) |
| 191 | } |
| 192 | return inputName |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Loads the string data of an input that should be exported. |