//! The usual cli parser shenenigans //! #![warn(missing_docs, clippy::missing_docs_in_private_items)] use clap::{Args, Parser, Subcommand}; use config::{ graph::GraphConfig, make::{ HELP_BLOCK_SELECTION, HELP_BUILD_TARGET_LIST, HELP_VERBOSITY_LEVEL, MakeTargets, VerboseLevel, }, statsolver::StatConfig, tablegen::{Craft, TableArgs}, }; use serde::Deserialize; // use graphs::{GraphConfig, make_graphs}; // use makepdf::{MakeConfig, make_pdf}; // use stats::{StatConfig, stat_solver}; // use table_structs::Craft; #[derive(Parser, Debug)] #[command(version, about)] #[command(propagate_version = true)] /// The list of commands to run pub struct ParserCLIArgs { /// The subcommand to run. #[command(subcommand)] pub command: Commands, } #[derive(Subcommand, Debug)] /// Enum representing the available commands. pub enum Commands { /// Generate a table from input data using the provided arguments. Tablegen(TableArgs), /// Show/Export config Config(ConfigArgs), /// Handle stat repartition Stats(StatConfig), /// Make a pdf via pdflatex Make(MakeConfig), /// Make all graphs Graphs(GraphConfig), // /// Generate analysis data // Analysis(AnalysisConfig) } #[derive(Debug, Args)] /// Genrate the config file with the specified arguments pub struct ConfigArgs { /// Wether to write the config to file, or just show it #[arg(short, long, default_value_t = false)] pub write: bool, /// Wether to overwrite the file if it exists #[arg(short, long, default_value_t = false)] pub force: bool, /// The path to overwrite to pub path: Option, } #[derive(Deserialize)] /// The config struct, holding all runtime information pub struct Config { /// Config specific for the classes table generation pub classes: Classes, /// Config for all the tables pub craft: Craft, } #[derive(Deserialize)] /// The classes config pub struct Classes { /// The header string formatter pub header: String, /// The row string formatter pub tier: String, /// The row string separator pub sep: String, /// The table end string formatter pub end: String, } // The make structs #[derive(Args, Debug, Clone)] // #[command(after_)] /// The configuration struct for the PdfMaker pub struct MakeConfig { /// The filename to compile pub filename: String, /// Special target #[arg(short, long, help = format!("Build with a special target. [{}]", HELP_BUILD_TARGET_LIST.as_str()))] pub target: Option, /// The verbosity level #[arg(short, long, default_value = "warning", help = format!("The verbosity level. [{}]",HELP_VERBOSITY_LEVEL.as_str()))] pub verbosity: VerboseLevel, /// The progress bar style #[arg(short, long, default_value = "class", help = format!("The progress bar style. [{}]",HELP_BLOCK_SELECTION.as_str()))] pub pbar: String, /// switch to non interactive mode #[arg(short = 'N', long, default_value_t = false)] pub non_interactive: bool, /// Select only these targets #[arg(short, long, value_name = "FILE", group = "select")] pub only: Vec, /// Deselect these targets #[arg(short, long, value_name = "FILE", group = "select")] pub no: Vec, /// Wether to add the initial and final context #[arg(short = 'C', long, action = clap::ArgAction::SetFalse)] pub no_context: bool, /// Activate shell escape #[arg(short, long)] pub shell_escape: bool, }