Simplify "steps" argument

This commit is contained in:
Zykino 2023-01-19 23:46:30 +01:00
parent 088eb42521
commit 088cd97b19
2 changed files with 8 additions and 6 deletions

View File

@ -132,13 +132,14 @@ impl Updater {
} }
fn update(&self, sys: &System, opt: &Opt) -> Result<()> { fn update(&self, sys: &System, opt: &Opt) -> Result<()> {
let steps = match &opt.steps { let steps = if opt.steps.is_empty() {
Some(v) => v.iter().map(|u| u.into()).collect(), vec![
None => vec![
UpdateSteps::Fetch, UpdateSteps::Fetch,
UpdateSteps::Compile, UpdateSteps::Compile,
UpdateSteps::Install, UpdateSteps::Install,
], ]
} else {
opt.steps.iter().map(|u| u.into()).collect()
}; };
if steps.contains(&UpdateSteps::Fetch) { if steps.contains(&UpdateSteps::Fetch) {

View File

@ -27,9 +27,10 @@ pub struct Opt {
pub yes: bool, pub yes: bool,
#[arg(short, long)] #[arg(short, long)]
pub quiet: bool, pub quiet: bool, // TODO: use clap_verbosity_flag instead
#[arg(short, long)] #[arg(short, long)]
pub steps: Option<Vec<String>>, pub steps: Vec<String>,
} }
pub fn run(opt: &Opt) { pub fn run(opt: &Opt) {