use crate::tools::health::HealthCheckToolImpl;
use std::path::Path;
pub async fn run_health_command(
config_path: &Path,
check_type: &str,
verbose: bool,
) -> Result<(), Box<dyn std::error::Error>> {
if config_path.exists() {
if let Ok(app_config) = crate::config::AppConfig::from_file(config_path) {
let _ = crate::utils::init_global_http_client(&app_config.performance);
}
}
let tool = HealthCheckToolImpl::new();
let (report, is_healthy) = tool.run_check_report(check_type, verbose).await;
println!("{report}");
if is_healthy {
Ok(())
} else {
Err(
format!("Health check did not report a healthy status (check_type: {check_type})")
.into(),
)
}
}