summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorextrawurst <776816+extrawurst@users.noreply.github.com>2024-02-20 18:52:35 +0100
committerGitHub <noreply@github.com>2024-02-20 18:52:35 +0100
commit762b889b4848f6bf12515cc1ad74da7d71f52334 (patch)
treefd4a720e815d56775060defcef492f2327c1c00b /src
parent2b39c6465aa01b06600040053fe3086f92590692 (diff)
better theme file handling (#2077)
* better theme file handling * print all possible err of loading theme closes #2007
Diffstat (limited to 'src')
-rw-r--r--src/args.rs11
-rw-r--r--src/ui/style.rs13
2 files changed, 9 insertions, 15 deletions
diff --git a/src/args.rs b/src/args.rs
index 0a45fb28..2effe5fc 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -48,11 +48,7 @@ pub fn process_cmdline() -> Result<CliArgs> {
.get_one::<String>("theme")
.map_or_else(|| PathBuf::from("theme.ron"), PathBuf::from);
- let theme = if get_app_config_path()?.join(&arg_theme).is_file() {
- get_app_config_path()?.join(arg_theme)
- } else {
- get_app_config_path()?.join("theme.ron")
- };
+ let theme = get_app_config_path()?.join(arg_theme);
let notify_watcher: bool =
*arg_matches.get_one("watcher").unwrap_or(&false);
@@ -82,10 +78,11 @@ fn app() -> ClapApp {
)
.arg(
Arg::new("theme")
- .help("Set the color theme (defaults to theme.ron)")
+ .help("Set color theme filename loaded from config directory")
.short('t')
.long("theme")
- .value_name("THEME")
+ .value_name("THEME_FILE")
+ .default_value("theme.ron")
.num_args(1),
)
.arg(
diff --git a/src/ui/style.rs b/src/ui/style.rs
index b86c2d6f..c00137b7 100644
--- a/src/ui/style.rs
+++ b/src/ui/style.rs
@@ -274,13 +274,7 @@ impl Theme {
fn load_patch(theme_path: &PathBuf) -> Result<ThemePatch> {
let file = File::open(theme_path)?;
- let load_result = ron::de::from_reader(file);
-
- if let Err(e) = &load_result {
- log::error!("theme error [{:?}]: {e}", theme_path);
- }
-
- Ok(load_result?)
+ Ok(ron::de::from_reader(file)?)
}
fn load_old_theme(theme_path: &PathBuf) -> Result<Self> {
@@ -303,7 +297,10 @@ impl Theme {
pub fn init(theme_path: &PathBuf) -> Self {
let mut theme = Self::default();
- if let Ok(patch) = Self::load_patch(theme_path) {
+ if let Ok(patch) = Self::load_patch(theme_path).map_err(|e| {
+ log::error!("theme error [{:?}]: {e}", theme_path);
+ e
+ }) {
theme.apply(patch);
} else if let Ok(old_theme) = Self::load_old_theme(theme_path)
{