aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/config.rs b/src/config.rs
index dcc44d7..10b358b 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -41,17 +41,20 @@ pub fn config() -> config::Config {
crate::dirs::Dirs::new().config_file(CONFIG_FILENAME);
let mut config = config::Config::default();
- if let Err(e) = config.merge(config::File::from(config_filename.clone()))
- {
- log::warn!(
- "failed to read config file {}: {}",
- config_filename.to_string_lossy(),
- e
- );
- // if merge returns an error, the config source will still have been
- // added to the config object, so the config object will likely never
- // work, so we should recreate it from scratch.
- config = config::Config::default();
+ if let Some(config_filename) = config_filename {
+ if let Err(e) =
+ config.merge(config::File::from(config_filename.clone()))
+ {
+ log::warn!(
+ "failed to read config file {}: {}",
+ config_filename.to_string_lossy(),
+ e
+ );
+ // if merge returns an error, the config source will still have been
+ // added to the config object, so the config object will likely never
+ // work, so we should recreate it from scratch.
+ config = config::Config::default();
+ }
}
config