2023-08-01 17:11:59 +02:00
|
|
|
use clap::Subcommand;
|
2023-08-01 17:01:00 +02:00
|
|
|
use cuddle_please_frontend::PleaseConfig;
|
|
|
|
use cuddle_please_misc::DynUi;
|
|
|
|
|
2023-08-01 17:11:59 +02:00
|
|
|
#[derive(Subcommand, Debug, Clone)]
|
|
|
|
pub enum ConfigCommand {
|
|
|
|
/// List will list the final configuration
|
|
|
|
List {},
|
|
|
|
}
|
2023-08-01 17:01:00 +02:00
|
|
|
|
|
|
|
pub struct ConfigCommandHandler {
|
|
|
|
ui: DynUi,
|
|
|
|
config: PleaseConfig,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ConfigCommandHandler {
|
|
|
|
pub fn new(ui: DynUi, config: PleaseConfig) -> Self {
|
|
|
|
Self { ui, config }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn execute(&self, command: &ConfigCommand) -> anyhow::Result<()> {
|
|
|
|
match command {
|
|
|
|
ConfigCommand::List {} => {
|
|
|
|
tracing::debug!("running command: config list");
|
|
|
|
|
|
|
|
self.ui.write_str_ln("cuddle-config");
|
|
|
|
self.ui.write_str(&format!("{}", self.config));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|