(values: T[])
| 217 | ): InputDefinition<T[]> { |
| 218 | const editValues = async (values: T[]): Promise<T[] | CancelAction> => { |
| 219 | // We can't add help to the inquirer `checkbox` so, at least for now, we'll display |
| 220 | // the help before we display the checkbox. |
| 221 | if (options?.helpText) { |
| 222 | console.log(`\n${options.helpText}\n`) |
| 223 | } |
| 224 | const choices: CheckboxChoice<T>[] = items.map(item => { |
| 225 | const value = typeof item === 'string' ? item as T : item.value |
| 226 | const retVal: CheckboxChoice<T> = typeof item === 'object' |
| 227 | ? { ...item } |
| 228 | : ({ name: item, value }) |
| 229 | if (values.includes(value)) { |
| 230 | retVal.checked = true |
| 231 | } |
| 232 | return retVal |
| 233 | }) |
| 234 | const question = { |
| 235 | message: `Select ${name}.`, |
| 236 | choices, |
| 237 | default: finishAction, |
| 238 | pageSize: inquirerPageSize, |
| 239 | validate: options?.validate, |
| 240 | } |
| 241 | const updatedValues = await checkbox(question) |
| 242 | |
| 243 | return updatedValues as T[] |
| 244 | } |
| 245 | |
| 246 | const buildFromUserInput = (): Promise<T[] | CancelAction> => editValues(options?.default ?? []) |
| 247 | |
| 248 | const summarizeForEdit = options?.summarizeForEdit |
no outgoing calls
no test coverage detected