Expand description
§Prompt input
Reads the answer to an interactive prompt (the setup wizard, a token selection) from stdin, so that a cancel can stop the read.
In the TUI, a suspend-mode command reads its prompts on the plain
terminal. Ctrl-C there must cancel the command and return to the TUI. A
blocking read_line cannot be stopped, and a read on another thread
would stay behind and take the TUI’s next keys. So the reader waits for
input in short steps and checks CANCEL between them. It reads one
byte at a time, so it never takes bytes after the newline.
On Windows the console edits the line itself and hands it over whole,
so the reader calls ReadConsoleW and waits for the line. Ctrl-C makes
that read return empty with ERROR_OPERATION_ABORTED (std retries
then, so a read_line would keep waiting); the reader takes it as the
cancel.
Outside the TUI nothing sets CANCEL, and the reader acts as
read_line does.
Every prompt goes through ask (or pick, for a numbered list).
It pauses the progress bars, so a spinner never draws over a question.
A question, a list to pick from and the text around a prompt are not
data: they go to the diagnostic channel of the Output. So piped
data stays clean, and a TUI run keeps only data for Ctrl-Y and save.
Functions§
- ask_
stdin askon stdin (cancellable in the TUI). Thescopebinary’s own prompts use it.- ask_
timeout askon stdin that waits at mosttimeoutfor the answer. ReturnsNonewhen no answer came in time.