MCPcopy Create free account
hub / github.com/Licoy/fetch-github-hosts / run_cli

Function run_cli

src-tauri/src/cli.rs:46–75  ·  view source on GitHub ↗

Run CLI mode (no GUI)

(args: CliArgs)

Source from the content-addressed store, hash-verified

44
45/// Run CLI mode (no GUI)
46pub 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
78async fn run_client_cli(url: &str, interval_minutes: u32) {

Callers 1

mainFunction · 0.85

Calls 2

run_server_cliFunction · 0.85
run_client_cliFunction · 0.85

Tested by

no test coverage detected