use clap::CommandFactory; use clap_complete::{Shell, generate}; use crate::cli::{CommandLine, ServiceCommand}; pub(super) fn run_service_command(command: ServiceCommand) -> anyhow::Result<()> { match command { ServiceCommand::Install => { let unit_path = crate::service::install()?; println!("Installed and started Appa at {}.", unit_path.display()); } ServiceCommand::Status => crate::service::status()?, ServiceCommand::Restart => { crate::service::restart()?; println!("Restarted the Appa user service."); } ServiceCommand::Logs => crate::service::logs()?, ServiceCommand::Uninstall => { if crate::service::uninstall()? { println!("Stopped and removed the Appa user service."); } else { println!("The Appa user service is not installed."); } } } Ok(()) } pub(super) fn print_completions(shell: Shell) { let mut command = CommandLine::command(); let command_name = command.get_name().to_owned(); generate(shell, &mut command, command_name, &mut std::io::stdout()); }