1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 03:12:25 +01:00

--file-name for normal files. integration tests.

This commit is contained in:
Kyle Criddle
2020-03-19 20:46:19 -06:00
committed by sharkdp
parent 8adce9fae8
commit fb3c775c8b
3 changed files with 70 additions and 4 deletions

View File

@@ -228,9 +228,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
if !self.config.style_components.header() {
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
let input = match file {
InputFile::Ordinary(filename) => {
format!("file '{}'", filename.to_string_lossy())
}
InputFile::Ordinary(filename) => format!(
"file '{}'",
self.config.filename.unwrap_or(&filename.to_string_lossy())
),
_ => self.config.filename.unwrap_or("STDIN").to_owned(),
};
@@ -266,7 +267,15 @@ impl<'a> Printer for InteractivePrinter<'a> {
}
let (prefix, name) = match file {
InputFile::Ordinary(filename) => ("File: ", filename.to_string_lossy()),
InputFile::Ordinary(filename) => (
"File: ",
Cow::from(
self.config
.filename
.unwrap_or(&filename.to_string_lossy())
.to_owned(),
),
),
_ => (
"File: ",
Cow::from(self.config.filename.unwrap_or("STDIN").to_owned()),