pub fn string_with_default(
text: &str,
def: Option<impl Into<String> + Display>,
) -> QueryResult<String>Expand description
Queries the user for string input with a default.
The user can unset the value by typing a space, otherwise, if no string is specified and a deafult is given the default will be used.
ยงErrors
Fails on io errors with the stdin and stdout.
Examples found in repository?
examples/query.rs (lines 7-10)
3fn main() -> io::Result<()> {
4 let name = uquery::string("What is your name?")?;
5 println!("Hello {}.", name);
6
7 let day = uquery::string_with_default(
8 "What is your favourite day?",
9 Some("Monday"),
10 )?;
11 println!(r#"I see your favourite day is "{}"."#, day);
12
13 let number: usize = uquery::parsable_with_default("Whats your favourite number?", 7)?;
14 println!("Hello {} lover", number);
15
16 let age: u8 = uquery::parsable("How old are you?")?;
17 println!("Hello {} year old.", age);
18
19 let happy = uquery::boolean("Are you happy?", None)?;
20 println!("It is {} that you are happy.", happy);
21
22 Ok(())
23}