1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-04 12:22:28 +01:00

Add new style component to separate multiple '--line-range's

This commit is contained in:
Ethan P
2019-05-24 18:24:13 -07:00
committed by David Peter
parent e289a2c698
commit 7f2e61d579
4 changed files with 76 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ pub enum OutputComponent {
Grid,
Header,
Numbers,
Snip,
Full,
Plain,
}
@@ -34,11 +35,13 @@ impl OutputComponent {
OutputComponent::Grid => &[OutputComponent::Grid],
OutputComponent::Header => &[OutputComponent::Header],
OutputComponent::Numbers => &[OutputComponent::Numbers],
OutputComponent::Snip => &[OutputComponent::Snip],
OutputComponent::Full => &[
OutputComponent::Changes,
OutputComponent::Grid,
OutputComponent::Header,
OutputComponent::Numbers,
OutputComponent::Snip,
],
OutputComponent::Plain => &[],
}
@@ -55,6 +58,7 @@ impl FromStr for OutputComponent {
"grid" => Ok(OutputComponent::Grid),
"header" => Ok(OutputComponent::Header),
"numbers" => Ok(OutputComponent::Numbers),
"snip" => Ok(OutputComponent::Snip),
"full" => Ok(OutputComponent::Full),
"plain" => Ok(OutputComponent::Plain),
_ => Err(format!("Unknown style '{}'", s).into()),
@@ -82,6 +86,10 @@ impl OutputComponents {
self.0.contains(&OutputComponent::Numbers)
}
pub fn snip(&self) -> bool {
self.0.contains(&OutputComponent::Snip)
}
pub fn plain(&self) -> bool {
self.0.iter().all(|c| c == &OutputComponent::Plain)
}