asky 0.1.1

Libray to create good looking prompts in the terminal
Documentation
  • Coverage
  • 100%
    58 out of 58 items documented8 out of 8 items with examples
  • Size
  • Source code size: 430.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.12 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 20s Average build duration of successful builds.
  • all releases: 20s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • axelvc/asky
    14 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • axelvc

Asky

Ansi + ask + yes = Asky

Good looking prompts for the terminal.

Usage

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.

Demos

Confirm

Confirm prompt gif demo

use asky::Confirm;

fn main() -> std::io::Result<()> {
    if Confirm::new("Do you like coffe?").prompt()? {
        println!("Great, me too!");
    }

    // ...

    Ok(())
}

Toggle

Toggle prompt gif demo

use asky::Toggle;

fn main() -> std::io::Result<()> {
    let tabs = Toggle::new("Which is better?", ["Tabs", "Spaces"]).prompt()?;
    println!("Great choice");

    // ...

    Ok(())
}

Text

Text prompt gif demo

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(())
}

Number

Number prompt gif demo

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(())
}

Password

Password prompt gif demo

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(())
}

Select

Select prompt gif demo

use asky::Select;

fn main() -> std::io::Result<()> {
    let choice = Select::new("Choose number", 1..=30).prompt()?;
    println!("{choice}, Interesting choice");

    // ...

    Ok(())
}

MultiSelect

Multi select prompt gif demo

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(())
}

Mentions

Inspired by:

  • Prompts - Lightweight, beautiful and user-friendly interactive prompts
  • Astro - All-in-one web framework with a beautiful command line tool
  • Gum - A tool for glamorous shell scripts

Alternatives:

  • Dialoguer - A command line prompting library.
  • Inquire - A library for building interactive prompts on terminals.
  • Requestty - An easy-to-use collection of interactive cli prompts.

License: MIT