- Use colors - Use cut-friendly formatting when not writing to terminal - Show sizes as number of bytes when not writing to terminal type: changed
39 lines
757 B
Rust
39 lines
757 B
Rust
#[derive(Clone, Copy, Debug)]
|
|
pub(crate) struct Style {
|
|
active: bool,
|
|
}
|
|
|
|
impl Style {
|
|
pub(crate) fn active() -> Self {
|
|
Self { active: true }
|
|
}
|
|
|
|
pub(crate) fn inactive() -> Self {
|
|
Self { active: false }
|
|
}
|
|
|
|
pub(crate) fn message(self) -> ansi_term::Style {
|
|
if self.active {
|
|
ansi_term::Style::new().bold()
|
|
} else {
|
|
ansi_term::Style::new()
|
|
}
|
|
}
|
|
|
|
pub(crate) fn error(self) -> ansi_term::Style {
|
|
if self.active {
|
|
ansi_term::Style::new().fg(ansi_term::Color::Red).bold()
|
|
} else {
|
|
ansi_term::Style::new()
|
|
}
|
|
}
|
|
|
|
pub(crate) fn blue(self) -> ansi_term::Style {
|
|
if self.active {
|
|
ansi_term::Style::new().fg(ansi_term::Color::Blue)
|
|
} else {
|
|
ansi_term::Style::new()
|
|
}
|
|
}
|
|
}
|