Set default jobs value using structopt default_value.
This commit is contained in:
@@ -40,8 +40,8 @@ struct Opt {
|
|||||||
test:bool,
|
test:bool,
|
||||||
#[structopt(help = "Ordinal of the prime to generate or number to test for primality")]
|
#[structopt(help = "Ordinal of the prime to generate or number to test for primality")]
|
||||||
num:u64,
|
num:u64,
|
||||||
#[structopt(short, long, name = "n", help = "Number of threads to spawn")]
|
#[structopt(short, long, name = "n", default_value = "1", help = "Number of threads to spawn")]
|
||||||
jobs:Option<u64>,
|
jobs:u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -57,11 +57,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let jobs = match opts.jobs {
|
|
||||||
Some(n) => n,
|
|
||||||
None => 1, // TODO: use number of CPUs
|
|
||||||
};
|
|
||||||
|
|
||||||
if opts.num == 0 {
|
if opts.num == 0 {
|
||||||
eprintln!("Invalid value for num: {}", opts.num);
|
eprintln!("Invalid value for num: {}", opts.num);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user