mirror of
https://github.com/sharkdp/bat.git
synced 2025-03-13 14:18:35 +00:00
Merge 287123c6ce39a642050d0d3f8ee953172e942fbd into 3eb79d63ceda959a7b2c1ae46ea34593656d1488
This commit is contained in:
commit
f029b6a1ef
17
src/main.rs
17
src/main.rs
@ -57,6 +57,7 @@ use errors::*;
|
||||
|
||||
enum OptionsStyle {
|
||||
Plain,
|
||||
LineChanges,
|
||||
LineNumbers,
|
||||
Full,
|
||||
}
|
||||
@ -162,7 +163,7 @@ fn print_file<P: AsRef<Path>>(
|
||||
let (_, term_width) = term.size();
|
||||
let term_width = term_width as usize;
|
||||
|
||||
// Show file name and bars for all but plain style
|
||||
// Show file name and bars for line-numbers and full styles
|
||||
match options.style {
|
||||
OptionsStyle::LineNumbers | OptionsStyle::Full => {
|
||||
print_horizontal_line(&mut handle, '┬', term_width)?;
|
||||
@ -177,7 +178,7 @@ fn print_file<P: AsRef<Path>>(
|
||||
|
||||
print_horizontal_line(handle, '┼', term_width)?;
|
||||
}
|
||||
OptionsStyle::Plain => {}
|
||||
OptionsStyle::LineChanges | OptionsStyle::Plain => {}
|
||||
};
|
||||
|
||||
|
||||
@ -203,6 +204,13 @@ fn print_file<P: AsRef<Path>>(
|
||||
OptionsStyle::Plain => writeln!(
|
||||
handle,
|
||||
"{}", as_terminal_escaped(®ions, options.true_color))?,
|
||||
// Show content and git diff for line-changes style
|
||||
OptionsStyle::LineChanges => writeln!(
|
||||
handle,
|
||||
"{} {}",
|
||||
line_change,
|
||||
as_terminal_escaped(®ions, options.true_color)
|
||||
)?,
|
||||
_ =>
|
||||
writeln!(
|
||||
handle,
|
||||
@ -223,7 +231,7 @@ fn print_file<P: AsRef<Path>>(
|
||||
match options.style {
|
||||
OptionsStyle::LineNumbers | OptionsStyle::Full =>
|
||||
print_horizontal_line(handle, '┴', term_width)?,
|
||||
OptionsStyle::Plain => {}
|
||||
OptionsStyle::LineChanges | OptionsStyle::Plain => {}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
@ -446,7 +454,7 @@ fn run() -> Result<()> {
|
||||
Arg::with_name("style")
|
||||
.short("s")
|
||||
.long("style")
|
||||
.possible_values(&["plain", "line-numbers", "full"])
|
||||
.possible_values(&["plain", "line-changes", "line-numbers", "full"])
|
||||
.default_value("full")
|
||||
.help("Additional info to display alongwith content"),
|
||||
)
|
||||
@ -468,6 +476,7 @@ fn run() -> Result<()> {
|
||||
true_color: is_truecolor_terminal(),
|
||||
style: match app_matches.value_of("style").unwrap() {
|
||||
"plain" => OptionsStyle::Plain,
|
||||
"line-changes" => OptionsStyle::LineChanges,
|
||||
"line-numbers" => OptionsStyle::LineNumbers,
|
||||
_ => OptionsStyle::Full,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user