[go: up one dir, main page]

prompt_yes

Macro prompt_yes 

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

Prompt the user with a formatted string and returns true if they reply 'y' or 'Y'

This macro functions accepts the same syntax as format!. The prompt is written to stderr. A space is also printed at the end for nice spacing between the prompt and the user input. Any input starting with 'y' or 'Y' is interpreted as yes.

ยงExamples

use uucore::prompt_yes;
let file = "foo.rs";
prompt_yes!("Do you want to delete '{file}'?");

will print something like below to stderr (with util_name substituted by the actual util name) and will wait for user input.

util_name: Do you want to delete 'foo.rs'?