Compare commits

..

2 Commits

Author SHA1 Message Date
ayrton 47d7d81f60 Merge pull request 'Added the thread option for the cli' (#4) from ayrton/threads into main
ci/woodpecker/push/workflow Pipeline was successful Details
Reviewed-on: #4
2024-01-13 05:20:16 +00:00
Ayrton Chilibeck e6610de9b6
Added the thread option for the cli
ci/woodpecker/push/workflow Pipeline was successful Details
ci/woodpecker/pr/workflow Pipeline was successful Details
ci/woodpecker/pull_request_closed/workflow Pipeline was successful Details
2024-01-12 22:16:50 -07:00
3 changed files with 18 additions and 5 deletions

View File

@ -2,6 +2,6 @@ use std::path::Path;
use crate::util; use crate::util;
pub fn grade(verbosity: u8, config: util::config::Config, grade_config: Option<&Path>) { pub fn grade(verbosity: u8, config: util::config::Config, grade_config: Option<&Path>, threads: u8) {
println!("Grading!"); println!("Grading!");
} }

View File

@ -13,6 +13,7 @@ fn main() {
// parse the verbosity and eliminate the Option<> // parse the verbosity and eliminate the Option<>
let verbosity = get_verbosity(cli.verbosity); let verbosity = get_verbosity(cli.verbosity);
let threads = get_threads(cli.threads);
let config = util::config::parse_config(cli.config_file); let config = util::config::parse_config(cli.config_file);
//parse the config file //parse the config file
@ -20,8 +21,8 @@ fn main() {
match &cli.command { match &cli.command {
Command::Validate => validate::validate(verbosity, config), Command::Validate => validate::validate(verbosity, config),
Command::Run => run::run(verbosity, config), Command::Run => run::run(verbosity, config, threads),
Command::Grade => grade::grade(verbosity, config, cli.grading_conf.as_deref()), Command::Grade => grade::grade(verbosity, config, cli.grading_conf.as_deref(), threads),
} }
} }
@ -33,7 +34,9 @@ struct Cli {
#[arg(short, long, action = clap::ArgAction::Count)] #[arg(short, long, action = clap::ArgAction::Count)]
verbosity: Option<u8>, verbosity: Option<u8>,
//TODO implement a thread count variable for the runner /// Set the number of threads (only valid in run and grade mode)
#[arg(short, long)]
threads: Option<u8>,
/// Set the config file /// Set the config file
#[arg(short, long, value_name = "CONFIG")] #[arg(short, long, value_name = "CONFIG")]
@ -76,3 +79,13 @@ fn get_verbosity(verb: Option<u8>) -> u8 {
return verbosity; return verbosity;
} }
fn get_threads(threads: Option<u8>) -> u8 {
let thr: u8;
match threads {
Some(x) => thr = x,
None => thr = 1,
}
return thr;
}

View File

@ -1,6 +1,6 @@
use crate::util; use crate::util;
pub fn run(verbosity: u8, config: util::config::Config) { pub fn run(verbosity: u8, config: util::config::Config, threads: u8) {
println!("Running!"); println!("Running!");
} }