Skip to content

feat(xtask): ✨ Exit with an error code when appropriate #2823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions alvr/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use alvr_filesystem as afs;
use dependencies::OpenXRLoadersSelection;
use packaging::ReleaseFlavor;
use pico_args::Arguments;
use std::{fs, time::Instant};
use std::{fs, process, time::Instant};
use xshell::{cmd, Shell};

const HELP_STR: &str = r#"
Expand Down Expand Up @@ -185,7 +185,10 @@ fn main() {
"linux" => BuildPlatform::Linux,
"macos" => BuildPlatform::Macos,
"android" => BuildPlatform::Android,
_ => panic!("Unrecognized platform."),
_ => {
eprintln!("\nUnrecognized platform.");
process::exit(1);
}
});

let version: Option<String> = args.opt_value_from_str("--version").unwrap();
Expand Down Expand Up @@ -266,20 +269,20 @@ fn main() {
"check-msrv" => version::check_msrv(),
"kill-oculus" => kill_oculus_processes(),
_ => {
println!("\nUnrecognized subcommand.");
eprintln!("\nUnrecognized subcommand.");
println!("{HELP_STR}");
Comment on lines -269 to 273
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh both should go into error out, splitting them is probably just confusing.

return;
process::exit(1);
}
}
} else {
println!("\nWrong arguments.");
eprintln!("\nWrong arguments.");
println!("{HELP_STR}");
return;
process::exit(1);
}
} else {
println!("\nMissing subcommand.");
eprintln!("\nMissing subcommand.");
println!("{HELP_STR}");
return;
process::exit(1);
}

let elapsed_time = begin_time.elapsed();
Expand Down