Skip to content

Commit

Permalink
add --help, --version/-v
Browse files Browse the repository at this point in the history
  • Loading branch information
mxve committed Sep 14, 2023
1 parent d47ebbc commit 428c75b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

- ```iw4-sp```, ```iw4x```, ```iw5-mod```, ```iw6-mod```, ```s1-mod```
- Skip automatic detection and launch the specified game
- This should always be the first argument if used
- ```--update```, ```-u```
- Only update the game, don't launch it
- ```--skip-launcher-update```
Expand All @@ -31,6 +32,8 @@
- Do not include a trailing backslash in the path
- ```--pass```
- Pass additional arguments to the game
- ```--version```, ```-v```
- Print the launcher version

Example: ```alterware-launcher.exe iw4x --bonus -u --path "C:\Games\IW4x" --pass "-console"```

Expand Down
43 changes: 39 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,43 @@ fn main() {

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

if arg_bool(&args, "--help") {
println!("CLI Args:");
println!(" <client>: Specify the client to launch");
println!(" --help: Display this help message");
println!(" --version: Display the launcher version");
println!(" --path/-p <path>: Specify the game directory");
println!(" --update/-u: Update only, don't launch the game");
println!(" --bonus: Download bonus content");
println!(" --force/-f: Force file hash recheck");
println!(" --pass <args>: Pass arguments to the game");
println!(" --skip-launcher-update: Skip launcher self-update");
println!(
"\nExample:\n alterware-launcher.exe iw4x --bonus --pass \"-console -nointro\""
);
std::process::exit(0);
}

if arg_bool(&args, "--version") || arg_bool(&args, "-v") {
println!(
"{} v{}",
"AlterWare Launcher".bright_green(),
env!("CARGO_PKG_VERSION")
);
println!("https://github.com/{}/{}", GH_OWNER, GH_REPO);
println!(
"\n{}{}{}{}{}{}{}",
"For ".on_black(),
"Alter".bright_blue().on_black().underline(),
"Ware".white().on_black().underline(),
".dev".on_black().underline(),
" by ".on_black(),
"mxve".bright_magenta().on_black().underline(),
".de".on_black().underline()
);
std::process::exit(0);
}

let install_path: PathBuf;
if let Some(path) = arg_value(&args, "--path") {
install_path = PathBuf::from(path);
Expand Down Expand Up @@ -347,10 +384,8 @@ fn main() {
if let Some(pass) = arg_value(&args, "--pass") {
cfg.args = pass;
arg_remove_value(&mut args, "--pass");
} else {
if cfg.args.is_empty() {
cfg.args = String::from("");
}
} else if cfg.args.is_empty() {
cfg.args = String::from("");
}

let games_json = http::get_body_string(format!("{}/games.json", MASTER).as_str());
Expand Down

0 comments on commit 428c75b

Please sign in to comment.