From 030c869fec8164ee571082aeb0f7c5a780232783 Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Sat, 26 Aug 2023 20:59:38 +0200 Subject: [PATCH] linting --- src/main.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index c4962d0..37382cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ mod http; #[cfg(windows)] use mslnk::ShellLink; use semver::Version; -use std::{fs, path::PathBuf}; +use std::{fs, path::Path, path::PathBuf}; #[cfg(not(windows))] use std::{thread, time}; #[cfg(windows)] @@ -134,7 +134,7 @@ fn get_installed_games(games: &Vec) -> Vec<(u32, PathBuf)> { } #[cfg(windows)] -fn setup_client_links(game: &Game, game_dir: &PathBuf) { +fn setup_client_links(game: &Game, game_dir: &Path) { if game.client.len() > 1 { println!("Multiple clients installed, use the shortcuts (launch-.lnk in the game directory or desktop shortcuts) to launch a specific client."); } @@ -170,7 +170,7 @@ fn windows_launcher_install(games: &Vec) { println!("Installing AlterWare client for {}.", id); let game = games.iter().find(|&g| g.app_id == *id).unwrap(); setup_client_links(game, path); - update(&game, path); + update(game, path); println!("Installation complete. Please run the launcher again or use a shortcut to launch the game."); std::io::stdin().read_line(&mut String::new()).unwrap(); std::process::exit(0); @@ -240,8 +240,10 @@ fn windows_launcher_install(games: &Vec) { } } -fn prompt_client_selection(games: &Vec) -> String { - println!("Couldn't detect any games, please select a client to install in the current directory:"); +fn prompt_client_selection(games: &[Game]) -> String { + println!( + "Couldn't detect any games, please select a client to install in the current directory:" + ); for (i, g) in games.iter().enumerate() { for c in g.client.iter() { println!("{}: {}", i, c); @@ -251,7 +253,7 @@ fn prompt_client_selection(games: &Vec) -> String { String::from(games[input].client[0]) } -fn manual_install(games: &Vec) { +fn manual_install(games: &[Game]) { let selection = prompt_client_selection(games); let game = games.iter().find(|&g| g.client[0] == selection).unwrap(); update(game, &std::env::current_dir().unwrap()); @@ -260,7 +262,7 @@ fn manual_install(games: &Vec) { std::process::exit(0); } -fn update(game: &Game, dir: &PathBuf) { +fn update(game: &Game, dir: &Path) { let cdn_info: Vec = serde_json::from_str(&http::get_body_string( format!("{}/files.json", MASTER).as_str(), )) @@ -375,7 +377,7 @@ fn main() { windows_launcher_install(&games); #[cfg(not(windows))] - prompt_client_selection(&games); + manual_install(&games); println!("Game not found!"); println!("Place the launcher in the game folder, if that doesn't work specify the client on the command line (ex. alterware-launcher.exe iw4-sp)");