1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-29 18:01:43 +00:00

Implemented --file-name for multiple files + tests

This commit is contained in:
Kyle Criddle
2020-03-24 18:26:00 -06:00
parent cfa2cb6ec7
commit 59f2e2d58d
5 changed files with 80 additions and 21 deletions
+10 -1
View File
@@ -137,6 +137,12 @@ impl App {
}
});
if self.matches.value_of("file-name").is_some()
&& self.matches.values_of("file-name").unwrap().len() != files.len()
{
return Err("When using --file-name, each input file must have a corresponding --file-name specified.".into());
}
Ok(Config {
true_color: is_truecolor_terminal(),
language: self.matches.value_of("language").or_else(|| {
@@ -222,7 +228,10 @@ impl App {
.transpose()?
.unwrap_or_else(|| vec![LineRange { lower: 0, upper: 0 }]),
),
filename: self.matches.value_of("file-name").or_else(|| None),
filenames: self
.matches
.values_of("file-name")
.map(|values| values.collect()),
})
}