Skip to main content

yesno

Function yesno 

Source
pub fn yesno(
    message: impl Into<String>,
) -> PromptBuilder<bool, DefaultIfCancel, impl FnMut(&mut String) -> Result<bool>>
Available on crate features print and prompt only.
Expand description

Show a Yes/No prompt

Note: Use the cu::yesno! macro if the default configuration is all you need

Return true if the answer is Yes. Return an error if prompt is not allowed.

If -y is specified from the command line, then the prompt will not show, and true will be returned immediately.

If user does not answer y or n, the prompt will show again, until user makes a decision.

if cu::yesno("do you want to continue?").run()? {
    cu::info!("user picked yes");
}