mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-28 13:38:19 +02:00
disable rule when grid enabled, and print warning
This commit is contained in:
parent
d7da4f5f2b
commit
3015ebfba1
@ -288,8 +288,8 @@ impl App {
|
|||||||
|
|
||||||
fn style_components(&self) -> Result<StyleComponents> {
|
fn style_components(&self) -> Result<StyleComponents> {
|
||||||
let matches = &self.matches;
|
let matches = &self.matches;
|
||||||
Ok(StyleComponents(
|
let mut styled_components =
|
||||||
if matches.value_of("decorations") == Some("never") {
|
StyleComponents(if matches.value_of("decorations") == Some("never") {
|
||||||
HashSet::new()
|
HashSet::new()
|
||||||
} else if matches.is_present("number") {
|
} else if matches.is_present("number") {
|
||||||
[StyleComponent::LineNumbers].iter().cloned().collect()
|
[StyleComponent::LineNumbers].iter().cloned().collect()
|
||||||
@ -323,7 +323,17 @@ impl App {
|
|||||||
acc.extend(components.iter().cloned());
|
acc.extend(components.iter().cloned());
|
||||||
acc
|
acc
|
||||||
})
|
})
|
||||||
},
|
});
|
||||||
))
|
|
||||||
|
// If `grid` is set, remove `rule` as it is a subset of `grid`, and print a warning.
|
||||||
|
if styled_components.grid() && styled_components.0.remove(&StyleComponent::Rule) {
|
||||||
|
use ansi_term::Colour::Yellow;
|
||||||
|
eprintln!(
|
||||||
|
"{}: Style 'rule' is a subset of style 'grid', 'rule' will not be visible.",
|
||||||
|
Yellow.paint("[bat warning]"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(styled_components)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user