From 6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 4 Sep 2024 11:12:04 +0200 Subject: do nearly anything to shut clippy up --- src/commands/io.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/commands/io.rs') diff --git a/src/commands/io.rs b/src/commands/io.rs index 1d17f7c..c9691c4 100644 --- a/src/commands/io.rs +++ b/src/commands/io.rs @@ -9,7 +9,7 @@ use crate::{ lists_get, lists_get_all_ids, lists_insert, userlist_get_all_ids, userlist_get_current_version, userlist_get_set_version, }, - error::MLE, + error::{EType, MLErr, MLE}, mod_add, AddMod, IDSelector, List, Modloader, STYLE_OPERATION, }; @@ -67,15 +67,26 @@ impl ExportList { } } +/// # Errors +/// # Panics pub fn export(config: &Cfg, list: Option) -> MLE<()> { let progress = ProgressBar::new_spinner(); - progress.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); + progress.set_style( + ProgressStyle::with_template(STYLE_OPERATION) + .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))?, + ); let mut list_ids: Vec = vec![]; if list.is_none() { list_ids = lists_get_all_ids(config)?; } else { - list_ids.push(lists_get(config, &list.unwrap())?.id); + list_ids.push( + lists_get( + config, + &list.ok_or(MLErr::new(EType::Other, "nolist"))?, + )? + .id, + ); } let mut lists: Vec = vec![]; @@ -88,7 +99,7 @@ pub fn export(config: &Cfg, list: Option) -> MLE<()> { let toml = toml::to_string(&Export { lists })?; let filestr = dirs::home_dir() - .unwrap() + .ok_or(MLErr::new(EType::Other, "no home"))? .join("mlexport.toml") .into_os_string() .into_string() @@ -102,6 +113,7 @@ pub fn export(config: &Cfg, list: Option) -> MLE<()> { Ok(()) } +/// # Errors pub async fn import( config: &Cfg, file_str: &str, @@ -117,7 +129,9 @@ pub async fn import( id: exportlist.id, mc_version: exportlist.mc_version, modloader: Modloader::from(&exportlist.launcher)?, - download_folder: exportlist.download_folder.ok_or("NO_DL").unwrap(), + download_folder: exportlist + .download_folder + .ok_or(MLErr::new(EType::Other, "NO_DL"))?, }; lists_insert( config, -- cgit v1.2.3