1use crate::webhook_status::WebhookStatus;
4
5pub fn status() -> anyhow::Result<()> {
7 match WebhookStatus::load() {
8 None => {
9 println!("Webhook status: unavailable");
10 println!(" (service not running or webhooks have never been configured)");
11 }
12 Some(s) => {
13 let health_str = if s.healthy { "healthy" } else { "unhealthy" };
14 let fallback_str = if s.fallback_mode {
15 "yes (polling)"
16 } else {
17 "no"
18 };
19 let port_str = s
20 .port
21 .map(|p| p.to_string())
22 .unwrap_or_else(|| "—".to_string());
23 let last_check = s
24 .last_check_utc
25 .map(|t| t.to_rfc3339())
26 .unwrap_or_else(|| "never".to_string());
27 let failure = s.last_failure_reason.as_deref().unwrap_or("none");
28
29 println!("Webhook status:");
30 println!(" Configured: {}", s.configured);
31 println!(" Port: {}", port_str);
32 println!(" Health: {}", health_str);
33 println!(" Fallback mode: {}", fallback_str);
34 println!(" Last check (UTC): {}", last_check);
35 println!(" Startup attempts: {}", s.startup_attempts);
36 println!(" Last failure: {}", failure);
37 }
38 }
39 Ok(())
40}