refactor: move doctor command

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-01 17:15:58 +02:00
parent af5d0f4af5
commit 526b2b7461
3 changed files with 29 additions and 11 deletions

View File

@@ -0,0 +1,26 @@
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(())
}
}