Added CLI arguments
parent
28b475d19b
commit
bfd57f39a8
41
src/main.rs
41
src/main.rs
|
@ -8,23 +8,56 @@ use clap::{Parser, Subcommand};
|
|||
struct Cli {
|
||||
/// Sets the verbosity of the tester
|
||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||
verbosity: u8,
|
||||
verbosity: Option<u8>,
|
||||
|
||||
/// Set the config file
|
||||
#[arg(short, long, value_name = "CONFIG")]
|
||||
config_file: PathBuf,
|
||||
|
||||
/// Set the grading config file
|
||||
#[arg(short, long, value_name = "GRADING_CONFIG")]
|
||||
grading_conf: Option<PathBuf>,
|
||||
|
||||
#[command(subcommand)]
|
||||
command: Commands,
|
||||
command: Command,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
/// Validate test matching and config file validity
|
||||
enum Command {
|
||||
/// Validate test matching and config file correctness
|
||||
Validate,
|
||||
|
||||
/// Run all tests
|
||||
Run,
|
||||
|
||||
/// Grade with grading config
|
||||
Grade,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
||||
let verbosity = get_verbosity(cli);
|
||||
|
||||
println!("verbosity = {}", verbosity);
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue