MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / main

Function main

src/main.rs:4–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3#[tokio::main]
4async fn main() {
5 // Initialize telemetry logger (non-blocking, best-effort)
6 let log_dir = dirs::home_dir()
7 .unwrap_or_default()
8 .join(".chrome-devtools-cli")
9 .join("logs");
10 telemetry::init_logger_once(log_dir);
11
12 // Internal daemon mode — invoked by spawn_daemon(), not by users
13 let args: Vec<String> = std::env::args().collect();
14 if args.get(1).map(|s| s.as_str()) == Some("__daemon__") {
15 let ws_url = args.get(2).expect("daemon requires ws_url argument");
16 let result = daemon::run_daemon(ws_url).await;
17 telemetry::shutdown_logger();
18 if let Err(e) = result {
19 eprintln!("daemon error: {e:#}");
20 std::process::exit(1);
21 }
22 return;
23 }
24
25 let result = chrome_devtools_cli::run().await;
26 telemetry::shutdown_logger();
27 if let Err(e) = result {
28 let code = match e.downcast_ref::<chrome_devtools_cli::error::CliError>() {
29 Some(ce) => ce.code().code(),
30 None => ErrorCode::Unspecified as u32,
31 };
32 eprintln!("error: {e:#}");
33 std::process::exit(code as i32);
34 }
35}

Callers

nothing calls this directly

Calls 5

init_logger_onceFunction · 0.85
run_daemonFunction · 0.85
shutdown_loggerFunction · 0.85
runFunction · 0.85
codeMethod · 0.80

Tested by

no test coverage detected