Add 'nocolor' option for output.

This maintains most output styles, but removes coloring from output. On Windows,
this is the default setting if Full would have been used
This commit is contained in:
Steve Pentland authored and David Peter committed 2018-02-20 21:42:47 +01:00
1 parent faff3e680e
commit faf00b6985
2 files changed
+17 -5

No files matched your search

+12 -3
View File
@@ -115,11 +115,12 @@ fn main() {
.short("s")
.takes_value(true)
.value_name("TYPE")
.possible_values(&["auto", "basic", "full"])
.possible_values(&["auto", "basic", "full", "nocolor"])
.help(
"Set output style type (default: auto). Set this to 'basic' to disable output \
coloring and interactive elements. Set it to 'full' to enable all effects \
even if no interactive terminal was detected.",
even if no interactive terminal was detected. Setting to 'nocolor' maintains \
all advanced output, but uses no colorization.",
),
)
.arg(
@@ -149,6 +150,7 @@ fn main() {
options.output_style = match matches.value_of("style") {
Some("full") => OutputStyleOption::Full,
Some("basic") => OutputStyleOption::Basic,
Some("nocolor") => OutputStyleOption::NoColor,
_ => if atty::is(Stream::Stdout) {
OutputStyleOption::Full
} else {
@@ -156,7 +158,14 @@ fn main() {
},
};
if options.output_style == OutputStyleOption::Basic {
// We default Windows to NoColor if full or auto had been specified.
if cfg!(windows) && options.output_style == OutputStyleOption::Full {
options.output_style = OutputStyleOption::NoColor;
}
if options.output_style == OutputStyleOption::Basic
|| options.output_style == OutputStyleOption::NoColor
{
colored::control::set_override(false);
}