mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-15 17:52:24 +01:00
Add support for reading from stdin, closes #2
This commit is contained in:
@@ -36,7 +36,7 @@ impl<'a> Printer<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_header(&mut self, filename: &str) -> Result<()> {
|
||||
pub fn print_header(&mut self, filename: Option<&str>) -> Result<()> {
|
||||
match self.options.style {
|
||||
OptionsStyle::Full => {}
|
||||
_ => return Ok(()),
|
||||
@@ -44,14 +44,22 @@ impl<'a> Printer<'a> {
|
||||
|
||||
self.print_horizontal_line('┬')?;
|
||||
|
||||
writeln!(
|
||||
write!(
|
||||
self.handle,
|
||||
"{}{} File {}",
|
||||
"{}{} ",
|
||||
" ".repeat(PANEL_WIDTH),
|
||||
self.colors.grid.paint("│"),
|
||||
self.colors.filename.paint(filename)
|
||||
)?;
|
||||
|
||||
match filename {
|
||||
None => {
|
||||
writeln!(self.handle, "STDIN",)?;
|
||||
}
|
||||
Some(filename) => {
|
||||
writeln!(self.handle, "File {}", self.colors.filename.paint(filename))?;
|
||||
}
|
||||
}
|
||||
|
||||
self.print_horizontal_line('┼')
|
||||
}
|
||||
|
||||
@@ -89,6 +97,8 @@ impl<'a> Printer<'a> {
|
||||
.join(" ")
|
||||
)?;
|
||||
|
||||
self.handle.flush()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user