From bbdaaa931c5bfe2a5ecab1acc1e6c2df27962158 Mon Sep 17 00:00:00 2001 From: null8626 Date: Fri, 2 Feb 2024 16:40:08 +0700 Subject: [PATCH] [refactor,style]: cleanup more code + cargo fmt --- src/app/from_string.rs | 6 +++--- src/app/mod.rs | 2 +- src/commands/import/mrpack.rs | 2 +- src/core/mod.rs | 5 ++++- src/interop/packwiz.rs | 20 ++++++++++---------- src/main.rs | 5 ++++- src/util/mod.rs | 3 +-- 7 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/app/from_string.rs b/src/app/from_string.rs index 29fcd6c..48b0292 100644 --- a/src/app/from_string.rs +++ b/src/app/from_string.rs @@ -90,7 +90,7 @@ impl App { let version = self.select( "Select a version", - &versions + versions .iter() .map(|v| { SelectItem( @@ -126,7 +126,7 @@ impl App { let version = self.select( "Select a version", - &versions + versions .iter() .map(|v| { SelectItem( @@ -165,7 +165,7 @@ impl App { let version = self.select( "Select a version", - &versions + versions .iter() .map(|v| { SelectItem( diff --git a/src/app/mod.rs b/src/app/mod.rs index ab5ab89..6d3989d 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -350,7 +350,7 @@ impl App { worlds => WorldsAPI, hooks => HooksAPI, } - + interop_methods_mut! { packwiz => PackwizInterop, mrpack => MRPackInterop, diff --git a/src/commands/import/mrpack.rs b/src/commands/import/mrpack.rs index ca5daa8..f5b7760 100644 --- a/src/commands/import/mrpack.rs +++ b/src/commands/import/mrpack.rs @@ -43,7 +43,7 @@ pub async fn run(mut app: App, args: Args) -> Result<()> { }; if !args.keep { - app.server.mods = vec![]; + app.server.mods.clear(); app.info("cleared mods list"); } diff --git a/src/core/mod.rs b/src/core/mod.rs index a4c92b6..9350db6 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -142,7 +142,10 @@ impl<'a> BuildContext<'a> { /// Save `new_lockfile` pub fn write_lockfile(&mut self) -> Result<()> { - if std::env::var("MCMAN_DISABLE_LOCKFILE") == Ok("true".to_owned()) { + if std::env::var("MCMAN_DISABLE_LOCKFILE") + .map(|s| s.as_str() == "true") + .unwrap_or_default() + { self.app.dbg("lockfile disabled"); } else { self.new_lockfile.save()?; diff --git a/src/interop/packwiz.rs b/src/interop/packwiz.rs index af75a62..6960ab0 100644 --- a/src/interop/packwiz.rs +++ b/src/interop/packwiz.rs @@ -179,16 +179,16 @@ impl<'a> PackwizInterop<'a> { _ => return Ok(None), }; - Ok( - self.0.modrinth() - .version_from_hash(&down.hash, fmt) - .await - .map(|ver| Downloadable::Modrinth { - id: ver.project_id.clone(), - version: ver.id.clone(), - }) - .ok() - ) + Ok(self + .0 + .modrinth() + .version_from_hash(&down.hash, fmt) + .await + .map(|ver| Downloadable::Modrinth { + id: ver.project_id.clone(), + version: ver.id.clone(), + }) + .ok()) } } diff --git a/src/main.rs b/src/main.rs index d78d4a2..3df8a01 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,10 @@ enum Commands { #[tokio::main] async fn main() -> Result<()> { - if env::var("CI") == Ok("true".to_owned()) { + if env::var("CI") + .map(|s| s.as_str() == "true") + .unwrap_or_default() + { println!("::endgroup::"); } diff --git a/src/util/mod.rs b/src/util/mod.rs index e518988..fe7317f 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -63,8 +63,7 @@ pub fn get_latest_semver(list: &[String]) -> Option { /// ci.luckto.me => ci-lucko-me pub fn url_to_folder(url: &str) -> String { - url - .replace("https://", "") + url.replace("https://", "") .replace("http://", "") .replace('/', " ") .trim()