pcal/
cli.rs

1//! Command-line argument definitions for pcal.
2
3use clap::{CommandFactory, Parser};
4
5/// A Shahanshahi (Imperial Persian) calendar for the terminal.
6///
7/// Displays the current month by default. Accepts an optional month and year
8/// to show a specific month, or just a year to show all 12 months.
9/// Years are counted from the founding of the Persian Empire by Cyrus the Great.
10#[derive(Parser, Debug)]
11#[command(
12    name = "pcal",
13    version,
14    about,
15    after_help = "EXAMPLES:\n  \
16        pcal                Show current month\n  \
17        pcal 2584           Show all months of year 2584\n  \
18        pcal mordad 2584    Show Mordad (month 5) of 2584\n  \
19        pcal 5 2584         Same as above, by number\n  \
20        pcal -3             Show previous, current, and next month\n  \
21        pcal --persian      Use Persian script and digits"
22)]
23pub struct Args {
24    /// Month number (1-12) or name (farvardin, mordad, مرداد, ...)
25    pub month: Option<String>,
26
27    /// Shahanshahi year, e.g. 2584
28    pub year: Option<i32>,
29
30    /// Display the previous, current, and next month side by side
31    #[arg(short = '3')]
32    pub three: bool,
33
34    /// Display all 12 months of the year
35    #[arg(short = 'y', long)]
36    pub year_view: bool,
37
38    /// Display the next NUM months starting from the current month
39    #[arg(short = 'n', value_name = "NUM")]
40    pub months: Option<u32>,
41
42    /// Display day-of-year numbers instead of day-of-month
43    #[arg(short = 'j')]
44    pub julian: bool,
45
46    /// Use Persian script (month names, weekday names, and digits)
47    #[arg(long = "persian", alias = "fa")]
48    pub persian: bool,
49
50    /// Disable colored output (also respects `NO_COLOR` env variable)
51    #[arg(long = "no-color")]
52    pub no_color: bool,
53}
54
55impl Args {
56    /// Build the clap `Command` for man page and completion generation.
57    #[must_use]
58    pub fn command() -> clap::Command {
59        <Self as CommandFactory>::command()
60    }
61}