#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
apoc::error_telemetry::install_panic_hook();
let argv = std::env::args().skip(1).collect::<Vec<_>>();
if let Some(message) = apoc::cli::exact_argv_cli_error(&argv) {
apoc::error_telemetry::record_cli_error("VALIDATION_ERROR", message);
println!(
"code: VALIDATION_ERROR\nmessage: {}",
serde_json::to_string(message)?
);
std::process::exit(2);
}
if argv
.iter()
.take_while(|arg| *arg != "--")
.any(|arg| arg == "--mcp")
{
return apoc::mcp_surface::serve_stdio().await.inspect_err(|error| {
apoc::error_telemetry::record_cli_error("MCP_RUNTIME_ERROR", &error.to_string());
});
}
apoc::error_telemetry::serve_cli(argv)
.await
.inspect_err(|error| {
apoc::error_telemetry::record_cli_error("CLI_RUNTIME_ERROR", &error.to_string());
})
}