foundry_common

Macro prompt

Source
macro_rules! prompt {
    () => { ... };
    ($($tt:tt)+) => { ... };
}
Expand description

Prints a message to stdout and reads a line from stdin into a String.

Returns Result<T>, so sometimes T must be explicitly specified, like in str::parse.

ยงExamples

use foundry_common::prompt;

let response: String = prompt!("Would you like to continue? [y/N] ")?;
if !matches!(response.as_str(), "y" | "Y") {
    return Ok(())
}