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

Function file

repos/effect/packages/effect/src/unstable/cli/Prompt.ts:863–900  ·  view source on GitHub ↗
(options: FileOptions = {})

Source from the content-addressed store, hash-verified

861
862/**
863 * Creates a custom `Prompt` from the specified initial state and handlers.
864 *
865 * **Details**
866 *
867 * The initial state can either be a pure value or an `Effect`. This is
868 * particularly useful when the initial state of the `Prompt` must be computed
869 * by performing an effectful computation, such as reading data from the file
870 * system. A `Prompt` runs as a render loop: `render` returns ANSI output for
871 * the current frame, the `Terminal` obtains user input, `process` returns the
872 * next prompt action, and `clear` returns ANSI output used to clear the previous
873 * frame.
874 *
875 * Optionally, an external `events` dequeue can be provided as the third
876 * argument. When present, the render loop will race user input against events
877 * from the dequeue, allowing background events to trigger re-renders without
878 * waiting for a keypress. When an event is received from the dequeue, the
879 * `receive` handler is called instead of `process`.
880 *
881 * @category constructors
882 * @since 4.0.0
883 */
884export const Custom: {
885 <State, Output>(
886 initialState: State | Effect.Effect<State, never, Environment>,
887 handlers: Handlers<State, Output>
888 ): Prompt<Output>
889 <State, Output, A>(
890 initialState: State | Effect.Effect<State, never, Environment>,
891 events: Queue.Dequeue<A, never>,
892 handlers: Handlers<State, Output, ProcessInput<A>>
893 ): Prompt<Output>
894} = <State, Output, A>(
895 initialState: State | Effect.Effect<State, never, Environment>,
896 ...args:
897 | [handlers: Handlers<State, Output, Terminal.UserInput>]
898 | [events: Queue.Dequeue<A, never>, handlers: Handlers<State, Output, ProcessInput<A>>]
899): Prompt<Output> => {
900 const [events, handlers] = args.length === 1
901 ? [undefined, args[0]] as const
902 : [args[0], args[1]] as const
903 const op = Object.create(proto)

Callers

nothing calls this directly

Calls 7

resolveCurrentPathFunction · 0.85
handleFileRenderFunction · 0.85
handleFileProcessFunction · 0.85
handleFileClearFunction · 0.85
customFunction · 0.70
mapMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…