mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-22 04:48:48 +00:00
Added -S flag for truncating long lines
This commit is contained in:
parent
6680f65e4b
commit
a272d3df16
@ -161,6 +161,7 @@ impl App {
|
|||||||
}),
|
}),
|
||||||
show_nonprintable: self.matches.get_flag("show-all"),
|
show_nonprintable: self.matches.get_flag("show-all"),
|
||||||
wrapping_mode: if self.interactive_output || maybe_term_width.is_some() {
|
wrapping_mode: if self.interactive_output || maybe_term_width.is_some() {
|
||||||
|
if !self.matches.contains_id("chop-long-lines") {
|
||||||
match self.matches.get_one::<String>("wrap").map(|s| s.as_str()) {
|
match self.matches.get_one::<String>("wrap").map(|s| s.as_str()) {
|
||||||
Some("character") => WrappingMode::Character,
|
Some("character") => WrappingMode::Character,
|
||||||
Some("never") => WrappingMode::NoWrapping(true),
|
Some("never") => WrappingMode::NoWrapping(true),
|
||||||
@ -173,6 +174,10 @@ impl App {
|
|||||||
}
|
}
|
||||||
_ => unreachable!("other values for --wrap are not allowed"),
|
_ => unreachable!("other values for --wrap are not allowed"),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WrappingMode::NoWrapping(true)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// We don't have the tty width when piping to another program.
|
// We don't have the tty width when piping to another program.
|
||||||
// There's no point in wrapping when this is the case.
|
// There's no point in wrapping when this is the case.
|
||||||
|
@ -201,6 +201,13 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
|
|||||||
The '--terminal-width' option can be used in addition to \
|
The '--terminal-width' option can be used in addition to \
|
||||||
control the output width."),
|
control the output width."),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("chop-long-lines")
|
||||||
|
.long("chop-long-lines")
|
||||||
|
.short('S')
|
||||||
|
.takes_value(false)
|
||||||
|
.help("Truncate all lines longer than screen width. Alias for '--wrap=never'."),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("terminal-width")
|
Arg::new("terminal-width")
|
||||||
.long("terminal-width")
|
.long("terminal-width")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user