From b15d0eb7d7d21ba35f4f55011b94d79620d56bde Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Mon, 12 Jun 2023 02:54:55 +0200 Subject: [PATCH] Add "update" cli arg --- README.md | 3 ++- src/main.rs | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f04b084..db9b507 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,5 @@ --- -- Passing iw4-sp, iw5-mod or iw6-mod as the first argument will skip automatic game detection \ No newline at end of file +- Passing ```iw4-sp```, ```iw5-mod``` or ```iw6-mod``` as the first argument will skip automatic game detection +- Passing ```update``` will stop the launcher from launching the game \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index b0c492a..f7a36cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,11 +93,19 @@ fn launch(file_path: &PathBuf) { } fn main() { - let args: Vec = std::env::args().collect(); + let mut args: Vec = std::env::args().collect(); let games_json = http::get_body_string(format!("{}/games.json", MASTER).as_str()); let games: Vec = serde_json::from_str(&games_json).unwrap(); + let mut update_only = false; + if args.contains(&String::from("update")) { + update_only = true; + args.iter() + .position(|r| r == "update") + .map(|e| args.remove(e)); + } + let mut game: String = String::new(); if args.len() > 1 { game = String::from(&args[1]); @@ -115,6 +123,9 @@ fn main() { for g in games.iter() { if g.client == game { update(g); + if update_only { + return; + } launch(&PathBuf::from(format!("{}.exe", g.client))); return; }