//! `start` subcommand - example of how to write a subcommand
/// App-local prelude includes `app_reader()`/`app_writer()`/`app_config()`
/// accessors along with logging macros. Customize as you see fit.
use crate::prelude::*;
use crate::config::{{~config_type~}};
use abscissa_core::{Command, FrameworkError, Runnable, config};
/// `start` subcommand
///
/// The `Parser` proc macro generates an option parser based on the struct
/// definition, and is defined in the `clap` crate. See their documentation
/// for a more comprehensive example:
///
/// <https://docs.rs/clap/>
#[derive(clap::Parser, Command, Debug)]
pub struct StartCmd {
/// To whom are we saying hello?
recipient: Vec<String>,
}
impl Runnable for StartCmd {
/// Start the application.
fn run(&self) {
let config = APP.config();
println!("Hello, {}!", &config.hello.recipient);
}
}
impl config::Override<{{~config_type~}}> for StartCmd {
// Process the given command line options, overriding settings from
// a configuration file using explicit flags taken from command-line
// arguments.
fn override_config(
&self,
mut config: {{config_type}},
) -> Result<{{config_type}}, FrameworkError> {
if !self.recipient.is_empty() {
config.hello.recipient = self.recipient.join(" ");
}
Ok(config)
}
}