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

Function makeCommandWithWrap

packages/cli/src/index.ts:435–472  ·  view source on GitHub ↗
(
        name: Name,
        config: Config,
        handler: (_: any) => Effect.Effect<void, E, R>,
        completionMessage?: string
      )

Source from the content-addressed store, hash-verified

433 * @param completionMessage - Optional message to log when the command completes
434 * @returns A Command with integrated wrap functionality
435 */
436 const makeCommandWithWrap = <Name extends string, const Config, R, E>(
437 name: Name,
438 config: Config,
439 handler: (_: any) => Effect.Effect<void, E, R>,
440 completionMessage?: string
441 ) =>
442 Command.make(
443 name,
444 { ...config, wo: WrapAsOption, wa: WrapAsArg },
445 Effect.fn("effa-cli.withWrapHandler")(function*(_) {
446 const { wa, wo, ...cfg } = _ as unknown as {
447 wo: Option.Option<string>
448 wa: Option.Option<ReadonlyArray<string>>
449 }
450
451 if (completionMessage) {
452 yield* Effect.addFinalizer(() => Effect.logInfo(completionMessage))
453 }
454
455 const wrapOption = Option.orElse(wa, () => wo)
456
457 yield* handler(cfg as any)
458
459 if (Option.isSome(wrapOption)) {
460 const val: string = Array.isArray(wrapOption.value)
461 ? wrapOption.value.join(" ")
462 : wrapOption.value as string
463
464 yield* Effect.logInfo(`Spawning child command: ${val}`)
465 const exitCode = yield* runGetExitCode(val)
466 if (exitCode !== 0) {
467 return yield* Effect.sync(() => process.exit(exitCode))
468 }
469 }
470
471 return
472 }, (_) => Effect.scoped(_))
473 )
474
475 const EffectAppLibsPath = Argument

Callers 1

index.tsFile · 0.85

Calls 6

addFinalizerMethod · 0.80
orElseMethod · 0.80
joinMethod · 0.80
syncMethod · 0.80
makeMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…