on master help sign in
disable rule when grid enabled, and print warning
3015ebfTom Milligan
src/bin/bat/app.rs+14−4
@@ -288,8 +288,8 @@ impl App {
288
288
289 fn style_components(&self) -> Result<StyleComponents> {
289 fn style_components(&self) -> Result<StyleComponents> {
290 let matches = &self.matches;
290 let matches = &self.matches;
291− Ok(StyleComponents(
291+ let mut styled_components =
292− if matches.value_of("decorations") == Some("never") {
292+ StyleComponents(if matches.value_of("decorations") == Some("never") {
293 HashSet::new()
293 HashSet::new()
294 } else if matches.is_present("number") {
294 } else if matches.is_present("number") {
295 [StyleComponent::LineNumbers].iter().cloned().collect()
295 [StyleComponent::LineNumbers].iter().cloned().collect()
@@ -323,7 +323,17 @@ impl App {
323 acc.extend(components.iter().cloned());
323 acc.extend(components.iter().cloned());
324 acc
324 acc
325 })
325 })
326− },
326+ });
327− ))
327+
328+ // If `grid` is set, remove `rule` as it is a subset of `grid`, and print a warning.
329+ if styled_components.grid() && styled_components.0.remove(&StyleComponent::Rule) {
330+ use ansi_term::Colour::Yellow;
331+ eprintln!(
332+ "{}: Style 'rule' is a subset of style 'grid', 'rule' will not be visible.",
333+ Yellow.paint("[bat warning]"),
334+ );
335+ }
336+
337+ Ok(styled_components)
328 }
338 }
329}
339}