Buncha clippy stuff

main
Michal 2 years ago
parent f6f7656caa
commit 8d93464d87
No known key found for this signature in database
GPG Key ID: A6A1A4DCB22279B9

@ -11,7 +11,6 @@ use std::process::Command;
use crate::args::{Args, Operation}; use crate::args::{Args, Operation};
use crate::internal::AppExitCode; use crate::internal::AppExitCode;
use crate::repository::create_config;
use crate::internal::parse_cfg; use crate::internal::parse_cfg;
#[global_allocator] #[global_allocator]

@ -37,14 +37,8 @@ pub fn build(packages: &[String], exclude: Vec<String>, no_regen: bool, verbose:
if !packages.is_empty() && !all { if !packages.is_empty() && !all {
log!(verbose, "Packages not empty: {:?}", packages); log!(verbose, "Packages not empty: {:?}", packages);
for pkg in packages.iter() { for pkg in packages.iter() {
// If repo is not in config, crash // If repo is not in config, crash, otherwise, build
if !repos.iter().map(|x| x.name.clone()).any(|x| x == *pkg) { 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 {
// Otherwise, build // Otherwise, build
log!(verbose, "Building {}", pkg); log!(verbose, "Building {}", pkg);
let code = repository::build(pkg, sign, verbose); let code = repository::build(pkg, sign, verbose);
@ -61,6 +55,12 @@ pub fn build(packages: &[String], exclude: Vec<String>, no_regen: bool, verbose:
}; };
errored.push(error); errored.push(error);
} }
} else {
crash!(
AppExitCode::PkgNotFound,
"Package repo {} not found in in mlc.toml",
pkg
);
} }
} }
} }

@ -2,13 +2,13 @@ use std::env;
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process::Command;
use crate::{create_config, log}; use crate::{repository::create, log};
pub fn config(verbose: bool) { pub fn config(verbose: bool) {
// Generate new config file if not already present // Generate new config file if not already present
if !Path::exists("mlc.toml".as_ref()) { if !Path::exists("mlc.toml".as_ref()) {
log!(verbose, "Creating mlc.toml"); log!(verbose, "Creating mlc.toml");
create_config(verbose); create(verbose);
} }
// Open config file in user's editor of choice // Open config file in user's editor of choice

@ -40,9 +40,7 @@ pub fn info(verbose: bool) {
log!(verbose, "Repos Sorted: {:?}", repos); log!(verbose, "Repos Sorted: {:?}", repos);
// Displaying basic info about the Malachite Repository // Displaying basic info about the Malachite Repository
let internal_name = if !config.mode.repository.name.is_empty() { let internal_name = if config.mode.repository.name.is_empty() {
config.mode.repository.name
} else {
env::current_dir() env::current_dir()
.unwrap() .unwrap()
.file_name() .file_name()
@ -50,6 +48,8 @@ pub fn info(verbose: bool) {
.to_str() .to_str()
.unwrap() .unwrap()
.to_string() .to_string()
} else {
config.mode.repository.name
}; };
let name = format!( let name = format!(
"{} \"{}\":", "{} \"{}\":",

@ -110,12 +110,12 @@ pub fn prune(verbose: bool) {
log!(verbose, "Current dir: {:?}", env::current_dir().unwrap()); log!(verbose, "Current dir: {:?}", env::current_dir().unwrap());
// Print which packages were deleted // 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:"); info!("Deleted the following packages:");
for p in &mut packages_to_delete { for p in &mut packages_to_delete {
info!("{}-{}", p.name.replace("./", ""), p.ver); info!("{}-{}", p.name.replace("./", ""), p.ver);
} }
} else {
info!("No packages were deleted.");
} }
} }

@ -39,7 +39,7 @@ urls = [
"" ""
]"#; ]"#;
pub fn create_config(verbose: bool) { pub fn create(verbose: bool) {
// Ensure current directory is empty // Ensure current directory is empty
if env::current_dir() if env::current_dir()
.unwrap() .unwrap()

Loading…
Cancel
Save