From 8d93464d87a222905f881fe15819c3fe3ffbfa38 Mon Sep 17 00:00:00 2001 From: Michal Date: Sat, 23 Jul 2022 18:03:12 +0100 Subject: [PATCH] Buncha clippy stuff --- src/main.rs | 1 - src/operations/build.rs | 16 ++++++++-------- src/operations/config.rs | 4 ++-- src/operations/info.rs | 6 +++--- src/operations/prune.rs | 6 +++--- src/repository/config.rs | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index dec2ad9..1779884 100755 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,6 @@ use std::process::Command; use crate::args::{Args, Operation}; use crate::internal::AppExitCode; -use crate::repository::create_config; use crate::internal::parse_cfg; #[global_allocator] diff --git a/src/operations/build.rs b/src/operations/build.rs index 79679f5..b7bf40d 100644 --- a/src/operations/build.rs +++ b/src/operations/build.rs @@ -37,14 +37,8 @@ pub fn build(packages: &[String], exclude: Vec, no_regen: bool, verbose: if !packages.is_empty() && !all { log!(verbose, "Packages not empty: {:?}", packages); for pkg in packages.iter() { - // If repo is not in config, crash - if !repos.iter().map(|x| x.name.clone()).any(|x| x == *pkg) { - crash!( - AppExitCode::PkgNotFound, - "Package repo {} not found in in mlc.toml", - pkg - ); - } else { + // If repo is not in config, crash, otherwise, build + if repos.iter().map(|x| x.name.clone()).any(|x| x == *pkg) { // Otherwise, build log!(verbose, "Building {}", pkg); let code = repository::build(pkg, sign, verbose); @@ -61,6 +55,12 @@ pub fn build(packages: &[String], exclude: Vec, no_regen: bool, verbose: }; errored.push(error); } + } else { + crash!( + AppExitCode::PkgNotFound, + "Package repo {} not found in in mlc.toml", + pkg + ); } } } diff --git a/src/operations/config.rs b/src/operations/config.rs index ea8f701..3b6a49f 100644 --- a/src/operations/config.rs +++ b/src/operations/config.rs @@ -2,13 +2,13 @@ use std::env; use std::path::Path; use std::process::Command; -use crate::{create_config, log}; +use crate::{repository::create, log}; pub fn config(verbose: bool) { // Generate new config file if not already present if !Path::exists("mlc.toml".as_ref()) { log!(verbose, "Creating mlc.toml"); - create_config(verbose); + create(verbose); } // Open config file in user's editor of choice diff --git a/src/operations/info.rs b/src/operations/info.rs index dadd004..3ad7631 100644 --- a/src/operations/info.rs +++ b/src/operations/info.rs @@ -40,9 +40,7 @@ pub fn info(verbose: bool) { log!(verbose, "Repos Sorted: {:?}", repos); // Displaying basic info about the Malachite Repository - let internal_name = if !config.mode.repository.name.is_empty() { - config.mode.repository.name - } else { + let internal_name = if config.mode.repository.name.is_empty() { env::current_dir() .unwrap() .file_name() @@ -50,6 +48,8 @@ pub fn info(verbose: bool) { .to_str() .unwrap() .to_string() + } else { + config.mode.repository.name }; let name = format!( "{} \"{}\":", diff --git a/src/operations/prune.rs b/src/operations/prune.rs index bca8a97..7c83f75 100644 --- a/src/operations/prune.rs +++ b/src/operations/prune.rs @@ -110,12 +110,12 @@ pub fn prune(verbose: bool) { log!(verbose, "Current dir: {:?}", env::current_dir().unwrap()); // Print which packages were deleted - if !packages_to_delete.is_empty() { + if packages_to_delete.is_empty() { + info!("No packages were deleted."); + } else { info!("Deleted the following packages:"); for p in &mut packages_to_delete { info!("{}-{}", p.name.replace("./", ""), p.ver); } - } else { - info!("No packages were deleted."); } } diff --git a/src/repository/config.rs b/src/repository/config.rs index a442c01..863d837 100644 --- a/src/repository/config.rs +++ b/src/repository/config.rs @@ -39,7 +39,7 @@ urls = [ "" ]"#; -pub fn create_config(verbose: bool) { +pub fn create(verbose: bool) { // Ensure current directory is empty if env::current_dir() .unwrap()