Import std.term.prompts
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.
Examples
Local terminal = FakeTerminal(interactive: False)
terminal.Feed("2\n")
Expect(Choose(terminal, "Size?", ["small", "medium", "large"]) == 1)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.