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

Function multiSelect

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

Source from the content-addressed store, hash-verified

1209 * @since 4.0.0
1210 */
1211export const multiSelect = <const A>(
1212 options: SelectOptions<A> & MultiSelectOptions
1213): Prompt<Array<A>> => {
1214 const opts: SelectOptionsReq<A> & MultiSelectOptionsReq = {
1215 maxPerPage: 10,
1216 ...options
1217 }
1218 // Seed initial selection from choices marked as selected: true
1219 const initialSelected = new Set<number>()
1220 for (let i = 0; i < opts.choices.length; i++) {
1221 const choice = opts.choices[i] as SelectChoice<A>
1222 if (choice.selected === true && !choice.disabled) {
1223 initialSelected.add(i)
1224 }
1225 }
1226 const initialState: MultiSelectState = { index: 0, selectedIndices: initialSelected, error: Option.none() }
1227 return custom(initialState, {
1228 render: handleMultiSelectRender(opts),
1229 process: handleMultiSelectProcess(opts),
1230 clear: handleMultiSelectClear(opts)
1231 })
1232}
1233
1234/**
1235 * 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