mirror of
https://github.com/sharkdp/bat
synced 2026-07-28 17:51:44 +00:00
Merge pull request #871 from neuronull/fix_654_stdin_filename
Implement --file-name<name> option
This commit is contained in:
@@ -136,6 +136,13 @@ impl App {
|
||||
}
|
||||
});
|
||||
|
||||
match self.matches.values_of("file-name") {
|
||||
Some(filenames) if filenames.len() != files.len() => {
|
||||
return Err(format!("{} {}", filenames.len(), files.len()).into());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Ok(Config {
|
||||
true_color: is_truecolor_terminal(),
|
||||
language: self.matches.value_of("language").or_else(|| {
|
||||
@@ -222,6 +229,10 @@ impl App {
|
||||
.map(LineRanges::from)
|
||||
.map(|lr| HighlightedLineRanges(lr))
|
||||
.unwrap_or_default(),
|
||||
filenames: self
|
||||
.matches
|
||||
.values_of("file-name")
|
||||
.map(|values| values.collect()),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,18 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
'--highlight-line 40:' highlights lines 40 to the end of the file"
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("file-name")
|
||||
.long("file-name")
|
||||
.takes_value(true)
|
||||
.number_of_values(1)
|
||||
.multiple(true)
|
||||
.value_name("name")
|
||||
.help("Specify the name to display for a file.")
|
||||
.long_help("Specify the name to display for a file. Useful when piping \
|
||||
data to bat from STDIN when bat does not otherwise know \
|
||||
the filename."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("tabs")
|
||||
.long("tabs")
|
||||
|
||||
Reference in New Issue
Block a user