mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-12 00:02:28 +01:00
Implement --file-name<name> option
- can specify filename to be displayed when printing. - useful for when piping data from STDIN Closes #654
This commit is contained in:
@@ -231,7 +231,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
InputFile::Ordinary(filename) => {
|
||||
format!("file '{}'", filename.to_string_lossy())
|
||||
}
|
||||
_ => "STDIN".into(),
|
||||
_ => self.config.filename.unwrap_or("STDIN").to_owned(),
|
||||
};
|
||||
|
||||
writeln!(
|
||||
@@ -267,7 +267,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
|
||||
let (prefix, name) = match file {
|
||||
InputFile::Ordinary(filename) => ("File: ", filename.to_string_lossy()),
|
||||
_ => ("", Cow::from("STDIN")),
|
||||
_ => (
|
||||
"File: ",
|
||||
Cow::from(self.config.filename.unwrap_or("STDIN").to_owned()),
|
||||
),
|
||||
};
|
||||
|
||||
let mode = match self.content_type {
|
||||
|
Reference in New Issue
Block a user