MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / multiInput

Function multiInput

packages/setupWizard/src/utils.ts:89–125  ·  view source on GitHub ↗
(options: {
    message: string;
    placeholder?: string;
    validate?: (value: string) => string | true;
})

Source from the content-addressed store, hash-verified

87}
88
89export 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
127export function note(message: string, title?: string): void {
128 console.log();

Callers 5

collectGiteaConfigFunction · 0.85
collectAzureDevOpsConfigFunction · 0.85
collectGerritConfigFunction · 0.85
collectBitbucketCloudFunction · 0.85
collectBitbucketServerFunction · 0.85

Calls 1

Tested by

no test coverage detected