bilal/
cli.rs

1use clap::{Parser, ValueEnum};
2use std::path::PathBuf;
3
4#[derive(Parser)]
5#[command(
6    name = "bilal",
7    version,
8    about = "Bilal [A CLI salah time]",
9    after_long_help = "Bugs can be reported on GitHub: https://github.com/azzamsa/bilal/issues"
10)]
11#[derive(Debug)]
12pub struct Opts {
13    /// A Salah mode to show
14    #[arg(value_enum)]
15    pub mode: Mode,
16
17    /// Display Salah in JSON formatted string
18    #[arg(short = 'J', long)]
19    pub json: bool,
20
21    /// Display Salah in colored output
22    #[arg(
23        short,
24        long,
25        value_enum,
26        default_value_t = Color::Auto,
27    )]
28    pub color: Color,
29
30    /// Specify an alternate configuration file
31    #[arg(long)]
32    pub config: Option<PathBuf>,
33}
34
35#[derive(Debug, Clone, ValueEnum)]
36pub enum Mode {
37    All,
38    Next,
39    Current,
40}
41
42#[derive(Debug, Clone, ValueEnum)]
43pub enum Color {
44    /// show colors if the output goes to an interactive console (default)
45    Auto,
46    /// always use colorized output
47    Always,
48    /// do not use colorized output
49    Never,
50}
51
52impl Color {
53    #[must_use]
54    pub fn as_str(&self) -> &'static str {
55        match self {
56            Color::Auto => "auto",
57            Color::Never => "never",
58            Color::Always => "always",
59        }
60    }
61}