Skip to content

Commit

Permalink
Print a warning message instead of just '<BINARY>'
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed May 14, 2019
1 parent f37dbb8 commit c709bf2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,18 @@ impl<'a> Printer for InteractivePrinter<'a> {
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()> {
if !self.config.output_components.header() {
if ContentType::BINARY == self.content_type {
writeln!(handle, "<BINARY>")?;
let input = match file {
InputFile::Ordinary(filename) => format!("file '{}'", filename),
_ => "STDIN".into(),
};

writeln!(
handle,
"{}: Binary content from {} will not be printed to the terminal \
(but will be present if the output of 'bat' is piped).",
Yellow.paint("[bat warning]"),
input
)?;
}
return Ok(());
}
Expand Down

0 comments on commit c709bf2

Please sign in to comment.