Crates.io | asky |
lib.rs | asky |
version | 0.1.1 |
source | src |
created_at | 2023-04-05 08:43:24.975925 |
updated_at | 2023-04-05 09:11:02.447616 |
description | Libray to create good looking prompts in the terminal |
homepage | |
repository | https://github.com/axelvc/asky/ |
max_upload_size | |
id | 830848 |
size | 421,221 |
Ansi + ask + yes = Asky
Good looking prompts for the terminal.
First of all, this is a library, so you need to add this to your project
cargo add asky
Then, you can see the documentation.
use asky::Confirm;
fn main() -> std::io::Result<()> {
if Confirm::new("Do you like coffe?").prompt()? {
println!("Great, me too!");
}
// ...
Ok(())
}
use asky::Toggle;
fn main() -> std::io::Result<()> {
let tabs = Toggle::new("Which is better?", ["Tabs", "Spaces"]).prompt()?;
println!("Great choice");
// ...
Ok(())
}
use asky::Text;
fn main() -> std::io::Result<()> {
let color = Text::new("What's your favorite color?").prompt()?;
println!("{color} is a beautiful color");
// ...
Ok(())
}
use asky::Number;
fn main() -> std::io::Result<()> {
let age: = Number::<u8>::new("How old are you?").prompt()?;
if let Ok(age) = Number::<u8>::new("How old are you?").prompt()? {
if age <= 60 {
println!("Pretty young");
}
}
// ...
Ok(())
}
use asky::Password;
fn main() -> std::io::Result<()> {
let password = Password::new("What's your IG password?").prompt()?;
if password.len() >= 1 {
println!("Ultra secure!");
}
// ...
Ok(())
}
use asky::Select;
fn main() -> std::io::Result<()> {
let choice = Select::new("Choose number", 1..=30).prompt()?;
println!("{choice}, Interesting choice");
// ...
Ok(())
}
use asky::MultiSelect;
fn main() -> std::io::Result<()> {
let opts = ["Dog", "Cat", "Fish", "Bird", "Other"];
let choices = MultiSelect::new("What kind of pets do you have?", opts).prompt()?;
if choices.len() > 2 {
println!("So you love pets");
}
// ...
Ok(())
}
Inspired by:
Alternatives:
License: MIT