use crate::{commands::EntryPoint, config::OrganizeConfig};
use abscissa_core::{
application::{self, AppCell},
config::{self, CfgCell},
trace, Application, FrameworkError, StandardPaths,
};
pub static ORGANIZE_APP: AppCell<OrganizeApp> = AppCell::new();
#[derive(Debug)]
pub struct OrganizeApp {
config: CfgCell<OrganizeConfig>,
state: application::State<Self>,
}
impl Default for OrganizeApp {
fn default() -> Self {
Self {
config: CfgCell::default(),
state: application::State::default(),
}
}
}
impl Application for OrganizeApp {
type Cmd = EntryPoint;
type Cfg = OrganizeConfig;
type Paths = StandardPaths;
fn config(&self) -> config::Reader<OrganizeConfig> {
self.config.read()
}
fn state(&self) -> &application::State<Self> {
&self.state
}
fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> {
let framework_components = self.framework_components(command)?;
let mut app_components = self.state.components_mut();
app_components.register(framework_components)
}
fn after_config(&mut self, config: Self::Cfg) -> Result<(), FrameworkError> {
self.state.components_mut().after_config(&config)?;
self.config.set_once(config);
Ok(())
}
fn tracing_config(&self, _command: &EntryPoint) -> trace::Config {
trace::Config::default()
}
}