Skip to main content

confirm

Function confirm 

Source
pub fn confirm(out: &mut dyn Write, question: &str) -> Result<Option<bool>>
Expand description

Asks a yes/no question, defaulting to no.

Returns None when there is no human to ask — stdin or stdout is not a terminal — so callers can keep their non-interactive behavior (a clear error) instead of blocking a script or an agent forever on a prompt nothing will answer. That distinction is the whole reason this returns an Option rather than a bool.

§Errors

When the prompt cannot be written or stdin cannot be read.