(options: {
message: string;
placeholder?: string;
validate?: (value: string) => string | true;
})
| 87 | } |
| 88 | |
| 89 | export async function multiInput(options: { |
| 90 | message: string; |
| 91 | placeholder?: string; |
| 92 | validate?: (value: string) => string | true; |
| 93 | }): Promise<string[]> { |
| 94 | const ctx = createSearchSelectContext(); |
| 95 | return searchSelect<string, true>({ |
| 96 | // Bake the "tab to add" hint into the message so it persists after the prompt is submitted |
| 97 | // (the library drops its transient helptip on submit), and disable the duplicate live helptip. |
| 98 | message: `${options.message} (tab to add)`, |
| 99 | multiple: true, |
| 100 | required: true, |
| 101 | loop: false, |
| 102 | clearInputWhenSelected: true, |
| 103 | instructions: false, |
| 104 | theme: ctx.theme, |
| 105 | placeholder: options.placeholder ?? 'Type a value and press tab to add, enter to finish', |
| 106 | options: async (search) => { |
| 107 | ctx.trackSearch(search); |
| 108 | if (!search) { |
| 109 | return []; |
| 110 | } |
| 111 | return [{ name: search, value: search }]; |
| 112 | }, |
| 113 | validate: options.validate |
| 114 | ? (selected) => { |
| 115 | for (const opt of selected) { |
| 116 | const result = options.validate!(opt.value); |
| 117 | if (result !== true) { |
| 118 | return result; |
| 119 | } |
| 120 | } |
| 121 | return true; |
| 122 | } |
| 123 | : undefined, |
| 124 | }); |
| 125 | } |
| 126 | |
| 127 | export function note(message: string, title?: string): void { |
| 128 | console.log(); |
no test coverage detected