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

Function MultiSelect

packages/effect/src/cli/Prompt.ts:1384–1405  ·  view source on GitHub ↗
(
  options: SelectOptions<A> & MultiSelectOptions
)

Source from the content-addressed store, hash-verified

1382 * @since 4.0.0
1383 */
1384export const MultiSelect = <const A>(
1385 options: SelectOptions<A> & MultiSelectOptions
1386): Prompt<Array<A>> => {
1387 const opts: SelectOptionsReq<A> & MultiSelectOptionsReq = {
1388 maxPerPage: 10,
1389 ...options
1390 }
1391 // Seed initial selection from choices marked as selected: true
1392 const initialSelected = new Set<number>()
1393 for (let i = 0; i < opts.choices.length; i++) {
1394 const choice = opts.choices[i] as SelectChoice<A>
1395 if (choice.selected === true && !choice.disabled) {
1396 initialSelected.add(i)
1397 }
1398 }
1399 const initialState: MultiSelectState = { index: 0, selectedIndices: initialSelected, error: Option.none() }
1400 return Custom(initialState, {
1401 render: handleMultiSelectRender(opts),
1402 process: handleMultiSelectProcess(opts),
1403 clear: handleMultiSelectClear(opts)
1404 })
1405}
1406
1407/**
1408 * Creates a `Prompt` which immediately succeeds with the specified value.

Callers

nothing calls this directly

Calls 5

handleMultiSelectRenderFunction · 0.85
handleMultiSelectProcessFunction · 0.85
handleMultiSelectClearFunction · 0.85
CustomFunction · 0.70
addMethod · 0.65

Tested by

no test coverage detected