self restart
This commit is contained in:
parent
8cc1047367
commit
f582cdd625
@ -376,6 +376,7 @@ async fn main() {
|
|||||||
setup_env();
|
setup_env();
|
||||||
|
|
||||||
let mut args: Vec<String> = env::args().collect();
|
let mut args: Vec<String> = env::args().collect();
|
||||||
|
let original_args = args.clone();
|
||||||
|
|
||||||
if arg_bool(&args, "--help") {
|
if arg_bool(&args, "--help") {
|
||||||
println!("CLI Args:");
|
println!("CLI Args:");
|
||||||
@ -428,7 +429,7 @@ async fn main() {
|
|||||||
let mut cfg = config::load(install_path.join("alterware-launcher.json"));
|
let mut cfg = config::load(install_path.join("alterware-launcher.json"));
|
||||||
|
|
||||||
if !arg_bool(&args, "--skip-launcher-update") && !cfg.skip_self_update {
|
if !arg_bool(&args, "--skip-launcher-update") && !cfg.skip_self_update {
|
||||||
self_update::run(cfg.update_only);
|
self_update::run(cfg.update_only, original_args);
|
||||||
} else {
|
} else {
|
||||||
arg_remove(&mut args, "--skip-launcher-update");
|
arg_remove(&mut args, "--skip-launcher-update");
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ pub fn self_update_available() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
pub fn run(_update_only: bool) {
|
pub fn run(_update_only: bool, _args: Vec<String>) {
|
||||||
if self_update_available() {
|
if self_update_available() {
|
||||||
println!("A new version of the AlterWare launcher is available.");
|
println!("A new version of the AlterWare launcher is available.");
|
||||||
println!(
|
println!(
|
||||||
@ -26,7 +26,20 @@ pub fn run(_update_only: bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn run(update_only: bool) {
|
pub fn restart(args: Vec<String>) -> std::io::Error {
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
match std::process::Command::new(std::env::current_exe().unwrap())
|
||||||
|
.args(args.into_iter().skip(1))
|
||||||
|
.creation_flags(0x00000010) // CREATE_NEW_CONSOLE
|
||||||
|
.spawn()
|
||||||
|
{
|
||||||
|
Ok(_) => std::process::exit(0),
|
||||||
|
Err(err) => err,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub fn run(update_only: bool, args: Vec<String>) {
|
||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::PathBuf};
|
||||||
|
|
||||||
use crate::http;
|
use crate::http;
|
||||||
@ -85,12 +98,12 @@ pub fn run(update_only: bool) {
|
|||||||
|
|
||||||
self_replace::self_replace("alterware-launcher-update.exe").unwrap();
|
self_replace::self_replace("alterware-launcher-update.exe").unwrap();
|
||||||
fs::remove_file(&file_path).unwrap();
|
fs::remove_file(&file_path).unwrap();
|
||||||
println!(
|
|
||||||
"Launcher updated. View the changelog at https://github.com/{}/{}/releases/latest",
|
// restarting spawns a new console, automation should manually restart on exit code 201
|
||||||
GH_OWNER, GH_REPO,
|
|
||||||
);
|
|
||||||
println!("Please restart the launcher.");
|
|
||||||
if !update_only {
|
if !update_only {
|
||||||
|
let restart_error = restart(args).to_string();
|
||||||
|
println!("Failed to restart launcher: {}", restart_error);
|
||||||
|
println!("Please restart the launcher manually.");
|
||||||
misc::stdin();
|
misc::stdin();
|
||||||
}
|
}
|
||||||
std::process::exit(201);
|
std::process::exit(201);
|
||||||
|
Loading…
Reference in New Issue
Block a user