use clap::Subcommand;
use crate::service::ServiceAction;
#[derive(Subcommand, Debug, Clone)]
pub enum ServiceCommand {
Install,
Start,
Stop,
Status,
Uninstall,
}
impl ServiceCommand {
pub fn to_action(&self) -> ServiceAction {
match self {
ServiceCommand::Install => ServiceAction::Install,
ServiceCommand::Start => ServiceAction::Start,
ServiceCommand::Stop => ServiceAction::Stop,
ServiceCommand::Status => ServiceAction::Status,
ServiceCommand::Uninstall => ServiceAction::Uninstall,
}
}
}
pub fn run_service_command(cmd: &ServiceCommand) -> anyhow::Result<()> {
crate::service::handle_command(&cmd.to_action())
}