Runs code that asks questions against a list of keys, with no terminal.
{answers, transcript} =
Drafter.Prompt.Script.run(["ada", :enter, :down, :enter], fn ->
{:ok, name} = Drafter.Prompt.text("Name")
{:ok, kind} = Drafter.Prompt.select("Kind", ["App", "Library"])
{name, kind}
end)
answers
#=> {"ada", "Library"}
transcript
#=> "✔ Name · ada\n✔ Kind · Library\n"Inputs
Each input is one of:
- a string, typed one character at a time;
"\r"is Enter and"\t"is Tab - an atom naming a key, such as
:enter,:down,:tab,:escapeor:backspace;:spaceis the space bar - an event as
Drafter.Terminal.ANSIdecodes it, such as{:key, :c, [:ctrl]}
A prompt that is still waiting when the inputs run out returns {:error, :eof}.
The transcript holds the line each prompt left on screen, what
Drafter.Prompt.say/2 wrote, and what was written during a spinner or progress
bar, in order and without styling.
Options
:size-{columns, rows}reported to prompts. Default{80, 24}.
Summary
Functions
Call fun with inputs standing in for the keyboard.
Types
@type input() :: String.t() | atom() | Drafter.Prompt.Terminal.event()