get_string

Function get_string 

Source
pub fn get_string(
    prompt: Option<&str>,
    repeat_message: Option<&str>,
    max_length: Option<i32>,
    can_be_empty: bool,
) -> String
Expand description

Prompts the user for a string input and returns it.

§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 input
  • max_length - An option that can contain a integer which specifies the maximum length the user’s input can reach.
  • can_be_empty - A boolean which denotes whether the user’s input can be an empty string.

§Example

use simple_cli::*;
let input = get_string(Some("Enter your name:"), Some("Enter your name:"), Some(25), false);