use config values

This commit is contained in:
2023-09-10 17:36:01 +02:00
parent 32b1272ff6
commit 86b0bb1b7a
3 changed files with 28 additions and 15 deletions

View File

@@ -1,3 +1,4 @@
mod config;
mod github;
mod global;
mod http;
@@ -223,23 +224,30 @@ fn launch(file_path: &PathBuf) {
fn main() {
let mut args: Vec<String> = std::env::args().collect();
let mut cfg = config::load(PathBuf::from("alterware-launcher.json"));
let mut update_only = false;
if args.contains(&String::from("update")) {
update_only = true;
cfg.update_only = true;
args.iter()
.position(|r| r == "update")
.map(|e| args.remove(e));
}
if !args.contains(&String::from("skip-launcher-update")) {
self_update::run(update_only);
if !args.contains(&String::from("skip-launcher-update")) && !cfg.skip_self_update {
self_update::run(cfg.update_only);
} else {
args.iter()
.position(|r| r == "skip-launcher-update")
.map(|e| args.remove(e));
}
if args.contains(&String::from("bonus")) {
cfg.bonus_content = true;
args.iter()
.position(|r| r == "bonus")
.map(|e| args.remove(e));
}
let games_json = http::get_body_string(format!("{}/games.json", MASTER).as_str());
let games: Vec<Game> = serde_json::from_str(&games_json).unwrap();
@@ -251,7 +259,7 @@ fn main() {
for r in g.references.iter() {
if std::path::Path::new(r).exists() {
if g.client.len() > 1 {
if update_only {
if cfg.update_only {
game = String::from(g.client[0]);
break 'main;
}
@@ -279,7 +287,7 @@ fn main() {
for c in g.client.iter() {
if c == &game {
update(g, &std::env::current_dir().unwrap());
if !update_only {
if !cfg.update_only {
launch(&PathBuf::from(format!("{}.exe", c)));
}
return;