Trait promptly::Promptable [−][src]
A trait for convenient, opinionated prompting
Required methods
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
Prompts for a value. Re-prompts on invalid and empty input.
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
Prompts for a value, returning None
for empty input. Re-prompts on invalid input.
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
Prompts for a value with a default value for empty input. Re-prompts on invalid input.
The default value will be mentioned in the prompt message
Implementations on Foreign Types
impl Promptable for String
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
Prompt until you get a non-empty string
use promptly::Promptable; String::prompt("Enter your name")?;
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
Prompt for an optional string
use promptly::Promptable; String::prompt_opt("Enter your phone number (optional)")?;
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
Prompt for a string with a provided fallback value if empty.
use promptly::Promptable; String::prompt_default("Enter your country", "USA".into())?;
Default value is visible in the prompt as: (default=USA)
impl Promptable for char
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for u8
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for u16
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for u32
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for u64
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for u128
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for usize
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for i8
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for i16
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for i32
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for i64
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for i128
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for isize
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for f32
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for f64
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for IpAddr
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for Ipv4Addr
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for Ipv6Addr
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for SocketAddrV4
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for SocketAddrV6
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroI128
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroI64
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroI32
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroI16
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroI8
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroIsize
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroU128
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroU64
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroU32
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroU16
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroU8
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for NonZeroUsize
[src]
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
impl Promptable for PathBuf
[src]
PathBuf prompting will use a path autocompleter
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
Prompt until you get a non-empty path
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
Prompt for an optional path
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
Prompt for a path with a provided fallback value if empty
impl Promptable for bool
[src]
Specialized bool
prompter that supports yes/no (y/n) values
fn prompt<S: AsRef<str>>(msg: S) -> Result<Self, ReadlineError>
[src]
Prompt for bool
represented as true/false
, yes/no
, or y/n
input
The prompt will display the options: (y/n)
use promptly::Promptable; bool::prompt("Do you accept the terms?")?;
fn prompt_opt<S: AsRef<str>>(msg: S) -> Result<Option<Self>, ReadlineError>
[src]
Prompt for optional bool
input. Empty input returns None
.
The prompt will display the options: (y/n)
use promptly::Promptable; bool::prompt_opt("Did you even read this question?")?;
fn prompt_default<S: AsRef<str>>(
msg: S,
default: Self
) -> Result<Self, ReadlineError>
[src]
msg: S,
default: Self
) -> Result<Self, ReadlineError>
Prompt for optional bool
input. Empty input returns None
.
The prompt will also display the options: (Y/n)
or (y/N)
depending on the default
use promptly::Promptable; bool::prompt_default("Would you like to send us money?", true)?;