How to Read User Input Interactively in Rust (dialoguer)

Cli
Use the dialoguer crate's Input struct to read user input interactively in Rust with minimal boilerplate.

Use the dialoguer crate to prompt the user for input and handle the result with a Result type.

[dependencies]
dialoguer = "0.11"
use dialoguer::Input;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let name: String = Input::new()
        .with_prompt("Enter your name")
        .interact_text()?;

    println!("Hello, {}!", name);
    Ok(())
}