caltemps 0.3.1

A tool to query and report on your iCalendar data from vDirs.
Documentation
use clap::{Parser, ValueEnum};

/// Query and report on your iCalendar data from vDirs.
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct Cli {
    /// Path to CalTemps config file
    ///
    /// Currently the file would look like:
    ///
    ///     # This is where your calendar lives in VDir format
    ///     # See also:
    ///     # https://vdirsyncer.readthedocs.io/en/stable/vdir.html
    ///     vdir_path: '/home/user/.calendars/work'
    ///     # See also the --filter argument
    ///     default_filter: '@work'
    ///     # See also the --date-range argument
    ///     default_date_range: 'monday..friday'
    #[arg(short, long, verbatim_doc_comment, env="CALTEMPS_CONFIG",
        default_value_t=xdg::BaseDirectories::with_prefix("caltemps").get_config_file("config.toml").unwrap().into_os_string().into_string().expect("Strange path"))]
    pub config: String,
    /// Filter to apply, something like '@work'
    ///
    /// Remember to quote '@' and '#' symbols on your shell if those have a
    /// special meaning.
    #[arg(short, long, env = "CALTEMPS_FILTER")]
    pub filter: Option<String>,
    /// The date range to filter items by.
    ///
    /// It includes both extremes.
    ///
    /// You can use '..' to separate the beginning and the end, for example:
    /// '2025-01-01..2025-12-31' would include everything on 2025.
    #[arg(short, long, env = "CALTEMPS_DATE_RANGE")]
    pub date_range: Option<String>,
    /// Type of report to prepare
    #[arg(short, long, value_enum, default_value_t=EnumReportTypes::Totals)]
    pub report_type: EnumReportTypes,
    /// Output type
    #[arg(short, long, value_enum, default_value_t=EnumOutputTypes::Cli)]
    pub output_type: EnumOutputTypes,
}

/// Kinds of report to generate
#[derive(ValueEnum, Debug, Clone, Copy)]
#[value()]
pub enum EnumReportTypes {
    /// Totals
    #[value()]
    Totals,
    /// Yearly
    #[value()]
    Yearly,
    /// Quarterly
    #[value()]
    Quarterly,
    /// Monthly
    #[value()]
    Monthly,
    /// Fortnightly
    #[value()]
    Fortnightly,
    /// Weekly
    #[value()]
    Weekly,
}

/// Kinds of output to generate
#[derive(ValueEnum, Debug, Clone, Copy)]
#[value()]
pub enum EnumOutputTypes {
    /// Command Line Interface
    #[value()]
    Cli,
    /// Comma Separated Values
    #[value()]
    Csv,
}