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

Function autoComplete

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

Source from the content-addressed store, hash-verified

1170 * @since 4.0.0
1171 */
1172export const autoComplete = <const A>(options: AutoCompleteOptions<A>): Prompt<A> => {
1173 const opts: AutoCompleteOptionsReq<A> = {
1174 maxPerPage: 10,
1175 filterLabel: "filter",
1176 filterPlaceholder: "type to filter",
1177 emptyMessage: "No matches",
1178 ...options
1179 }
1180 const initialIndex = getSelectInitialIndex(opts.choices)
1181 const filtered = filterAutoCompleteChoices(opts.choices, "")
1182 const index = filtered.length === 0
1183 ? 0
1184 : filtered.includes(initialIndex)
1185 ? initialIndex
1186 : filtered[0]
1187 const initialState: AutoCompleteState = {
1188 query: "",
1189 index,
1190 filtered
1191 }
1192 return custom(initialState, {
1193 render: handleAutoCompleteRender(opts),
1194 process: handleAutoCompleteProcess(opts),
1195 clear: handleAutoCompleteClear(opts)
1196 })
1197}
1198
1199/**
1200 * 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