Minor Changes
-
#3153
51bb7d5
Thanks @IMax153! - Refactors thePrompt.custom
constructor to make it easier to create custom
Prompt
s.The
Prompt.custom
constructor allows for creation of a customPrompt
from
the provided initial state and handlers.export const custom: <State, Output>( initialState: State | Effect<State, never, Prompt.Environment>, handlers: { readonly render: ( state: State, action: Action<State, Output>, ) => Effect<string, never, Environment>; readonly process: ( input: UserInput, state: State, ) => Effect<Action<State, Output>, never, Environment>; readonly clear: ( state: State, action: Action<State, Output>, ) => Effect<string, never, Environment>; }, ) => Prompt<Output> = InternalPrompt.custom;
The initial state of a
Prompt
can either be a pure value or anEffect
. This
is particularly useful when the initial state of thePrompt
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 theTerminal
. Thehandlers
of a custom prompt are used
to control what is rendered to theTerminal
each frame. During each frame,
the following occurs:- The
render
handler is called with this frame's prompt state and prompt
action and returns an ANSI escape string to be rendered to the
Terminal
- The
Terminal
obtains input from the user - The
process
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 performed - The
clear
handler is called with this frame's prompt state and prompt
action and returns an ANSI escape string used to clear the screen of
theTerminal
- The
-
#3153
51bb7d5
Thanks @IMax153! - Utilize thePrompt.file
constructor in Effect CLI's wizard mode for file and directoryOptions
-
#3153
51bb7d5
Thanks @IMax153! - Adds aPrompt.file
constructor to thePrompt
module which allows the user to select a file