summaryrefslogtreecommitdiff
path: root/src/commands/io.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-09-04 11:12:04 +0200
committerfxqnlr <[email protected]>2024-09-04 11:12:04 +0200
commit6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043 (patch)
treeae04cf34582f57699d12ac7b5b486ab065bf8d19 /src/commands/io.rs
parentf5e070cdf6628a5ebd981d373929802317104e24 (diff)
downloadmodlist-6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043.tar
modlist-6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043.tar.gz
modlist-6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043.zip
do nearly anything to shut clippy up
Diffstat (limited to 'src/commands/io.rs')
-rw-r--r--src/commands/io.rs24
1 files changed, 19 insertions, 5 deletions
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::{
9 lists_get, lists_get_all_ids, lists_insert, userlist_get_all_ids, 9 lists_get, lists_get_all_ids, lists_insert, userlist_get_all_ids,
10 userlist_get_current_version, userlist_get_set_version, 10 userlist_get_current_version, userlist_get_set_version,
11 }, 11 },
12 error::MLE, 12 error::{EType, MLErr, MLE},
13 mod_add, AddMod, IDSelector, List, Modloader, STYLE_OPERATION, 13 mod_add, AddMod, IDSelector, List, Modloader, STYLE_OPERATION,
14}; 14};
15 15
@@ -67,15 +67,26 @@ impl ExportList {
67 } 67 }
68} 68}
69 69
70/// # Errors
71/// # Panics
70pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> { 72pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> {
71 let progress = ProgressBar::new_spinner(); 73 let progress = ProgressBar::new_spinner();
72 progress.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 74 progress.set_style(
75 ProgressStyle::with_template(STYLE_OPERATION)
76 .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))?,
77 );
73 78
74 let mut list_ids: Vec<String> = vec![]; 79 let mut list_ids: Vec<String> = vec![];
75 if list.is_none() { 80 if list.is_none() {
76 list_ids = lists_get_all_ids(config)?; 81 list_ids = lists_get_all_ids(config)?;
77 } else { 82 } else {
78 list_ids.push(lists_get(config, &list.unwrap())?.id); 83 list_ids.push(
84 lists_get(
85 config,
86 &list.ok_or(MLErr::new(EType::Other, "nolist"))?,
87 )?
88 .id,
89 );
79 } 90 }
80 91
81 let mut lists: Vec<ExportList> = vec![]; 92 let mut lists: Vec<ExportList> = vec![];
@@ -88,7 +99,7 @@ pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> {
88 let toml = toml::to_string(&Export { lists })?; 99 let toml = toml::to_string(&Export { lists })?;
89 100
90 let filestr = dirs::home_dir() 101 let filestr = dirs::home_dir()
91 .unwrap() 102 .ok_or(MLErr::new(EType::Other, "no home"))?
92 .join("mlexport.toml") 103 .join("mlexport.toml")
93 .into_os_string() 104 .into_os_string()
94 .into_string() 105 .into_string()
@@ -102,6 +113,7 @@ pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> {
102 Ok(()) 113 Ok(())
103} 114}
104 115
116/// # Errors
105pub async fn import( 117pub async fn import(
106 config: &Cfg, 118 config: &Cfg,
107 file_str: &str, 119 file_str: &str,
@@ -117,7 +129,9 @@ pub async fn import(
117 id: exportlist.id, 129 id: exportlist.id,
118 mc_version: exportlist.mc_version, 130 mc_version: exportlist.mc_version,
119 modloader: Modloader::from(&exportlist.launcher)?, 131 modloader: Modloader::from(&exportlist.launcher)?,
120 download_folder: exportlist.download_folder.ok_or("NO_DL").unwrap(), 132 download_folder: exportlist
133 .download_folder
134 .ok_or(MLErr::new(EType::Other, "NO_DL"))?,
121 }; 135 };
122 lists_insert( 136 lists_insert(
123 config, 137 config,