erebus 0.1.1

A CLI message generation library
Documentation
use yansi::Color;

use crate::Identifier;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Note {
    pub(crate) text: String,
    pub(crate) identifier: Identifier,
    pub(crate) color: Option<Color>,
}

impl Note {
    #[must_use]
    pub const fn builder(text: String, identifier: Identifier) -> NoteBuilder {
        NoteBuilder::new(text, identifier)
    }
}

pub struct NoteBuilder {
    text: String,
    identifier: Identifier,
    color: Option<Color>,
}

impl NoteBuilder {
    pub const fn new(text: String, identifier: Identifier) -> Self {
        Self {
            text,
            identifier,
            color: None,
        }
    }

    pub const fn set_color(mut self, color: Color) -> Self {
        self.color = Some(color);
        self
    }

    pub fn build(self) -> Note {
        Note {
            text: self.text,
            identifier: self.identifier,
            color: self.color,
        }
    }
}