1
0
mirror of https://github.com/sharkdp/bat.git synced 2024-10-06 02:41:06 +01:00

Use 'plain' style for non-interactive terminals

This commit is contained in:
sharkdp 2018-05-06 15:48:19 +02:00 committed by David Peter
parent 3fa70deaa7
commit 15f0268bdc

View File

@ -486,8 +486,8 @@ fn run() -> Result<()> {
Arg::with_name("style") Arg::with_name("style")
.short("s") .short("s")
.long("style") .long("style")
.possible_values(&["plain", "line-numbers", "full"]) .possible_values(&["auto", "plain", "line-numbers", "full"])
.default_value("full") .default_value("auto")
.help("Additional info to display along with content"), .help("Additional info to display along with content"),
) )
.arg( .arg(
@ -515,10 +515,15 @@ fn run() -> Result<()> {
_ => { _ => {
let options = Options { let options = Options {
true_color: is_truecolor_terminal(), true_color: is_truecolor_terminal(),
style: match app_matches.value_of("style").unwrap() { style: match app_matches.value_of("style") {
"plain" => OptionsStyle::Plain, Some("plain") => OptionsStyle::Plain,
"line-numbers" => OptionsStyle::LineNumbers, Some("line-numbers") => OptionsStyle::LineNumbers,
_ => OptionsStyle::Full, Some("full") => OptionsStyle::Full,
Some("auto") | _ => if interactive_terminal {
OptionsStyle::Full
} else {
OptionsStyle::Plain
},
}, },
language: app_matches.value_of("language"), language: app_matches.value_of("language"),
interactive_terminal, interactive_terminal,