Run CLI mode (no GUI)
(args: CliArgs)
| 44 | |
| 45 | /// Run CLI mode (no GUI) |
| 46 | pub async fn run_cli(args: CliArgs) { |
| 47 | let mode = args.mode.as_deref().unwrap_or("client"); |
| 48 | |
| 49 | // Validate mode |
| 50 | let mode = match mode { |
| 51 | "client" | "server" => mode, |
| 52 | other => { |
| 53 | println!("⚠️ 无效的启动模式: {},已自动设置为 client", other); |
| 54 | "client" |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | // Validate interval |
| 59 | let interval = if args.interval < 1 { |
| 60 | println!("⚠️ 获取间隔不可小于 1 分钟,已自动设置为 60 分钟"); |
| 61 | 60 |
| 62 | } else { |
| 63 | args.interval |
| 64 | }; |
| 65 | |
| 66 | println!("╔════════════════════════════════════════════════╗"); |
| 67 | println!("║ Fetch Github Hosts V{} ║", crate::APP_VERSION); |
| 68 | println!("╚════════════════════════════════════════════════╝"); |
| 69 | println!(); |
| 70 | |
| 71 | match mode { |
| 72 | "server" => run_server_cli(args.port, interval, args.template).await, |
| 73 | _ => run_client_cli(&args.url, interval).await, |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /// CLI Client mode: fetch hosts from URL, write to system, loop with interval |
| 78 | async fn run_client_cli(url: &str, interval_minutes: u32) { |
no test coverage detected