prox 0.1.1

Rusty development process manager like foreman, but better!
Documentation
use owo_colors::AnsiColors;

/// All bright and normal ANSI colors except black
pub const ALL: &[AnsiColors] = &[
    AnsiColors::Red,
    AnsiColors::Yellow,
    AnsiColors::Green,
    AnsiColors::Cyan,
    AnsiColors::Blue,
    AnsiColors::Magenta,
    AnsiColors::BrightRed,
    AnsiColors::BrightYellow,
    AnsiColors::BrightGreen,
    AnsiColors::BrightCyan,
    AnsiColors::BrightBlue,
    AnsiColors::BrightMagenta,
];

/// All ANSI colors black
pub const NORMAL: &[AnsiColors] = &[
    AnsiColors::Red,
    AnsiColors::Yellow,
    AnsiColors::Green,
    AnsiColors::Cyan,
    AnsiColors::Blue,
    AnsiColors::Magenta,
];

/// All bright ANSI colors except black
pub const BRIGHT: &[AnsiColors] = &[
    AnsiColors::BrightRed,
    AnsiColors::BrightYellow,
    AnsiColors::BrightGreen,
    AnsiColors::BrightCyan,
    AnsiColors::BrightBlue,
    AnsiColors::BrightMagenta,
];

/// Custom serde_with converter for AnsiColors
pub mod color_converter {
    use super::*;
    use serde::{Deserialize, Deserializer, Serializer, de};
    use serde_with::{DeserializeAs, SerializeAs};

    pub struct ColorAsString;

    impl SerializeAs<AnsiColors> for ColorAsString {
        fn serialize_as<S>(source: &AnsiColors, serializer: S) -> Result<S::Ok, S::Error>
        where
            S: Serializer,
        {
            let color_str = match source {
                AnsiColors::Black => "black",
                AnsiColors::Red => "red",
                AnsiColors::Green => "green",
                AnsiColors::Yellow => "yellow",
                AnsiColors::Blue => "blue",
                AnsiColors::Magenta => "magenta",
                AnsiColors::Cyan => "cyan",
                AnsiColors::White => "white",
                AnsiColors::BrightBlack => "bright-black",
                AnsiColors::BrightRed => "bright-red",
                AnsiColors::BrightGreen => "bright-green",
                AnsiColors::BrightYellow => "bright-yellow",
                AnsiColors::BrightBlue => "bright-blue",
                AnsiColors::BrightMagenta => "bright-magenta",
                AnsiColors::BrightCyan => "bright-cyan",
                AnsiColors::BrightWhite => "bright-white",
                AnsiColors::Default => "default",
            };
            serializer.serialize_str(color_str)
        }
    }

    impl<'de> DeserializeAs<'de, AnsiColors> for ColorAsString {
        fn deserialize_as<D>(deserializer: D) -> Result<AnsiColors, D::Error>
        where
            D: Deserializer<'de>,
        {
            let s = String::deserialize(deserializer)?;
            match s.to_lowercase().as_str() {
                "black" => Ok(AnsiColors::Black),
                "red" => Ok(AnsiColors::Red),
                "green" => Ok(AnsiColors::Green),
                "yellow" => Ok(AnsiColors::Yellow),
                "blue" => Ok(AnsiColors::Blue),
                "magenta" => Ok(AnsiColors::Magenta),
                "cyan" => Ok(AnsiColors::Cyan),
                "white" => Ok(AnsiColors::White),
                "bright-black" => Ok(AnsiColors::BrightBlack),
                "bright-red" => Ok(AnsiColors::BrightRed),
                "bright-green" => Ok(AnsiColors::BrightGreen),
                "bright-yellow" => Ok(AnsiColors::BrightYellow),
                "bright-blue" => Ok(AnsiColors::BrightBlue),
                "bright-magenta" => Ok(AnsiColors::BrightMagenta),
                "bright-cyan" => Ok(AnsiColors::BrightCyan),
                "bright-white" => Ok(AnsiColors::BrightWhite),
                "default" => Ok(AnsiColors::Default),
                invalid => Err(de::Error::custom(format!("Invalid color name: {invalid}"))),
            }
        }
    }
}