Function simple_cli::select_string_from_choices
source · pub fn select_string_from_choices(
prompt: Option<&str>,
repeat_message: Option<&str>,
choices: Vec<&str>,
case_sensitive: bool,
show_choices_on_failure: bool
) -> String
Expand description
Prompts the user to input a string from a selection of string choices, and returns the string the user selected. Panics if there are no strings in the choices 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 string slices which make up the choices the user can select from.case_sensitive
- A boolean which represents whether the user’s input is case-sensitive.show_choices_on_failure
- Whether or not to show the available choices after invalid input.
Example
use simple_cli::*;
let choices = vec!["Moe", "Larry", "Curly"];
let choice = select_string_from_choices(Some("Select Moe, Larry, or Curly"), None, choices, false, true);