use clap::ArgMatches; use qsu::{installer::RegSvc, rt::SrvAppRt, AppErr}; use crate::err::Error; pub(crate) struct AppArgsProc { pub(crate) bldr: Box SrvAppRt> } impl qsu::argp::ArgsProc for AppArgsProc { /// Process an `register-service` subcommand. fn proc_inst( &mut self, _sub_m: &ArgMatches, regsvc: RegSvc ) -> Result { // This is split out into its own function because the orphan rule wouldn't // allow the application to implement a std::io::Error -> qsu::AppErr // conversion in one go, so we do it in two steps instead. // proc_inst_inner()'s '?' converts "all" errors into 'Error`. // The proc_inst() method's `?` converts from `Error` to `qsu::AppError` Ok(proc_inst_inner(regsvc)?) } fn build_apprt(&mut self) -> Result { Ok((self.bldr)()) } } fn proc_inst_inner(regsvc: RegSvc) -> Result { // Use current working directory as the service's workdir let cwd = std::env::current_dir()?.to_str().unwrap().to_string(); let regsvc = regsvc .workdir(cwd) .env("HOLY", "COW") .env("Private", "Public") .env("General", "Specific"); // Add a callback that will increase log and trace levels by deafault. #[cfg(windows)] let regsvc = regsvc.regconf(|_svcname, params| { params.set_value("AppArgParser", &"SaysHello")?; Ok(()) }); Ok(regsvc) } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :