Crate promptly[−][src]
Simply call prompt
or prompt_default
to prompt for any Promptable
type:
Examples
use promptly::{prompt, 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("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);
Errors
If readline fails to read from stdin, this call will exit the process with an exit code of 1
.
All other errors just result in re-prompting.
Structs
Prompter |
Optinionated wrapper around rustyline to prompt for strings |
Traits
Promptable |
A trait for convenient, opinionated prompting |
Functions
prompt |
Prompt until input can be parsed as |
prompt_default |
Prompt until input can be parsed as |