Flags are often simple booleans, but combining them into a mode string makes behavior easy to report.

Program

Play the program to choose whether verbose mode is enabled.

cli_flag_summary.rs
fn main() {
    let verbose = ;
    let dry_run = true;
    let mode = format_mode(verbose, dry_run);
    println!("{mode}");
}

fn format_mode(verbose: bool, dry_run: bool) -> String {
    match (verbose, dry_run) {
        (true, true) => "verbose dry-run".to_string(),
        (false, true) => "quiet dry-run".to_string(),
        (true, false) => "verbose live".to_string(),
        (false, false) => "quiet live".to_string(),
    }
}
fn main() {
    let verbose = ;
    let dry_run = true;
    let mode = format_mode(verbose, dry_run);
    println!("{mode}");
}

fn format_mode(verbose: bool, dry_run: bool) -> String {
    match (verbose, dry_run) {
        (true, true) => "verbose dry-run".to_string(),
        (false, true) => "quiet dry-run".to_string(),
        (true, false) => "verbose live".to_string(),
        (false, false) => "quiet live".to_string(),
    }
}
flag `verbose` is a boolean flag represented by a normal binding.
mode `format_mode` turns flag combinations into a user-facing summary.
match tuple Matching `(verbose, dry_run)` keeps the mode table explicit.