| 2506 | } |
| 2507 | |
| 2508 | fn no_command_action_from_args_slice(args: &[String]) -> Option<NoCommandAction> { |
| 2509 | if args |
| 2510 | .first() |
| 2511 | .is_some_and(|arg| is_known_command(arg) || arg == "ui" || arg == "serve") |
| 2512 | { |
| 2513 | return None; |
| 2514 | } |
| 2515 | let mut options = DefaultServiceLaunchOptions::default(); |
| 2516 | let mut i = 0; |
| 2517 | while i < args.len() { |
| 2518 | let arg = &args[i]; |
| 2519 | match arg.as_str() { |
| 2520 | "-p" | "--port" => { |
| 2521 | i += 1; |
| 2522 | options.port = args.get(i)?.parse().ok()?; |
| 2523 | options.port_explicit = true; |
| 2524 | } |
| 2525 | value if value.starts_with("--port=") => { |
| 2526 | options.port = value.strip_prefix("--port=")?.parse().ok()?; |
| 2527 | options.port_explicit = true; |
| 2528 | } |
| 2529 | "--bind" => { |
| 2530 | i += 1; |
| 2531 | options.bind = args.get(i)?.parse().ok()?; |
| 2532 | } |
| 2533 | value if value.starts_with("--bind=") => { |
| 2534 | options.bind = value.strip_prefix("--bind=")?.parse().ok()?; |
| 2535 | } |
| 2536 | "--advertise-host" => { |
| 2537 | i += 1; |
| 2538 | options.advertise_host = args.get(i).cloned(); |
| 2539 | } |
| 2540 | value if value.starts_with("--advertise-host=") => { |
| 2541 | options.advertise_host = Some(value.strip_prefix("--advertise-host=")?.to_owned()); |
| 2542 | } |
| 2543 | "--client-root" => { |
| 2544 | i += 1; |
| 2545 | options.client_root = args.get(i).map(PathBuf::from); |
| 2546 | } |
| 2547 | value if value.starts_with("--client-root=") => { |
| 2548 | options.client_root = Some(PathBuf::from(value.strip_prefix("--client-root=")?)); |
| 2549 | } |
| 2550 | "--video-codec" => { |
| 2551 | i += 1; |
| 2552 | options.video_codec = parse_video_codec_mode(args.get(i)?)?; |
| 2553 | } |
| 2554 | value if value.starts_with("--video-codec=") => { |
| 2555 | options.video_codec = |
| 2556 | parse_video_codec_mode(value.strip_prefix("--video-codec=")?)?; |
| 2557 | } |
| 2558 | "--android-gpu" => { |
| 2559 | i += 1; |
| 2560 | options.android_gpu = parse_android_gpu_mode(args.get(i)?)?; |
| 2561 | } |
| 2562 | value if value.starts_with("--android-gpu=") => { |
| 2563 | options.android_gpu = |
| 2564 | parse_android_gpu_mode(value.strip_prefix("--android-gpu=")?)?; |
| 2565 | } |