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

Function runWithInput

packages/effect/src/cli/Prompt.ts:1526–1547  ·  view source on GitHub ↗
(
  prompt: Prompt<Output>,
  terminal: Terminal.Terminal,
  input: Terminal.Terminal["readInput"]
)

Source from the content-addressed store, hash-verified

1524}
1525
1526const runWithInput = <Output>(
1527 prompt: Prompt<Output>,
1528 terminal: Terminal.Terminal,
1529 input: Terminal.Terminal["readInput"]
1530): Effect.Effect<Output, NoSuchElementError, Environment | Scope.Scope> =>
1531 Effect.suspend(() => {
1532 const op = prompt as PromptPrimitive
1533 switch (op._tag) {
1534 case "Loop": {
1535 return Effect.flatMap(input, (queue) => runLoop(op, terminal, queue))
1536 }
1537 case "OnSuccess": {
1538 return Effect.flatMap(
1539 runWithInput(op.prompt, terminal, input),
1540 (a) => runWithInput(op.onSuccess(a), terminal, input)
1541 ) as any
1542 }
1543 case "Succeed": {
1544 return Effect.succeed(op.value)
1545 }
1546 }
1547 })
1548
1549const runLoop = Effect.fnUntraced(
1550 function*(

Callers 1

Prompt.tsFile · 0.85

Calls 1

succeedMethod · 0.45

Tested by

no test coverage detected