From 088cd97b194c3c8001321d19d22604ee3889920d Mon Sep 17 00:00:00 2001 From: Zykino Date: Thu, 19 Jan 2023 23:46:30 +0100 Subject: [PATCH] Simplify "steps" argument --- src/command.rs | 9 +++++---- src/lib.rs | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/command.rs b/src/command.rs index 901ce17..3975f2e 100644 --- a/src/command.rs +++ b/src/command.rs @@ -132,13 +132,14 @@ impl Updater { } fn update(&self, sys: &System, opt: &Opt) -> Result<()> { - let steps = match &opt.steps { - Some(v) => v.iter().map(|u| u.into()).collect(), - None => vec![ + let steps = if opt.steps.is_empty() { + vec![ UpdateSteps::Fetch, UpdateSteps::Compile, UpdateSteps::Install, - ], + ] + } else { + opt.steps.iter().map(|u| u.into()).collect() }; if steps.contains(&UpdateSteps::Fetch) { diff --git a/src/lib.rs b/src/lib.rs index 27f76cb..5c72b97 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,9 +27,10 @@ pub struct Opt { pub yes: bool, #[arg(short, long)] - pub quiet: bool, + pub quiet: bool, // TODO: use clap_verbosity_flag instead + #[arg(short, long)] - pub steps: Option>, + pub steps: Vec, } pub fn run(opt: &Opt) {