use std::io::IsTerminal;
#[derive(Copy, Clone, Debug, Eq, PartialEq, clap::ValueEnum)]
#[value(rename_all = "lower")]
pub enum DenyMethod {
All,
Added,
Changed,
Removed,
}
impl DenyMethod {
pub(crate) const fn deny_added(self) -> bool {
std::matches!(self, Self::All | Self::Added)
}
pub(crate) const fn deny_changed(self) -> bool {
std::matches!(self, Self::All | Self::Changed)
}
pub(crate) const fn deny_removed(self) -> bool {
std::matches!(self, Self::All | Self::Removed)
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, clap::ValueEnum)]
#[value(rename_all = "lower")]
pub enum Color {
Auto,
Never,
Always,
}
impl Color {
pub fn active(self) -> bool {
match self {
Self::Auto => std::io::stdout().is_terminal(), Self::Never => false,
Self::Always => true,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, clap::ValueEnum)]
#[value(rename_all = "kebab-case")]
#[allow(clippy::enum_variant_names)] pub enum Omit {
BlanketImpls,
AutoTraitImpls,
AutoDerivedImpls,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, clap::ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum Include {
FunctionParameterNames,
}
#[cfg(test)]
mod tests {
use super::DenyMethod;
use std::ops::Not;
#[test]
fn test_deny_added() {
assert!(DenyMethod::Added.deny_added());
assert!(DenyMethod::All.deny_added());
assert!(DenyMethod::Changed.deny_added().not());
assert!(DenyMethod::Removed.deny_added().not());
}
#[test]
fn test_deny_changed() {
assert!(DenyMethod::Changed.deny_changed());
assert!(DenyMethod::All.deny_changed());
assert!(DenyMethod::Added.deny_changed().not());
assert!(DenyMethod::Removed.deny_changed().not());
}
#[test]
fn test_deny_removed() {
assert!(DenyMethod::Removed.deny_removed());
assert!(DenyMethod::All.deny_removed());
assert!(DenyMethod::Added.deny_removed().not());
assert!(DenyMethod::Changed.deny_removed().not());
}
}