From 775e92c52e8f4ddce544c4da32d251a1bb403ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Wed, 8 Dec 2021 00:26:05 -0300 Subject: [PATCH] Add redundant check for --yes and --no flags conflict Should be covered by clap, but we're double checking it now --- src/cli.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index bef64db61..298818167 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -33,12 +33,11 @@ impl Opts { | Subcommand::List { archives: files, .. }) = &mut opts.cmd; *files = canonicalize_files(files)?; - let skip_questions_positively = if opts.yes { - QuestionPolicy::AlwaysYes - } else if opts.no { - QuestionPolicy::AlwaysNo - } else { - QuestionPolicy::Ask + let skip_questions_positively = match (opts.yes, opts.no) { + (false, false) => QuestionPolicy::Ask, + (true, false) => QuestionPolicy::AlwaysYes, + (false, true) => QuestionPolicy::AlwaysNo, + (true, true) => unreachable!(), }; Ok((opts, skip_questions_positively))