1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-08 19:41:45 +00:00

Fix padding, add --wrap argument, disable wrap for non-tty. (Fixed)

I'm not quite sure what was up with git on that last commit, but it's
all properly committed now.
This commit is contained in:
eth-p
2018-05-12 13:44:10 -07:00
parent cd26d403a3
commit d4b438b9d3
3 changed files with 43 additions and 4 deletions
+18 -1
View File
@@ -80,6 +80,14 @@ impl App {
.default_value("auto")
.help("When to use the pager"),
)
.arg(
Arg::with_name("wrap")
.long("wrap")
.takes_value(true)
.possible_values(&["character", "never"])
.default_value("character")
.help("When to wrap text"),
)
.arg(
Arg::with_name("list-languages")
.long("list-languages")
@@ -135,7 +143,16 @@ impl App {
true_color: is_truecolor_terminal(),
output_components: self.output_components()?,
language: self.matches.value_of("language"),
output_wrap: OutputWrap::Character,
output_wrap: if ! self.interactive_output {
// We don't have the tty width when piping to another program.
// There's no point in wrapping when this is the case.
OutputWrap::None
} else {
match self.matches.value_of("wrap") {
Some("character") => OutputWrap::Character,
Some("never") | _ => OutputWrap::None,
}
},
colored_output: match self.matches.value_of("color") {
Some("always") => true,
Some("never") => false,