MCPcopy Create free account
hub / github.com/effect-app/libs / runWith

Function runWith

repos/effect/packages/effect/src/unstable/cli/Command.ts:1507–1610  ·  view source on GitHub ↗
(
  command: Command<Name, Input, ContextInput, E, R>,
  config: {
    readonly version: string
  }
)

Source from the content-addressed store, hash-verified

1505 )))
1506
1507/**
1508 * Provides the handler of a command with the service produced by an effect
1509 * that optionally depends on the command-line input to be created.
1510 *
1511 * **When to use**
1512 *
1513 * Use to acquire a service effectfully for each command run, optionally using
1514 * parsed command input.
1515 *
1516 * @see {@link provideSync} for synchronous service acquisition
1517 * @see {@link provide} for providing an already-available service
1518 * @see {@link provideEffectDiscard} for running an effect before the handler without providing a service
1519 *
1520 * @category providing services
1521 * @since 4.0.0
1522 */
1523export const provideEffect: {
1524 <I, S, Input, R2, E2>(
1525 service: Context.Key<I, S>,
1526 effect: Effect.Effect<S, E2, R2> | ((input: Input) => Effect.Effect<S, E2, R2>)
1527 ): <const Name extends string, E, R, ContextInput>(
1528 self: Command<Name, Input, ContextInput, E, R>
1529 ) => Command<Name, Input, ContextInput, E | E2, Exclude<R, I> | R2>
1530 <const Name extends string, Input, E, R, ContextInput, I, S, R2, E2>(
1531 self: Command<Name, Input, ContextInput, E, R>,
1532 service: Context.Key<I, S>,
1533 effect: Effect.Effect<S, E2, R2> | ((input: Input) => Effect.Effect<S, E2, R2>)
1534 ): Command<Name, Input, ContextInput, E | E2, Exclude<R, I> | R2>
1535} = dual(3, <const Name extends string, Input, E, R, ContextInput, I, S, R2, E2>(
1536 self: Command<Name, Input, ContextInput, E, R>,
1537 service: Context.Key<I, S>,
1538 effect: Effect.Effect<S, E2, R2> | ((input: Input) => Effect.Effect<S, E2, R2>)
1539) =>
1540 mapHandler(
1541 self,
1542 (handler, input) =>
1543 Effect.provideServiceEffect(handler, service, typeof effect === "function" ? effect(input) : effect)
1544 ))
1545
1546/**
1547 * Allows for execution of an effect, which optionally depends on command-line
1548 * input to be created, prior to executing the handler of a command.
1549 *
1550 * @category providing services
1551 * @since 4.0.0
1552 */
1553export const provideEffectDiscard: {
1554 <_, Input, E2, R2>(
1555 effect: Effect.Effect<_, E2, R2> | ((input: Input) => Effect.Effect<_, E2, R2>)
1556 ): <const Name extends string, E, R, ContextInput>(
1557 self: Command<Name, Input, ContextInput, E, R>
1558 ) => Command<Name, Input, ContextInput, E | E2, R | R2>
1559 <const Name extends string, Input, E, R, ContextInput, _, E2, R2>(
1560 self: Command<Name, Input, ContextInput, E, R>,
1561 effect: Effect.Effect<_, E2, R2> | ((input: Input) => Effect.Effect<_, E2, R2>)
1562 ): Command<Name, Input, ContextInput, E | E2, R | R2>
1563} = dual(2, <const Name extends string, Input, E, R, ContextInput, _, E2, R2>(
1564 self: Command<Name, Input, ContextInput, E, R>,

Callers 2

Channel.tsFile · 0.85
Command.tsFile · 0.85

Calls 14

toImplFunction · 0.90
showHelpFunction · 0.85
filterMethod · 0.80
someMethod · 0.80
parseMethod · 0.80
resultMethod · 0.65
handleMethod · 0.65
makeMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…