refactor: move doctor command
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
26
crates/cuddle-please-commands/src/doctor_command.rs
Normal file
26
crates/cuddle-please-commands/src/doctor_command.rs
Normal 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(())
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user