#![forbid(unsafe_code)]
use std::io::IsTerminal;
#[derive(Debug, Clone, Copy, Default)]
pub struct Verbosity {
pub quiet: bool,
pub verbose: bool,
}
impl Verbosity {
pub fn info(&self, msg: &str) {
if !self.quiet {
eprintln!("{msg}");
}
}
pub fn verbose(&self, msg: &str) {
if self.verbose && !self.quiet {
if std::io::stderr().is_terminal() {
use anstyle::{AnsiColor, Color, Style};
let style = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Cyan)));
eprintln!("{style}{msg}{style:#}");
} else {
eprintln!("{msg}");
}
}
}
pub fn error(&self, msg: &str) {
if std::io::stderr().is_terminal() {
use anstyle::{AnsiColor, Color, Style};
let style = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Red)));
eprintln!("{style}error: {msg}{style:#}");
} else {
eprintln!("error: {msg}");
}
}
}