use std::path::PathBuf;
use crate::OutputFormat;
use light_fw_cli_core::doctor::{SystemProbe, doctor};
#[derive(clap::Args)]
pub struct DoctorArgs {
#[arg(default_value = ".")]
pub path: PathBuf,
#[arg(long, value_enum, default_value_t = OutputFormat::Text)]
pub format: OutputFormat,
#[arg(long)]
pub offline: bool,
}
pub fn run(args: DoctorArgs) -> anyhow::Result<i32> {
let probe = if args.offline {
SystemProbe::offline()
} else {
SystemProbe::new()
};
let report = doctor(&args.path, &probe)?;
match args.format {
OutputFormat::Text => print!("{}", report.to_text()),
OutputFormat::Json => println!("{}", serde_json::to_string_pretty(&report.to_json())?),
}
Ok(if report.has_errors() { 1 } else { 0 })
}