Skip to content

Commit 72c2c74

Browse files
committed
fix: support additional yaml file extension, clippy
1 parent 5ac404e commit 72c2c74

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

src/options/config.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -628,43 +628,43 @@ mod tests {
628628

629629
#[test]
630630
fn parse_none_color_from_string() {
631-
["", "none", "None"].iter().for_each(|case| {
631+
for case in &["", "none", "None"] {
632632
assert_eq!(color_from_str(case), None);
633-
});
633+
}
634634
}
635635

636636
#[test]
637637
fn parse_default_color_from_string() {
638-
["default", "Default"].iter().for_each(|case| {
638+
for case in &["default", "Default"] {
639639
assert_eq!(color_from_str(case), Some(Color::Default));
640-
});
640+
}
641641
}
642642

643643
#[test]
644644
fn parse_fixed_color_from_string() {
645-
["black", "Black"].iter().for_each(|case| {
645+
for case in &["black", "Black"] {
646646
assert_eq!(color_from_str(case), Some(Color::Black));
647-
});
647+
}
648648
}
649649

650650
#[test]
651651
fn parse_long_hex_color_from_string() {
652-
["#ff00ff", "#FF00FF"].iter().for_each(|case| {
652+
for case in &["#ff00ff", "#FF00FF"] {
653653
assert_eq!(color_from_str(case), Some(Color::Rgb(255, 0, 255)));
654-
});
654+
}
655655
}
656656

657657
#[test]
658658
fn parse_short_hex_color_from_string() {
659-
["#f0f", "#F0F"].iter().for_each(|case| {
659+
for case in ["#f0f", "#F0F"].iter() {
660660
assert_eq!(color_from_str(case), Some(Color::Rgb(255, 0, 255)));
661-
});
661+
}
662662
}
663663

664664
#[test]
665665
fn parse_color_code_from_string() {
666-
[("10", 10), ("01", 1)].iter().for_each(|(s, c)| {
666+
for (s, c) in &[("10", 10), ("01", 1)] {
667667
assert_eq!(color_from_str(s), Some(Color::Fixed(*c)));
668-
});
668+
}
669669
}
670670
}

src/options/theme.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,26 @@ impl Options {
3535

3636
impl ThemeConfig {
3737
fn deduce<V: Vars>(vars: &V) -> Option<Self> {
38-
if let Some(path) = vars.get("EZA_CONFIG_DIR") {
39-
let path = PathBuf::from(path);
40-
let path = path.join("theme.yml");
41-
if path.exists() {
42-
Some(ThemeConfig::from_path(&path.to_string_lossy()))
43-
} else {
44-
None
45-
}
38+
let (base_path, is_default_location) = if let Some(path) = vars.get("EZA_CONFIG_DIR") {
39+
(PathBuf::from(path), false)
40+
} else if let Some(path) = dirs::config_dir() {
41+
(path.join("eza"), true)
4642
} else {
47-
let path = dirs::config_dir().unwrap_or_default();
48-
let path = path.join("eza").join("theme.yml");
49-
if path.exists() {
50-
Some(ThemeConfig::default())
43+
return None;
44+
};
45+
let yml_path = base_path.join("theme.yml");
46+
if yml_path.exists() {
47+
return if is_default_location {
48+
Some(ThemeConfig::from_path(&yml_path.to_string_lossy()))
5149
} else {
52-
None
53-
}
50+
Some(ThemeConfig::default())
51+
};
52+
}
53+
let yaml_path = base_path.join("theme.yaml");
54+
if yaml_path.exists() {
55+
return Some(ThemeConfig::from_path(&yaml_path.to_string_lossy()));
5456
}
57+
None
5558
}
5659
}
5760

0 commit comments

Comments
 (0)