Skip to content

Commit

Permalink
theme: 🔨 try yml if yaml theme file not found
Browse files Browse the repository at this point in the history
Signed-off-by: zwPapEr <[email protected]>
  • Loading branch information
zwpaper committed Sep 13, 2021
1 parent 9377613 commit bb6e7f9
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/color/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,30 @@ impl Theme {
config_file::Config::config_file_path()?
.join("themes")
.join(real)
.with_extension("yaml")
};
match fs::read(&path) {
match fs::read(&path.with_extension("yaml")) {
Ok(f) => match Self::with_yaml(&String::from_utf8_lossy(&f)) {
Ok(t) => Some(t),
Err(e) => {
print_error!("Theme file {} format error: {}.", &file, e);
None
}
},
Err(e) => {
print_error!("Not a valid theme: {}, {}.", path.to_string_lossy(), e);
None
Err(_) => {
// try `yml` if `yaml` extension file not found
match fs::read(&path.with_extension("yml")) {
Ok(f) => match Self::with_yaml(&String::from_utf8_lossy(&f)) {
Ok(t) => Some(t),
Err(e) => {
print_error!("Theme file {} format error: {}.", &file, e);
None
}
},
Err(e) => {
print_error!("Not a valid theme: {}, {}.", path.to_string_lossy(), e);
None
}
}
}
}
}
Expand Down

0 comments on commit bb6e7f9

Please sign in to comment.