Package: @effect/cli
Module: Prompt
Creates a custom Prompt from the specified initial state and handlers.
The initial state can either be a pure value or an Effect. This is
particularly useful when the initial state of the Prompt must be computed
by performing some effectful computation, such as reading data from the file
system.
A Prompt is essentially a render loop where user input triggers a new frame
to be rendered to the Terminal. The handlers of a custom prompt are used
to control what is rendered to the Terminal each frame. During each frame,
the following occurs:
render handler is called with this frame’s prompt state and prompt
action and returns an ANSI escape string to be rendered to the
TerminalTerminal obtains input from the userprocess handler is called with the input obtained from the user
and this frame’s prompt state and returns the next prompt action that
should be performedclear handler is called with this frame’s prompt state and prompt
action and returns an ANSI escape string used to clear the screen of
the TerminalSignature
declare const custom: <State, Output>(initialState: State | Effect<State, never, Prompt.Environment>, handlers: Prompt.Handlers<State, Output>) => Prompt<Output>
Since v1.0.0