summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-09-04 09:56:42 +0200
committerfxqnlr <[email protected]>2024-09-04 09:56:42 +0200
commitf5e070cdf6628a5ebd981d373929802317104e24 (patch)
treee31c88371737e20b2cc79bf9ee0c1dbfdeb6e727 /src/commands
parent1d64516ed95266a4fc1f8a18652f99158a4004f1 (diff)
downloadmodlist-f5e070cdf6628a5ebd981d373929802317104e24.tar
modlist-f5e070cdf6628a5ebd981d373929802317104e24.tar.gz
modlist-f5e070cdf6628a5ebd981d373929802317104e24.zip
clippy --fix
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/download.rs2
-rw-r--r--src/commands/io.rs8
-rw-r--r--src/commands/list.rs20
-rw-r--r--src/commands/modification.rs12
4 files changed, 20 insertions, 22 deletions
diff --git a/src/commands/download.rs b/src/commands/download.rs
index a7cf744..3e50c87 100644
--- a/src/commands/download.rs
+++ b/src/commands/download.rs
@@ -71,7 +71,7 @@ pub async fn download(
71 } 71 }
72 72
73 if clean { 73 if clean {
74 clean_list_dir(&current_list)? 74 clean_list_dir(&current_list)?;
75 }; 75 };
76 76
77 if !to_download.is_empty() { 77 if !to_download.is_empty() {
diff --git a/src/commands/io.rs b/src/commands/io.rs
index 8e44b2b..1d17f7c 100644
--- a/src/commands/io.rs
+++ b/src/commands/io.rs
@@ -48,13 +48,13 @@ impl ExportList {
48 48
49 let mut dl_folder = None; 49 let mut dl_folder = None;
50 if download { 50 if download {
51 dl_folder = Some(list.download_folder) 51 dl_folder = Some(list.download_folder);
52 }; 52 };
53 53
54 let mods = userlist_get_all_ids(config, list_id)?; 54 let mods = userlist_get_all_ids(config, list_id)?;
55 let mut versions = vec![]; 55 let mut versions = vec![];
56 for m in mods { 56 for m in mods {
57 versions.push(ExportVersion::from(config, list_id, &m)?) 57 versions.push(ExportVersion::from(config, list_id, &m)?);
58 } 58 }
59 59
60 Ok(Self { 60 Ok(Self {
@@ -80,7 +80,7 @@ pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> {
80 80
81 let mut lists: Vec<ExportList> = vec![]; 81 let mut lists: Vec<ExportList> = vec![];
82 for list_id in list_ids { 82 for list_id in list_ids {
83 progress.set_message(format!("Export {}", list_id)); 83 progress.set_message(format!("Export {list_id}"));
84 //TODO download option/ new download on import 84 //TODO download option/ new download on import
85 lists.push(ExportList::from(config, &list_id, true)?); 85 lists.push(ExportList::from(config, &list_id, true)?);
86 } 86 }
@@ -97,7 +97,7 @@ pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> {
97 progress.set_message("Create file"); 97 progress.set_message("Create file");
98 let mut file = File::create(&filestr)?; 98 let mut file = File::create(&filestr)?;
99 file.write_all(toml.as_bytes())?; 99 file.write_all(toml.as_bytes())?;
100 progress.finish_with_message(format!("Exported to {}", filestr)); 100 progress.finish_with_message(format!("Exported to {filestr}"));
101 101
102 Ok(()) 102 Ok(())
103} 103}
diff --git a/src/commands/list.rs b/src/commands/list.rs
index 3665446..63105cf 100644
--- a/src/commands/list.rs
+++ b/src/commands/list.rs
@@ -32,32 +32,32 @@ pub fn list_add(
32) -> MLE<()> { 32) -> MLE<()> {
33 let p = ProgressBar::new_spinner(); 33 let p = ProgressBar::new_spinner();
34 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 34 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap());
35 p.set_message(format!("Create {}", id)); 35 p.set_message(format!("Create {id}"));
36 lists_insert(config, id, mc_version, modloader, directory)?; 36 lists_insert(config, id, mc_version, modloader, directory)?;
37 p.finish_with_message(format!("Created {}", id)); 37 p.finish_with_message(format!("Created {id}"));
38 Ok(()) 38 Ok(())
39} 39}
40 40
41pub fn list_change(config: &Cfg, id: &str) -> MLE<()> { 41pub fn list_change(config: &Cfg, id: &str) -> MLE<()> {
42 let p = ProgressBar::new_spinner(); 42 let p = ProgressBar::new_spinner();
43 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 43 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap());
44 p.set_message(format!("Change default list to {}", id)); 44 p.set_message(format!("Change default list to {id}"));
45 45
46 if !lists_get_all_ids(config)?.into_iter().any(|l| l == id) { 46 if !lists_get_all_ids(config)?.into_iter().any(|l| l == id) {
47 return Err(MLError::new(ErrorType::ArgumentError, "List not found")); 47 return Err(MLError::new(ErrorType::ArgumentError, "List not found"));
48 }; 48 };
49 config_change_current_list(config, id)?; 49 config_change_current_list(config, id)?;
50 50
51 p.finish_with_message(format!("Changed default list to {}", id)); 51 p.finish_with_message(format!("Changed default list to {id}"));
52 Ok(()) 52 Ok(())
53} 53}
54 54
55pub fn list_remove(config: &Cfg, id: &str) -> MLE<()> { 55pub fn list_remove(config: &Cfg, id: &str) -> MLE<()> {
56 let p = ProgressBar::new_spinner(); 56 let p = ProgressBar::new_spinner();
57 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 57 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap());
58 p.set_message(format!("Remove {}", id)); 58 p.set_message(format!("Remove {id}"));
59 lists_remove(config, id)?; 59 lists_remove(config, id)?;
60 p.finish_with_message(format!("Removed {}", id)); 60 p.finish_with_message(format!("Removed {id}"));
61 Ok(()) 61 Ok(())
62} 62}
63 63
@@ -77,15 +77,13 @@ pub async fn list_version(
77 let p = ProgressBar::new_spinner(); 77 let p = ProgressBar::new_spinner();
78 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 78 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap());
79 p.set_message(format!( 79 p.set_message(format!(
80 "Change version for list {} to minecraft version: {}", 80 "Change version for list {id} to minecraft version: {mc_version}"
81 id, mc_version
82 )); 81 ));
83 82
84 lists_version(config, id, &mc_version)?; 83 lists_version(config, id, &mc_version)?;
85 84
86 p.finish_with_message(format!( 85 p.finish_with_message(format!(
87 "Changed version for list {} to minecraft version: {}", 86 "Changed version for list {id} to minecraft version: {mc_version}"
88 id, mc_version
89 )); 87 ));
90 88
91 let list = lists_get(config, id)?; 89 let list = lists_get(config, id)?;
@@ -96,7 +94,7 @@ pub fn list_list(config: &Cfg) -> MLE<()> {
96 let lists = lists_get_all_ids(config)?; 94 let lists = lists_get_all_ids(config)?;
97 for list in lists { 95 for list in lists {
98 let l = lists_get(config, &list)?; 96 let l = lists_get(config, &list)?;
99 println!("{}: | {} | {}", l.id, l.mc_version, l.modloader) 97 println!("{}: | {} | {}", l.id, l.mc_version, l.modloader);
100 } 98 }
101 Ok(()) 99 Ok(())
102} 100}
diff --git a/src/commands/modification.rs b/src/commands/modification.rs
index 4488b70..e0e54b2 100644
--- a/src/commands/modification.rs
+++ b/src/commands/modification.rs
@@ -65,7 +65,7 @@ pub async fn mod_add(
65 add_p.inc(1); 65 add_p.inc(1);
66 match m.id { 66 match m.id {
67 IDSelector::ModificationID(pid) => { 67 IDSelector::ModificationID(pid) => {
68 mod_ids.push((pid, m.set_version)) 68 mod_ids.push((pid, m.set_version));
69 } 69 }
70 IDSelector::VersionID(vid) => ver_ids.push((vid, m.set_version)), 70 IDSelector::VersionID(vid) => ver_ids.push((vid, m.set_version)),
71 } 71 }
@@ -153,7 +153,7 @@ pub async fn mod_add(
153 }?; 153 }?;
154 154
155 if project.current_version.is_some() { 155 if project.current_version.is_some() {
156 downloadstack.push(project.current_version.unwrap()) 156 downloadstack.push(project.current_version.unwrap());
157 }; 157 };
158 158
159 project_p.inc(1); 159 project_p.inc(1);
@@ -245,7 +245,7 @@ async fn get_mod_infos(
245 applicable_versions: available_versions_vec, 245 applicable_versions: available_versions_vec,
246 download_link: file, 246 download_link: file,
247 set_version: *setmap.get(&project.slug).unwrap(), 247 set_version: *setmap.get(&project.slug).unwrap(),
248 }) 248 });
249 } else { 249 } else {
250 current_version = None; 250 current_version = None;
251 file = String::from("NONE"); 251 file = String::from("NONE");
@@ -258,7 +258,7 @@ async fn get_mod_infos(
258 applicable_versions: available_versions_vec, 258 applicable_versions: available_versions_vec,
259 download_link: file, 259 download_link: file,
260 set_version: *setmap.get(&project.id).unwrap(), 260 set_version: *setmap.get(&project.id).unwrap(),
261 }) 261 });
262 } 262 }
263 } 263 }
264 264
@@ -308,7 +308,7 @@ async fn get_ver_info(
308 applicable_versions: vec![String::from(&version.id)], 308 applicable_versions: vec![String::from(&version.id)],
309 download_link: file, 309 download_link: file,
310 set_version: *setmap.get(&version.id).unwrap(), 310 set_version: *setmap.get(&version.id).unwrap(),
311 }) 311 });
312 } 312 }
313 Ok(projectinfo) 313 Ok(projectinfo)
314} 314}
@@ -335,7 +335,7 @@ pub fn mod_remove(config: &Cfg, id: &str, list: &List) -> MLE<()> {
335 335
336 progress.set_message("Delete file"); 336 progress.set_message("Delete file");
337 match delete_version(list, version) { 337 match delete_version(list, version) {
338 Ok(_) => (), 338 Ok(()) => (),
339 Err(err) => { 339 Err(err) => {
340 if err.to_string() 340 if err.to_string()
341 != "User input not accepted: VERSION_NOT_FOUND_IN_FILES" 341 != "User input not accepted: VERSION_NOT_FOUND_IN_FILES"