1
0
Эх сурвалжийг харах

feat: create EZA_ICONS_AUTO environment variable

Ryan Breaker 2 жил өмнө
parent
commit
02441e5d81

+ 2 - 2
man/eza.1.md

@@ -304,9 +304,9 @@ Overrides any `--git` or `--git-repos` argument
 
 ## `EZA_ICONS_AUTO`
 
-If set to `true`, automates the same behavior as `--icons` or `--icons=auto`. Useful for if you always want to have icons enabled.
+If set, automates the same behavior as using `--icons` or `--icons=auto`. Useful for if you always want to have icons enabled.
 
-Any use of the `--icons=WHEN` flag overrides this. 
+Any explicit use of the `--icons=WHEN` flag overrides this behavior. 
 
 
 EXIT STATUSES

+ 1 - 4
src/options/file_name.rs

@@ -1,7 +1,6 @@
 use crate::options::parser::MatchedFlags;
 use crate::options::vars::{self, Vars};
 use crate::options::{flags, NumberSource, OptionsError};
-use std::ffi::OsString;
 
 use crate::output::file_name::{Classify, EmbedHyperlinks, Options, QuoteStyle, ShowIcons};
 
@@ -46,9 +45,7 @@ impl ShowIcons {
             Automatic,
         }
 
-        let force_icons = vars
-            .get(vars::EZA_ICONS_AUTO)
-            .eq(&Some(OsString::from("true")));
+        let force_icons = vars.get(vars::EZA_ICONS_AUTO).is_some();
         let mode_opt = matches.get(&flags::ICONS)?;
         if !force_icons && !matches.has(&flags::ICONS)? && mode_opt.is_none() {
             return Ok(Self::Never);

+ 2 - 0
src/options/vars.rs

@@ -55,6 +55,8 @@ pub static EZA_ICON_SPACING: &str = "EZA_ICON_SPACING";
 pub static EXA_OVERRIDE_GIT: &str = "EXA_OVERRIDE_GIT";
 pub static EZA_OVERRIDE_GIT: &str = "EZA_OVERRIDE_GIT";
 
+/// Environment variable used to automate the same behavior as `--icons=auto` if set.
+/// Any explicit use of `--icons=WHEN` overrides this behavior.
 pub static EZA_ICONS_AUTO: &str = "EZA_ICONS_AUTO";
 
 /// Mockable wrapper for `std::env::var_os`.