just/src/verbosity.rs
Casey Rodarmor 86c2e52dc6
Suppress all output to stderr when --quiet (#771)
Suppress all warnings and error messages when `--quiet` is passed.
2021-03-25 16:51:29 -07:00

48 lines
844 B
Rust

use Verbosity::*;
#[derive(Copy, Clone, Debug, PartialEq)]
pub(crate) enum Verbosity {
Quiet,
Taciturn,
Loquacious,
Grandiloquent,
}
impl Verbosity {
pub(crate) fn from_flag_occurrences(flag_occurences: u64) -> Self {
match flag_occurences {
0 => Taciturn,
1 => Loquacious,
_ => Grandiloquent,
}
}
pub(crate) fn quiet(self) -> bool {
matches!(self, Quiet)
}
pub(crate) fn loud(self) -> bool {
!self.quiet()
}
pub(crate) fn loquacious(self) -> bool {
match self {
Quiet | Taciturn => false,
Loquacious | Grandiloquent => true,
}
}
pub(crate) fn grandiloquent(self) -> bool {
match self {
Quiet | Taciturn | Loquacious => false,
Grandiloquent => true,
}
}
}
impl Default for Verbosity {
fn default() -> Self {
Self::Taciturn
}
}