1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use clap::{Parser, ValueEnum};

#[derive(Parser)]
#[command(
    name = "bilal",
    version,
    about = "Bilal [A CLI salah time]",
    after_long_help = "Bugs can be reported on GitHub: https://github.com/azzamsa/bilal/issues"
)]
#[derive(Debug)]
pub struct Opts {
    /// A Salah mode to show
    #[arg(value_enum)]
    pub mode: Mode,

    /// Display Salah in JSON formatted string
    #[arg(short = 'J', long)]
    pub json: bool,

    /// Display Salah in colored output
    #[arg(
        short,
        long,
        value_enum,
        default_value_t = Color::Auto,
    )]
    pub color: Color,
}

#[derive(Debug, Clone, ValueEnum)]
pub enum Mode {
    All,
    Next,
    Current,
}

#[derive(Debug, Clone, ValueEnum)]
pub enum Color {
    /// show colors if the output goes to an interactive console (default)
    Auto,
    /// always use colorized output
    Always,
    /// do not use colorized output
    Never,
}

impl Color {
    pub fn as_str(&self) -> &'static str {
        match self {
            Color::Auto => "auto",
            Color::Never => "never",
            Color::Always => "always",
        }
    }
}