mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-27 15:28:43 +00:00
Add support for NO_COLOR env var (#1021)
This commit is contained in:
parent
6f88ba0e6f
commit
8b481dd41f
@ -1,6 +1,9 @@
|
|||||||
# unreleased
|
# unreleased
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
- Added support for the `NO_COLOR` environment variable, see #1021 and #1031 (@eth-p)
|
||||||
|
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
## Other
|
## Other
|
||||||
## New syntaxes
|
## New syntaxes
|
||||||
|
@ -165,7 +165,7 @@ impl App {
|
|||||||
colored_output: match self.matches.value_of("color") {
|
colored_output: match self.matches.value_of("color") {
|
||||||
Some("always") => true,
|
Some("always") => true,
|
||||||
Some("never") => false,
|
Some("never") => false,
|
||||||
Some("auto") | _ => self.interactive_output,
|
Some("auto") | _ => env::var_os("NO_COLOR").is_none() && self.interactive_output,
|
||||||
},
|
},
|
||||||
paging_mode,
|
paging_mode,
|
||||||
term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize),
|
term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize),
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use clap::{crate_name, crate_version, App as ClapApp, AppSettings, Arg, ArgGroup, SubCommand};
|
use clap::{crate_name, crate_version, App as ClapApp, AppSettings, Arg, ArgGroup, SubCommand};
|
||||||
|
use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||||
let clap_color_setting = if interactive_output {
|
let clap_color_setting = if interactive_output && env::var_os("NO_COLOR").is_none() {
|
||||||
AppSettings::ColoredHelp
|
AppSettings::ColoredHelp
|
||||||
} else {
|
} else {
|
||||||
AppSettings::ColorNever
|
AppSettings::ColorNever
|
||||||
|
Loading…
x
Reference in New Issue
Block a user