2020-01-16 08:37:12 +01:00
|
|
|
#[derive(Clone, Copy, Debug)]
|
|
|
|
pub(crate) struct Style {
|
|
|
|
active: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Style {
|
2020-03-15 11:22:33 +01:00
|
|
|
pub(crate) fn from_active(active: bool) -> Self {
|
|
|
|
Self { active }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
2020-01-16 08:37:12 +01:00
|
|
|
pub(crate) fn active() -> Self {
|
|
|
|
Self { active: true }
|
|
|
|
}
|
|
|
|
|
2020-03-15 11:22:33 +01:00
|
|
|
#[cfg(test)]
|
2020-01-16 08:37:12 +01:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
2020-02-04 19:54:41 +01:00
|
|
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
2020-03-13 02:00:52 +01:00
|
|
|
|
2020-03-16 09:07:29 +01:00
|
|
|
pub(crate) fn good(self) -> ansi_term::Style {
|
|
|
|
if self.active {
|
|
|
|
ansi_term::Style::new().fg(ansi_term::Color::Green).bold()
|
|
|
|
} else {
|
|
|
|
ansi_term::Style::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-13 02:00:52 +01:00
|
|
|
pub(crate) fn dim(self) -> ansi_term::Style {
|
|
|
|
if self.active {
|
|
|
|
ansi_term::Style::new().dimmed()
|
|
|
|
} else {
|
|
|
|
ansi_term::Style::new()
|
|
|
|
}
|
|
|
|
}
|
2020-01-16 08:37:12 +01:00
|
|
|
}
|