use zfish::{Color, Prompt, Style};
fn main() {
println!(
"{}\n",
Color::Cyan
.paint("=== Interactive Prompts Demo ===")
.style(Style::Bold)
);
println!("Example 1: Text Input");
if let Ok(name) = Prompt::input("What is your name? ") {
println!("Hello, {}!\n", Color::Green.paint(&name).style(Style::Bold));
}
println!("Example 2: Confirmation");
if let Ok(confirmed) = Prompt::confirm("Do you like Rust? ", true) {
if confirmed {
println!("{}\n", Color::Green.paint("Great choice! 🦀"));
} else {
println!("{}\n", Color::Yellow.paint("That's okay, give it time!"));
}
}
println!("Example 3: Simple Text Input");
if let Ok(lang) = Prompt::text("Favorite language? ") {
println!(
"You chose: {}\n",
Color::Cyan.paint(&lang).style(Style::Bold)
);
}
println!("Example 4: Password Input");
if let Ok(_password) = Prompt::password("Enter password: ") {
println!("{}\n", Color::Green.paint("✓ Password accepted (hidden)"));
}
println!(
"\n{}",
Color::Magenta
.paint("=== Quick Survey ===")
.style(Style::Bold)
);
if let Ok(email) = Prompt::input("Email address: ")
&& let Ok(age) = Prompt::input("Age: ")
&& let Ok(subscribe) = Prompt::confirm("Subscribe to newsletter? ", false)
{
println!(
"\n{}",
Color::Green
.paint("=== Survey Results ===")
.style(Style::Bold)
);
println!("Email: {}", email);
println!("Age: {}", age);
println!("Newsletter: {}", if subscribe { "Yes" } else { "No" });
println!("\n{}", Color::Green.paint("✓ Thank you!"));
}
}