[][src]Trait clappconfig::AppConfig

pub trait AppConfig: Sized + Serialize + DeserializeOwned + Debug + Default {
    type Init;
    fn logging(&self) -> &str;
fn configure<'a>(self, _clap: &ArgMatches<'a>) -> Result<Self::Init>; fn print_banner(name: &str, version: &str) { ... }
fn pre_log_println(message: String) { ... }
fn logging_suppress_mods(&self) -> Option<Vec<&str>> { ... }
fn logging_mod_levels(&self) -> Option<&HashMap<String, String>> { ... }
fn add_args<'a: 'b, 'b>(clap: App<'a, 'b>) -> App<'a, 'b> { ... }
fn on_config_file_found(&mut self, _path: &PathBuf) { ... }
fn init(
        name: &str,
        cfg_file_name: &str,
        version: &str
    ) -> Result<Self::Init> { ... } }

Implement this for the main config struct

Associated Types

type Init

Loading content...

Required methods

fn logging(&self) -> &str

Get log level

fn configure<'a>(self, _clap: &ArgMatches<'a>) -> Result<Self::Init>

Configure the config object using args. Logging has already been inited and configured.

Loading content...

Provided methods

fn print_banner(name: &str, version: &str)

Print startup banner. May be overridden to customize or disable it.

fn pre_log_println(message: String)

Log messages printed before logging is set up May be overridden to customize or disable it.

fn logging_suppress_mods(&self) -> Option<Vec<&str>>

Get names of library modules to suppress from log output (limit to warn or error)

fn logging_mod_levels(&self) -> Option<&HashMap<String, String>>

Get log module levels to use (take priority over the main log level)

fn add_args<'a: 'b, 'b>(clap: App<'a, 'b>) -> App<'a, 'b>

Add args to later use in the configure method.

fn on_config_file_found(&mut self, _path: &PathBuf)

Called when the config file is resolved, e.g. to store it in Config for later relative path resolution

fn init(name: &str, cfg_file_name: &str, version: &str) -> Result<Self::Init>

Initialize the app

Use env!("CARGO_PKG_VERSION") to get a version string from Cargo.toml

Loading content...

Implementors

Loading content...