Import std.term.prompts
std.term.prompts
std.term's prompts: Confirm asks yes or no, Choose for one of some options, and Ask for a line of text, on the console or on a Terminal given. Where both what's written and the keys are a terminal's, keys are read as they're typed: Confirm takes y or n at once, Choose moves through its options with the arrows, and typing filters them, by fuzzy matching, and Ask edits its line as a shell does. Otherwise, as from a pipe or a file, each reads a line, which it writes after its question, and asks again for one it can't take. Each gives Null at the end of the input, and for Escape.
std/term/prompts.fb
Functions
Confirm
function
Public Function Confirm(question: String, default: Bool? = Null): Bool?
Asks question on the console, and gives True for yes or False for no, or default for ENTER
alone, when it has one.
Confirm
function
Public Function Confirm(terminal: Terminal, question: String, default: Bool? = Null): Bool?
Asks question on terminal, and gives True for yes or False for no, or default for ENTER
alone, when it has one: a key, y or n in either case, where it's interactive, and a line
otherwise, "y", "yes", "n", or "no", in any case.
Ask
function
Public Function Ask(question: String, default: String = ""): String?
Asks question on the console, and gives what's typed, or default for nothing.
Ask
function
Public Function Ask(question: String, validate: Func(String): String?, default: String = ""): String?
Asks question on the console, and gives what's typed, or default for nothing, once
validate gives Null for it; until then, what it gives says what's wrong, and the question
goes on.
Ask
function
Public Function Ask(terminal: Terminal, question: String, default: String = ""): String?
Asks question on terminal, and gives what's typed, or default for nothing.
Ask
function
Public Function Ask(terminal: Terminal, question: String, validate: Func(String): String?, default: String = ""): String?
Asks question on terminal, and gives what's typed, or default for nothing, once validate
gives Null for it; until then, what it gives says what's wrong, and the question goes on.
Choose
function
@PanicsAtCaller Public Function Choose(question: String, options: String[], default: Int = 0): Int?
Asks question on the console, and gives one of options, by its index, from default's at
first, or Null for Escape. Panics without an option.
Choose
function
@PanicsAtCaller Public Function Choose(terminal: Terminal, question: String, options: String[], default: Int = 0): Int?
Asks question on terminal, and gives one of options, by its index: where it's interactive,
the one selected with the arrows, from default's, at ENTER, among those that match what's
typed, by fuzzy matching, the best first; otherwise, a number from 1, or default's for none.
Panics without an option.
Report an issue with this page or with FutureBlitz on GitHub.