Merge pull request 'Added the thread option for the cli' (#4) from ayrton/threads into main
ci/woodpecker/push/workflow Pipeline was successful
Details
ci/woodpecker/push/workflow Pipeline was successful
Details
Reviewed-on: #4main
commit
47d7d81f60
|
@ -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!");
|
||||||
}
|
}
|
||||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -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!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue