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

Function handleSelectProcess

packages/effect/src/unstable/cli/Prompt.ts:3394–3421  ·  view source on GitHub ↗
(options: SelectOptionsReq<A>)

Source from the content-addressed store, hash-verified

3392 })
3393
3394const handleSelectProcess = <A>(options: SelectOptionsReq<A>) => {
3395 return (input: Terminal.UserInput, state: SelectState) => {
3396 switch (input.key.name) {
3397 case "k":
3398 case "up": {
3399 return processSelectCursorUp(state, options.choices)
3400 }
3401 case "j":
3402 case "down": {
3403 return processSelectCursorDown(state, options.choices)
3404 }
3405 case "tab": {
3406 return processSelectNext(state, options.choices)
3407 }
3408 case "enter":
3409 case "return": {
3410 const selected = options.choices[state]
3411 if (selected.disabled) {
3412 return Effect.succeed(Action.Beep())
3413 }
3414 return Effect.succeed(Action.Submit({ value: selected.value }))
3415 }
3416 default: {
3417 return Effect.succeed(Action.Beep())
3418 }
3419 }
3420 }
3421}
3422
3423const handleAutoCompleteProcess = <A>(options: AutoCompleteOptionsReq<A>) => {
3424 return (input: Terminal.UserInput, state: AutoCompleteState) => {

Callers 1

selectFunction · 0.85

Calls 4

processSelectCursorUpFunction · 0.85
processSelectCursorDownFunction · 0.85
processSelectNextFunction · 0.85
succeedMethod · 0.45

Tested by

no test coverage detected