Skip to content

Commit

Permalink
Merge pull request #14 from cheap-glitch/support-config.yml
Browse files Browse the repository at this point in the history
Add support for config file with `.yml` extension
  • Loading branch information
AndrewRadev authored Feb 27, 2022
2 parents e74ad1c + feba59a commit 8580cfb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ impl Config {
///
pub fn load() -> Option<Self> {
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| {
Expand Down

0 comments on commit 8580cfb

Please sign in to comment.