mirror of
https://github.com/sharkdp/bat
synced 2026-07-31 18:21:43 +00:00
Introduce bat_warning! helper macro
This macro is intended to be package-internal and is not to be considered part of the public lib API. Use it in three places to reduce code duplication. However, main reason for this refactoring is to allow us to fix #1063 without duplicating the code yet another time. The macro can also be used for the "Binary content from {} will not be printed to the terminal" message if that message starts to use eprintln! instead (if ever). To trigger/verify the changed code, the following commands can be used: cargo run -- --theme=ansi-light tests/examples/single-line.txt cargo run -- --theme=does-not-exist tests/examples/single-line.txt cargo run -- --style=grid,rule tests/examples/single-line.txt
This commit is contained in:
committed by
David Peter
parent
b149ea91dd
commit
47bb4a9c0f
+2
-5
@@ -16,6 +16,7 @@ use console::Term;
|
||||
use crate::input::{new_file_input, new_stdin_input};
|
||||
use bat::{
|
||||
assets::HighlightingAssets,
|
||||
bat_warning,
|
||||
config::{Config, VisibleLines},
|
||||
error::*,
|
||||
input::Input,
|
||||
@@ -322,11 +323,7 @@ impl App {
|
||||
|
||||
// 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]"),
|
||||
);
|
||||
bat_warning!("Style 'rule' is a subset of style 'grid', 'rule' will not be visible.");
|
||||
}
|
||||
|
||||
Ok(styled_components)
|
||||
|
||||
Reference in New Issue
Block a user