1
/*
2
 * Hurl (https://hurl.dev)
3
 * Copyright (C) 2024 Orange
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *          http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18

            
19
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
20
pub struct Style {
21
    pub fg: Option<Color>,
22
    pub bold: bool,
23
}
24

            
25
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
26
pub enum Color {
27
    Blue,
28
    BrightBlack,
29
    Cyan,
30
    Green,
31
    Magenta,
32
    Purple,
33
    Red,
34
    Yellow,
35
}
36

            
37
impl Style {
38
206695
    pub fn new() -> Style {
39
206695
        let fg = None;
40
206695
        let bold = false;
41
206695
        Style { fg, bold }
42
    }
43

            
44
37365
    pub fn blue(mut self) -> Style {
45
37365
        self.fg = Some(Color::Blue);
46
37365
        self
47
    }
48

            
49
5295
    pub fn bright_black(mut self) -> Style {
50
5295
        self.fg = Some(Color::BrightBlack);
51
5295
        self
52
    }
53

            
54
11700
    pub fn cyan(mut self) -> Style {
55
11700
        self.fg = Some(Color::Cyan);
56
11700
        self
57
    }
58

            
59
6910
    pub fn green(mut self) -> Style {
60
6910
        self.fg = Some(Color::Green);
61
6910
        self
62
    }
63

            
64
180
    pub fn magenta(mut self) -> Style {
65
180
        self.fg = Some(Color::Magenta);
66
180
        self
67
    }
68

            
69
1040
    pub fn purple(mut self) -> Style {
70
1040
        self.fg = Some(Color::Purple);
71
1040
        self
72
    }
73

            
74
10370
    pub fn red(mut self) -> Style {
75
10370
        self.fg = Some(Color::Red);
76
10370
        self
77
    }
78

            
79
1020
    pub fn yellow(mut self) -> Style {
80
1020
        self.fg = Some(Color::Yellow);
81
1020
        self
82
    }
83

            
84
72900
    pub fn bold(mut self) -> Style {
85
72900
        self.bold = true;
86
72900
        self
87
    }
88
}