aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs
index b54f8f1..5c76c6a 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -21,8 +21,21 @@ pub fn load_config() -> Result<Config, Error> {
}
};
file.read_to_string(&mut data)?;
- let yml_content = &YamlLoader::load_from_str(&data).unwrap()[0];
- let config = parse_config(yml_content);
+
+ // checking if rsblocks.yml is empty
+ let yml_content = match YamlLoader::load_from_str(&data) {
+ Ok(content) => {
+ if content.len() > 0 {
+ content[0].clone()
+ } else {
+ eprintln!("configuration file looks empty, loading defaults!");
+ return Ok(load_defaults());
+ }
+ }
+ _ => return Ok(load_defaults()),
+ };
+
+ let config = parse_config(&yml_content);
Ok(config)
}