[][src]Crate promptly

Simply call prompt, prompt_default, or prompt_opt to prompt for any Promptable type:

Examples

use promptly::{prompt, prompt_opt, prompt_default};

// Prompt until a non-empty string is provided
let name: String = prompt("Enter your name")?;

// Prompt for other `FromStr` types
let age: u32 = prompt("Enter your age")?;

// Prompt for optional paths with path completion. Returns `None` if empty input.
let photo: Option<PathBuf> = prompt_opt("Enter a path to a profile picture")?;

// Prompt Y/n with a default value when input is empty
let fallback = prompt_default("Would you like to receive marketing emails", true)?;

Enums

ReadlineError

The error type for Rustyline errors that can arise from I/O related errors or Errno when using the nix-rust library

Traits

Promptable

A trait for convenient, opinionated prompting

Functions

prompt

Prompt until input can be parsed as T.

prompt_default

Prompt until input can be parsed as T, returning the default for empty input.

prompt_opt

Prompt until input can be parsed as T, returning None for empty input.