#interactive-prompt #interactive-cli #prompt #console #cli

dsplce-co-promptuity

This is a fork of https://crates.io/crates/promptuity, go to the original repository if you want to use as a dep

1 unstable release

0.0.5-supabase-plus-0.8 Nov 16, 2025

#859 in Command-line interface

Download history 57/week @ 2025-11-23

57 downloads per month
Used in supabase-plus

MIT license

1.5MB
3K SLoC

This is a fork of promptuity for purposes of dsplce.co's projects. If you want to use promptuity as a dependency, you should probably go to the original repository.


lib.rs:

Promptuity

Promptuity is a library that provides interactive prompts. It is highly extensible, allowing you to build your original prompts from scratch. It brings ingenuity to various projects.

Concept

  • Not easy, But simple
    • Avoids APIs with implicit behavior, aiming to provide as transparent APIs as possible.
    • The amount of code required to start a prompt may be more compared to other libraries.
  • Extensible
    • You can customize built-in prompts or build your prompts from scratch.
    • The built-in prompts are minimal, assuming that prompt requirements vary by project.
  • Beautiful
    • Offers two types of built-in Themes.
    • Themes can also be fully customized to fit your ideal.

Quick Start

The basic usage is as follows.

use promptuity::prompts::{Confirm, Input, Select, SelectOption};
use promptuity::themes::FancyTheme;
use promptuity::{Error, Promptuity, Term};

fn main() -> Result<(), Error> {
    let mut term = Term::default();
    let mut theme = FancyTheme::default();
    let mut p = Promptuity::new(&mut term, &mut theme);

    p.term().clear()?;

    p.with_intro("Survey").begin()?;

    let name = p.prompt(Input::new("Please enter your username").with_placeholder("username"))?;

    let _ = p.prompt(Confirm::new("Are you a full-time software developer?").with_default(true))?;

    let _ = p.prompt(
        Select::new(
            "Select your primary programming language",
            vec![
                SelectOption::new("Rust", "rust"),
                SelectOption::new("Go", "go"),
                SelectOption::new("C++", "cpp"),
                SelectOption::new("C", "c"),
                SelectOption::new("TypeScript", "typescript"),
                SelectOption::new("JavaScript", "javascript"),
                SelectOption::new("Deno", "deno"),
                SelectOption::new("Python", "python"),
                SelectOption::new("Java", "java"),
                SelectOption::new("Dart", "dart"),
                SelectOption::new("Other", "other"),
            ],
        )
        .with_hint("Submit with Space or Enter."),
    )?;

    p.with_outro(format!("Thank you for your response, {}!", name))
        .finish()?;

    Ok(())
}

Error Handling

All errors are consolidated into promptuity::Error.

In many cases, prompt interruptions will need to be handled individually. Interruptions occur during user input reception, typically through inputs like Ctrl + C or ESC.

use promptuity::prompts::Input;
use promptuity::themes::MinimalTheme;
use promptuity::{Error, Promptuity, Term};

fn ask() -> Result<String, Error> {
    let mut term = Term::default();
    let mut theme = MinimalTheme::default();
    let mut p = Promptuity::new(&mut term, &mut theme);

    p.begin()?;
    let name = p.prompt(Input::new("Please enter your username").with_placeholder("username"))?;
    p.finish()?;

    Ok(name)
}

fn main() {
    match ask() {
        Ok(name) => println!("Hello, {}!", name),
        Err(Error::Cancel) => {}
        Err(e) => eprintln!("Error: {}", e),
    }
}

Prompt interruptions can be handled as Error::Cancel. In the above examples, no message is displayed in the event of an interruption.

Dependencies

~2.5–3.5MB
~61K SLoC