mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-02-03 19:18:24 +00:00
[no-color] - implement NO_COLOR support
This commit is contained in:
parent
b32f441851
commit
aab1d3db59
3
.gitignore
vendored
3
.gitignore
vendored
@ -19,3 +19,6 @@ parts
|
||||
prime
|
||||
stage
|
||||
*.snap
|
||||
|
||||
# IntelliJ IDEA files
|
||||
.idea
|
||||
|
@ -5,7 +5,7 @@ use crate::theme::{Options, UseColours, ColourScale, Definitions};
|
||||
|
||||
impl Options {
|
||||
pub fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
|
||||
let use_colours = UseColours::deduce(matches)?;
|
||||
let use_colours = UseColours::deduce(matches, vars)?;
|
||||
let colour_scale = ColourScale::deduce(matches)?;
|
||||
|
||||
let definitions = if use_colours == UseColours::Never {
|
||||
@ -21,10 +21,15 @@ impl Options {
|
||||
|
||||
|
||||
impl UseColours {
|
||||
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
|
||||
fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
|
||||
let default_value = match vars.get(vars::NO_COLOR) {
|
||||
Some(_) => Self::Never,
|
||||
None => Self::Automatic,
|
||||
};
|
||||
|
||||
let word = match matches.get_where(|f| f.matches(&flags::COLOR) || f.matches(&flags::COLOUR))? {
|
||||
Some(w) => w,
|
||||
None => return Ok(Self::Automatic),
|
||||
None => return Ok(default_value),
|
||||
};
|
||||
|
||||
if word == "always" {
|
||||
|
@ -15,6 +15,9 @@ pub static COLUMNS: &str = "COLUMNS";
|
||||
/// Environment variable used to datetime format.
|
||||
pub static TIME_STYLE: &str = "TIME_STYLE";
|
||||
|
||||
/// Environment variable used to disable colors.
|
||||
/// See: https://no-color.org/
|
||||
pub static NO_COLOR: &str = "NO_COLOR";
|
||||
|
||||
// exa-specific variables
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user