Skip to content

Commit

Permalink
Add "update" cli arg
Browse files Browse the repository at this point in the history
  • Loading branch information
mxve committed Jun 12, 2023
1 parent eb508f2 commit b15d0eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

---

- Passing iw4-sp, iw5-mod or iw6-mod as the first argument will skip automatic game detection
- 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
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,19 @@ fn launch(file_path: &PathBuf) {
}

fn main() {
let args: Vec<String> = std::env::args().collect();
let mut args: Vec<String> = std::env::args().collect();

let games_json = http::get_body_string(format!("{}/games.json", MASTER).as_str());
let games: Vec<Game> = 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]);
Expand All @@ -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;
}
Expand Down

0 comments on commit b15d0eb

Please sign in to comment.