Added CLI arguments

Ayrton Chilibeck 2024-01-12 01:08:31 -07:00
parent 6aa524966c
commit c49de07543
Signed by: ayrton
GPG Key ID: BAE24A03DCBF160D
1 changed files with 37 additions and 4 deletions

View File

@ -8,23 +8,56 @@ use clap::{Parser, Subcommand};
struct Cli { struct Cli {
/// Sets the verbosity of the tester /// Sets the verbosity of the tester
#[arg(short, long, action = clap::ArgAction::Count)] #[arg(short, long, action = clap::ArgAction::Count)]
verbosity: u8, verbosity: Option<u8>,
/// Set the config file /// Set the config file
#[arg(short, long, value_name = "CONFIG")]
config_file: PathBuf, config_file: PathBuf,
/// Set the grading config file
#[arg(short, long, value_name = "GRADING_CONFIG")]
grading_conf: Option<PathBuf>,
#[command(subcommand)] #[command(subcommand)]
command: Commands, command: Command,
} }
#[derive(Subcommand)] #[derive(Subcommand)]
enum Commands { enum Command {
/// Validate test matching and config file validity /// Validate test matching and config file correctness
Validate, Validate,
/// Run all tests
Run, Run,
/// Grade with grading config
Grade, Grade,
} }
fn main() { fn main() {
let cli = Cli::parse();
let verbosity = get_verbosity(cli);
println!("verbosity = {}", verbosity);
println!("Hello, world!"); println!("Hello, world!");
} }
fn get_verbosity(cli: Cli) -> u8 {
// Check the user defined verbosity, if none, set to normal
let verbosity: u8;
match cli.verbosity {
Some(x) => verbosity = x,
None => verbosity = 1,
}
match verbosity {
0 => println!("Showing Result Summary 🫢"),
1 => println!("Using Regular Verbosity 🤫"),
2 => println!("Using Extreme Verbosity 🫨"),
_ => println!("Woah 🫠 ... didn't think we'd get this far, continuing with Extreme Verbosity"),
}
return verbosity;
}