launcher: default to GUI except legacy positional direct mode
This commit is contained in:
parent
fa47fa4e30
commit
94eab89dfc
@ -25,7 +25,28 @@ fn should_run_launcher(args: &[String]) -> bool {
|
||||
if args.iter().any(|arg| arg == "--no-launcher") {
|
||||
return false;
|
||||
}
|
||||
args.iter().any(|arg| arg == "--launcher") || args.is_empty()
|
||||
if args.iter().any(|arg| arg == "--launcher") {
|
||||
return true;
|
||||
}
|
||||
!has_direct_server_arg(args)
|
||||
}
|
||||
|
||||
/// Detects legacy positional direct-connect invocation (`lesavka-client <url>`).
|
||||
fn has_direct_server_arg(args: &[String]) -> bool {
|
||||
let mut idx = 0usize;
|
||||
while idx < args.len() {
|
||||
let arg = &args[idx];
|
||||
if arg == "--server" {
|
||||
idx = idx.saturating_add(2);
|
||||
continue;
|
||||
}
|
||||
if arg.starts_with("--") {
|
||||
idx += 1;
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn runtime_env_vars(state: &LauncherState) -> BTreeMap<String, String> {
|
||||
@ -146,4 +167,10 @@ mod tests {
|
||||
let args = vec!["http://server:50051".to_string()];
|
||||
assert!(!should_run_launcher(&args));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_run_launcher_with_server_flag() {
|
||||
let args = vec!["--server".to_string(), "http://server:50051".to_string()];
|
||||
assert!(should_run_launcher(&args));
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
"client/src/launcher/mod.rs": {
|
||||
"clippy_warnings": 4,
|
||||
"doc_debt": 4,
|
||||
"loc": 149
|
||||
"loc": 176
|
||||
},
|
||||
"client/src/launcher/state.rs": {
|
||||
"clippy_warnings": 8,
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
},
|
||||
"client/src/launcher/mod.rs": {
|
||||
"line_percent": 96.15384615384616,
|
||||
"loc": 149
|
||||
"loc": 176
|
||||
},
|
||||
"client/src/launcher/state.rs": {
|
||||
"line_percent": 99.32432432432432,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user