From feba59a54795ce065c2dd1e8ce78f10e6a564564 Mon Sep 17 00:00:00 2001 From: cheap-glitch Date: Sat, 12 Feb 2022 19:43:10 +0100 Subject: [PATCH] Add support for config file with `.yml` extension --- src/input.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/input.rs b/src/input.rs index 17f3144..3c56221 100644 --- a/src/input.rs +++ b/src/input.rs @@ -118,8 +118,12 @@ impl Config { /// pub fn load() -> Option { let yaml_path = Self::yaml_path(); - let config_file = File::open(&yaml_path).map_err(|_| { - debug!("Didn't find config file: {}", yaml_path.display()); + let config_file = File::open(&yaml_path).or_else(|_| { + // If "config.yaml" is missing, check for "config.yml" just in case + let yml_path = yaml_path.with_extension("yml"); + File::open(&yml_path).map_err(|_| { + debug!("Didn't find config file: {} (or {})", yaml_path.display(), yml_path.display()); + }) }).ok()?; serde_yaml::from_reader(&config_file).map_err(|e| {