cuddle-please/crates/cuddle-please-commands/src/doctor_command.rs
kjuulh 526b2b7461
refactor: move doctor command
Signed-off-by: kjuulh <contact@kjuulh.io>
2023-08-01 17:15:58 +02:00

27 lines
653 B
Rust

use cuddle_please_misc::DynUi;
pub struct DoctorCommandHandler {
ui: DynUi,
}
impl DoctorCommandHandler {
pub fn new(ui: DynUi) -> Self {
Self { ui }
}
pub fn execute(&self) -> anyhow::Result<()> {
match std::process::Command::new("git").arg("-v").output() {
Ok(o) => {
let stdout = std::str::from_utf8(&o.stdout).unwrap_or("");
self.ui.write_str_ln(&format!("OK: {}", stdout));
}
Err(e) => {
self.ui
.write_str_ln(&format!("WARNING: git is not installed: {}", e));
}
}
Ok(())
}
}