expression
Separate explicit consent from noninteractive mode
Noninteractive mode disables questions; it does not grant consent. Keep a distinct explicit confirmation flag. The simulated operation below only decides whether to proceed; it performs no modification. Fixture: Expected stdout (not executed): refuse ask approved Expected stderr: (empty) Expected exit: 0 Common mistake: Interpreting --non-interactive as --yes.
Formal Syntax & Structure
rust syntaxrust
match (yes, interactive) { ... }Working Example
Example Snippetrust
fn main() { fn decision(yes: bool, interactive: bool) -> &'static str { match (yes, interactive) { (true, _) => "approved", (false, true) => "ask", (false, false) => "refuse", } } for pair in [(false, false), (false, true), (true, false)] { println!("{}", decision(pair.0, pair.1)); }}