Skip to main content

ephemeris_forge_github/operation/
labels.rs

1use std::fmt;
2
3use ephemeris_forge::LabelColor;
4
5/// One write to the repository's labels.
6#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum Operation {
8    /// Create a label.
9    Create {
10        /// The label's name.
11        name: String,
12        /// The label's color.
13        color: LabelColor,
14        /// The label's description, empty for none.
15        description: String,
16    },
17    /// Set the color and description of an existing label.
18    Update {
19        /// The live label's name.
20        name: String,
21        /// The label's color.
22        color: LabelColor,
23        /// The label's description, empty for none.
24        description: String,
25    },
26    /// Delete a label.
27    Delete {
28        /// The label's name.
29        name: String,
30    },
31}
32
33impl fmt::Display for Operation {
34    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35        match self {
36            Self::Create {
37                name,
38                color: _,
39                description: _,
40            }
41            | Self::Update {
42                name,
43                color: _,
44                description: _,
45            }
46            | Self::Delete { name } => write!(f, "label {name}"),
47        }
48    }
49}