1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-31 18:21:43 +00:00

Merge pull request #102 from eth-p/master

Added text wrapping. (Fixes #54)
This commit is contained in:
David Peter
2018-05-16 08:41:49 +02:00
committed by GitHub
12 changed files with 497 additions and 247 deletions
+20 -1
View File
@@ -4,7 +4,7 @@ use console::Term;
use errors::*;
use std::collections::HashSet;
use std::env;
use style::{OutputComponent, OutputComponents};
use style::{OutputComponent, OutputComponents, OutputWrap};
#[cfg(windows)]
use ansi_term;
@@ -86,6 +86,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")
@@ -141,6 +149,16 @@ impl App {
true_color: is_truecolor_terminal(),
output_components: self.output_components()?,
language: self.matches.value_of("language"),
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,
@@ -197,6 +215,7 @@ impl App {
pub struct Config<'a> {
pub true_color: bool,
pub output_wrap: OutputWrap,
pub output_components: OutputComponents,
pub language: Option<&'a str>,
pub colored_output: bool,