pub fn select_number_from_choices<T: PartialOrd + Display + FromStr + Copy>(
prompt: Option<&str>,
repeat_message: Option<&str>,
choices: Vec<T>,
show_choices_on_failure: bool,
) -> TExpand description
Prompts the user to input a number from a selection of number choices, and returns the number the user selected. Panics if there are no numbers in the vector passed into the function.
§Arguments
prompt- An option that can contain a string slice which holds the prompt to present the user with.repeat_message- An option that can contain a string slice which holds a repeat message which will be displayed if the user enters invalid inputchoices- A vector of numbers of type T which make up the choices the user can select from.show_choices_on_failure- Whether or not to show the available choices after invalid input.
§Example
use simple_cli::*;
let choices: Vec<i8> = vec![1,2,3];
let choice = select_number_from_choices::<i8>(Some("Enter 1, 2 or 3"), None, choices, true);