diff --git a/crates/cuddle-please-commands/src/command.rs b/crates/cuddle-please-commands/src/command.rs index 9161401..5b5c3bb 100644 --- a/crates/cuddle-please-commands/src/command.rs +++ b/crates/cuddle-please-commands/src/command.rs @@ -14,6 +14,7 @@ use cuddle_please_misc::{ use crate::{ config_command::{ConfigCommand, ConfigCommandHandler}, + doctor_command::DoctorCommandHandler, gitea_command::{GiteaCommand, GiteaCommandHandler}, release_command::ReleaseCommandHandler, }; @@ -96,7 +97,6 @@ impl Command { ReleaseCommandHandler::new(config, git_client, gitea_client) .execute(self.global.dry_run)?; } - Some(Commands::Config { command }) => { ConfigCommandHandler::new(self.ui, config).execute(command)?; } @@ -105,16 +105,7 @@ impl Command { .execute(command, self.global.token.expect("token to be set").deref())?; } Some(Commands::Doctor {}) => { - 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)); - } - } + DoctorCommandHandler::new(self.ui).execute()?; } None => {} } diff --git a/crates/cuddle-please-commands/src/doctor_command.rs b/crates/cuddle-please-commands/src/doctor_command.rs new file mode 100644 index 0000000..22efe77 --- /dev/null +++ b/crates/cuddle-please-commands/src/doctor_command.rs @@ -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(()) + } +} diff --git a/crates/cuddle-please-commands/src/lib.rs b/crates/cuddle-please-commands/src/lib.rs index 1e2c4d6..ca3d3d6 100644 --- a/crates/cuddle-please-commands/src/lib.rs +++ b/crates/cuddle-please-commands/src/lib.rs @@ -1,5 +1,6 @@ mod command; mod config_command; +mod doctor_command; mod gitea_command; mod release_command;