mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 15:44:35 +01:00
Fix args
This commit is contained in:
@@ -54,13 +54,18 @@ async fn parse_args(inp: &Vec<String>) -> Result<Args, ArgsError> {
|
|||||||
"no-admin",
|
"no-admin",
|
||||||
"Launch without requiring admin permissions",
|
"Launch without requiring admin permissions",
|
||||||
);
|
);
|
||||||
args.flag("g", "no-gui", "Run in CLI mode");
|
args.flag("g", "no-gui", "Run in CLI mode. Requires -A to be passed as well.");
|
||||||
args.flag("s", "server", "Launch the configured GC server");
|
args.flag("s", "server", "Launch the configured GC server");
|
||||||
args.flag(
|
args.flag(
|
||||||
"P",
|
"P",
|
||||||
"patch",
|
"patch",
|
||||||
"Patch your game before launching, with whatever your game version needs",
|
"Patch your game before launching, with whatever your game version needs",
|
||||||
);
|
);
|
||||||
|
args.flag(
|
||||||
|
"N",
|
||||||
|
"non-elevated-game",
|
||||||
|
"Launch the game without admin permissions"
|
||||||
|
);
|
||||||
args.option(
|
args.option(
|
||||||
"H",
|
"H",
|
||||||
"host",
|
"host",
|
||||||
@@ -96,17 +101,20 @@ async fn parse_args(inp: &Vec<String>) -> Result<Args, ArgsError> {
|
|||||||
patch::patch_game().await;
|
patch::patch_game().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
system_helpers::run_program(game_path.to_string(), Some(game_args))
|
if args.value_of("non-elevated-game")? {
|
||||||
|
system_helpers::run_un_elevated(game_path.to_string(), Some(game_args))
|
||||||
|
} else {
|
||||||
|
system_helpers::run_program(game_path.to_string(), Some(game_args))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.value_of("server")? {
|
if args.value_of("server")? {
|
||||||
let server_jar = config.grasscutter_path;
|
let server_jar = config.grasscutter_path;
|
||||||
let mut server_path = server_jar.clone();
|
// Assumes grasscutter jar is named appropriately
|
||||||
|
let server_path = server_jar.trim_end_matches("grasscutter.jar");
|
||||||
let java_path = config.java_path;
|
let java_path = config.java_path;
|
||||||
|
|
||||||
server_path.pop();
|
system_helpers::run_jar(server_jar.clone(), server_path.to_string(), java_path);
|
||||||
|
|
||||||
system_helpers::run_jar(server_jar, server_path.to_string(), java_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.value_of::<String>("host").is_ok() && !args.value_of::<String>("host")?.is_empty() {
|
if args.value_of::<String>("host").is_ok() && !args.value_of::<String>("host")?.is_empty() {
|
||||||
|
|||||||
@@ -11,7 +11,16 @@ use registry::{Data, Hive, Security};
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn run_program(path: String, args: Option<String>) {
|
pub fn run_program(path: String, args: Option<String>) {
|
||||||
// Without unwrap_or, this can crash when UAC prompt is denied
|
// Without unwrap_or, this can crash when UAC prompt is denied
|
||||||
open::that(format!("{} {}", &path, &args.unwrap_or_else(|| "".into()))).unwrap_or(());
|
match open::with(
|
||||||
|
format!(
|
||||||
|
"{} {}",
|
||||||
|
path, args.unwrap_or_else(|| "".into())
|
||||||
|
),
|
||||||
|
path.clone(),
|
||||||
|
) {
|
||||||
|
Ok(_) => (),
|
||||||
|
Err(e) => println!("Failed to open program ({}): {}", &path, e),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -80,12 +89,12 @@ pub fn run_jar(path: String, execute_in: String, java_path: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn run_un_elevated(path: String) {
|
pub fn run_un_elevated(path: String, args: Option<String>) {
|
||||||
// Open the program non-elevated.
|
// Open the program non-elevated.
|
||||||
match open::with(
|
match open::with(
|
||||||
format!(
|
format!(
|
||||||
"cmd /min /C \"set __COMPAT_LAYER=RUNASINVOKER && start \"\" \"{}\"\"",
|
"cmd /min /C \"set __COMPAT_LAYER=RUNASINVOKER && start \"\" \"{}\"\" {}",
|
||||||
path
|
path, args.unwrap_or_else(|| "".into())
|
||||||
),
|
),
|
||||||
"C:\\Windows\\System32\\cmd.exe",
|
"C:\\Windows\\System32\\cmd.exe",
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user