From c7ecf3019a75dc0ab1a0aefeb9b880899fc8a231 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 29 May 2023 18:01:12 +0200 Subject: cargo fmt and add fmt file --- src/commands/modification.rs | 55 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 12 deletions(-) (limited to 'src/commands/modification.rs') diff --git a/src/commands/modification.rs b/src/commands/modification.rs index 577bbd1..4488b70 100644 --- a/src/commands/modification.rs +++ b/src/commands/modification.rs @@ -5,12 +5,16 @@ use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use crate::{ config::Cfg, db::{ - lists_get_all_ids, mods_get_id, mods_get_info, mods_insert, mods_remove, - userlist_get_all_ids, userlist_get_current_version, userlist_insert, userlist_remove, + lists_get_all_ids, mods_get_id, mods_get_info, mods_insert, + mods_remove, userlist_get_all_ids, userlist_get_current_version, + userlist_insert, userlist_remove, }, error::{ErrorType, MLError, MLE}, files::{delete_version, download_versions}, - modrinth::{extract_current_version, get_raw_versions, project, projects, versions, Version}, + modrinth::{ + extract_current_version, get_raw_versions, project, projects, versions, + Version, + }, List, PROGRESS_CHARS, STYLE_BAR_POS, STYLE_OPERATION, }; @@ -60,7 +64,9 @@ pub async fn mod_add( for m in mods { add_p.inc(1); match m.id { - IDSelector::ModificationID(pid) => mod_ids.push((pid, m.set_version)), + IDSelector::ModificationID(pid) => { + mod_ids.push((pid, m.set_version)) + } IDSelector::VersionID(vid) => ver_ids.push((vid, m.set_version)), } } @@ -69,7 +75,8 @@ pub async fn mod_add( let mut projectinfo: Vec = Vec::new(); if !mod_ids.is_empty() { - projectinfo.append(&mut get_mod_infos(config, mod_ids, list.clone()).await?); + projectinfo + .append(&mut get_mod_infos(config, mod_ids, list.clone()).await?); }; if !ver_ids.is_empty() { projectinfo.append(&mut get_ver_info(config, ver_ids).await?); @@ -113,7 +120,10 @@ pub async fn mod_add( project.set_version, ) { Err(e) => { - let expected_err = format!("SQL: UNIQUE constraint failed: {}.mod_id", list.id); + let expected_err = format!( + "SQL: UNIQUE constraint failed: {}.mod_id", + list.id + ); if e.to_string() == expected_err { Err(MLError::new( ErrorType::ModError, @@ -126,7 +136,12 @@ pub async fn mod_add( Ok(..) => Ok(..), }?; - match mods_insert(config, &project.mod_id, &project.slug, &project.title) { + match mods_insert( + config, + &project.mod_id, + &project.slug, + &project.title, + ) { Err(e) => { if e.to_string() == "SQL: UNIQUE constraint failed: mods.id" { Ok(..) @@ -149,7 +164,14 @@ pub async fn mod_add( //Download all the added mods if direct_download { add_p.set_message("Download mods"); - download_versions(list.clone(), config.clone(), downloadstack, &mp, &add_p).await?; + download_versions( + list.clone(), + config.clone(), + downloadstack, + &mp, + &add_p, + ) + .await?; }; add_p.finish_with_message("Added all mods"); @@ -191,7 +213,8 @@ async fn get_mod_infos( let current_version: Option; let file: String; if !available_versions.is_empty() { - let current_id = extract_current_version(available_versions.clone())?; + let current_id = + extract_current_version(available_versions.clone())?; current_version = Some( available_versions @@ -242,7 +265,10 @@ async fn get_mod_infos( Ok(projectinfo) } -async fn get_ver_info(config: &Cfg, ver_ids: Vec<(String, bool)>) -> MLE> { +async fn get_ver_info( + config: &Cfg, + ver_ids: Vec<(String, bool)>, +) -> MLE> { let mut setmap: HashMap = HashMap::new(); let mut ids = vec![]; @@ -311,7 +337,9 @@ pub fn mod_remove(config: &Cfg, id: &str, list: &List) -> MLE<()> { match delete_version(list, version) { Ok(_) => (), Err(err) => { - if err.to_string() != "User input not accepted: VERSION_NOT_FOUND_IN_FILES" { + if err.to_string() + != "User input not accepted: VERSION_NOT_FOUND_IN_FILES" + { return Err(err); }; } @@ -343,7 +371,10 @@ pub fn mod_remove(config: &Cfg, id: &str, list: &List) -> MLE<()> { mods_remove(config, &mod_id)?; }; - progress.finish_with_message(format!("Removed {} from {}", info.title, list.id)); + progress.finish_with_message(format!( + "Removed {} from {}", + info.title, list.id + )); Ok(()) } -- cgit v1.2.3