use clap::{Parser, Subcommand, ValueEnum};
use serde::{Deserialize, Serialize};

/// A easy way to safely manage your grades
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
pub struct Args {
    #[command(subcommand)]
    pub cli: Option<Command>,
}
#[derive(Subcommand, Debug)]
pub enum Command {
    /// Adds a grade
    #[clap(value_parser)]
    Add {
        #[arg(value_parser)]
        /// The class name
        class: String,

        #[arg(value_parser)]
        /// The grade in points
        grade: u16,

        #[arg(value_parser)]
        /// The type of the grade
        grade_type: String,

        #[arg(value_parser, short, long)]
        /// The unit of the grade, if none is specified, the value is taken from the config
        unit: Option<String>,

        #[arg(value_parser, short, long)]
        /// Optional comment, to describe the grade
        message: Option<String>,
    },
    /// Lists grades
    #[clap(value_parser)]
    List {
        #[arg(value_parser, short, long)]
        /// Only list grades from this class
        class: Option<String>,

        #[arg(value_enum)]
        /// What grade to list
        list_type: ListType,
    },
    ///// Changes the config file
    //#[clap(value_parser)]
    //Config {
    //    #[arg(value_enum, short, long)]
    //    /// Which classes to treat as lk (this is only relevant for the calculation of the grade
    //    /// point average)
    //    class: Classes,
    //},
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Serialize, Deserialize)]
pub enum ListType {
    /// List only the worst grade
    Worst,

    /// List only the best grade
    Best,

    /// List only the average grade
    Average,

    /// List all grades
    All,
}

#[cfg(test)]
mod test {
    #[test]
    fn test() {}
}
