diff --git a/src/config.rs b/src/config.rs index 92d4a73..08e8d5f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -250,6 +250,17 @@ impl Config { } } +/// Load and validate the application configuration. +/// +/// This uses the `confy` crate to load the configuration from a file +/// (e.g. `~/.config/gman/config.yaml`). If the file does +/// not exist, a default configuration is created and saved. +/// +/// ```no_run +/// # use gman::config::load_config; +/// let config = load_config().unwrap(); +/// println!("loaded config: {:?}", config); +/// ``` pub fn load_config() -> Result { let mut config: Config = confy::load("gman", "config")?; config.validate()?; @@ -268,3 +279,8 @@ pub fn load_config() -> Result { Ok(config) } + +/// Returns the configuration file path that `confy` will use for this app. +pub fn get_config_file_path() -> Result { + Ok(confy::get_configuration_file_path("gman", "config")?) +}