Просмотр исходного кода

fix: imports and merge conflicts

PThorpe92 1 год назад
Родитель
Сommit
c484244b4b
3 измененных файлов с 26 добавлено и 2 удалено
  1. 1 1
      src/options/error.rs
  2. 24 1
      src/options/theme.rs
  3. 1 0
      src/output/details.rs

+ 1 - 1
src/options/error.rs

@@ -99,7 +99,7 @@ impl fmt::Display for OptionsError {
             Self::TreeAllAll                 => write!(f, "Option --tree is useless given --all --all"),
             Self::FailedParse(s, n, e)       => write!(f, "Value {s:?} not valid for {n}: {e}"),
             Self::FailedGlobPattern(ref e)   => write!(f, "Failed to parse glob pattern: {e}"),
-            Self::WriteTheme(ref e)          => write!(f, "Failed to write theme file: {e}"),
+            Self::WriteTheme(ref e)          => write!(f, "Error writing theme file to disk: {e}"),
         };
     }
 }

+ 24 - 1
src/options/theme.rs

@@ -9,7 +9,8 @@ impl Options {
     pub fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
         let use_colours = UseColours::deduce(matches, vars)?;
         let colour_scale = ColorScaleOptions::deduce(matches, vars)?;
-        let theme_config = ThemeConfig::deduce(matches, vars, colour_scale)?;
+        let theme_config = ThemeConfig::deduce(vars);
+
         let definitions = if use_colours == UseColours::Never {
             Definitions::default()
         } else {
@@ -25,6 +26,28 @@ impl Options {
     }
 }
 
+impl ThemeConfig {
+    fn deduce<V: Vars>(vars: &V) -> Option<Self> {
+        if let Some(path) = vars.get("EZA_CONFIG_DIR") {
+            let path = PathBuf::from(path);
+            let path = path.join("theme.yml");
+            if path.exists() {
+                Some(ThemeConfig::from_path(&path.to_string_lossy()))
+            } else {
+                None
+            }
+        } else {
+            let path = dirs::config_dir().unwrap_or_default();
+            let path = path.join("eza").join("theme.yml");
+            if path.exists() {
+                Some(ThemeConfig::default())
+            } else {
+                None
+            }
+        }
+    }
+}
+
 impl UseColours {
     fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
         let default_value = match vars.get(vars::NO_COLOR) {

+ 1 - 0
src/output/details.rs

@@ -64,6 +64,7 @@ use std::path::PathBuf;
 use std::vec::IntoIter as VecIntoIter;
 
 use nu_ansi_term::Style;
+use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
 use rayon::prelude::*;
 
 use log::*;