MCPcopy Create free account
hub / github.com/Effect-TS/effect / AutoComplete

Function AutoComplete

packages/effect/src/cli/Prompt.ts:1344–1369  ·  view source on GitHub ↗
(options: AutoCompleteOptions<A>)

Source from the content-addressed store, hash-verified

1342 * @since 4.0.0
1343 */
1344export const AutoComplete = <const A>(options: AutoCompleteOptions<A>): Prompt<A> => {
1345 const opts: AutoCompleteOptionsReq<A> = {
1346 maxPerPage: 10,
1347 filterLabel: "filter",
1348 filterPlaceholder: "type to filter",
1349 emptyMessage: "No matches",
1350 ...options
1351 }
1352 const initialIndex = getSelectInitialIndex(opts.choices)
1353 const filtered = filterAutoCompleteChoices(opts.choices, "")
1354 const index = filtered.length === 0
1355 ? 0
1356 : filtered.includes(initialIndex)
1357 ? initialIndex
1358 : filtered[0]
1359 const initialState: AutoCompleteState = {
1360 query: "",
1361 index,
1362 filtered
1363 }
1364 return Custom(initialState, {
1365 render: handleAutoCompleteRender(opts),
1366 process: handleAutoCompleteProcess(opts),
1367 clear: handleAutoCompleteClear(opts)
1368 })
1369}
1370
1371/**
1372 * Creates a prompt that lets the user select multiple choices and returns their

Callers

nothing calls this directly

Calls 6

getSelectInitialIndexFunction · 0.85
handleAutoCompleteRenderFunction · 0.85
handleAutoCompleteClearFunction · 0.85
CustomFunction · 0.70

Tested by

no test coverage detected