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

Function runWithInput

packages/effect/src/unstable/cli/Prompt.ts:1348–1369  ·  view source on GitHub ↗
(
  prompt: Prompt<Output>,
  terminal: Terminal.Terminal,
  input: Queue.Dequeue<Terminal.UserInput, Cause.Done>
)

Source from the content-addressed store, hash-verified

1346}
1347
1348const runWithInput = <Output>(
1349 prompt: Prompt<Output>,
1350 terminal: Terminal.Terminal,
1351 input: Queue.Dequeue<Terminal.UserInput, Cause.Done>
1352): Effect.Effect<Output, NoSuchElementError, Environment> =>
1353 Effect.suspend(() => {
1354 const op = prompt as PromptPrimitive
1355 switch (op._tag) {
1356 case "Loop": {
1357 return runLoop(op, terminal, input)
1358 }
1359 case "OnSuccess": {
1360 return Effect.flatMap(
1361 runWithInput(op.prompt, terminal, input),
1362 (a) => runWithInput(op.onSuccess(a), terminal, input)
1363 ) as any
1364 }
1365 case "Succeed": {
1366 return Effect.succeed(op.value)
1367 }
1368 }
1369 })
1370
1371const runLoop = Effect.fnUntraced(
1372 function*(

Callers 1

Prompt.tsFile · 0.85

Calls 2

onSuccessMethod · 0.80
succeedMethod · 0.45

Tested by

no test coverage detected