Skip to content

Commit

Permalink
Update clap requirement from ~2.34.0 to ~3.0.0 (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Jan 7, 2022
1 parent ad3f2b1 commit 4efddb6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tskit-derive = {version = "0.2.0", path = "tskit-derive", optional = true}
mbox = "0.6.0"

[dev-dependencies]
clap = "~2.34.0"
clap = "~3.0.0"
serde = {version = "1.0.118", features = ["derive"]}
serde-pickle = "1.1.0"
bincode = "1.3.1"
Expand Down
54 changes: 28 additions & 26 deletions examples/forward_simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* and numbers of crossovers, etc.., from being entered
* on the command line.
*/
use clap::{value_t, App, Arg};
use clap::{App, Arg};
use rand::rngs::StdRng;
use rand::Rng;
use rand::SeedableRng;
Expand Down Expand Up @@ -67,73 +67,75 @@ impl SimParams {

let matches = App::new("forward_simulation")
.arg(
Arg::with_name("popsize")
.short("N")
Arg::new("popsize")
.short('N')
.long("popsize")
.help("Diploid population size. Default = 1,000.")
.takes_value(true),
)
.arg(
Arg::with_name("nsteps")
.short("n")
Arg::new("nsteps")
.short('n')
.long("nsteps")
.help("Number of birth steps to simulate. For non-overlapping generations, this is the number of generations to simulate. Default = 1,000.")
.takes_value(true),
)
.arg(
Arg::with_name("xovers")
.short("x")
Arg::new("xovers")
.short('x')
.long("xovers")
.help("Mean number of crossovers per meiosis. The number of crossovers is Poisson-distributed with this value. Default = 0.0.")
.takes_value(true),
)
.arg(
Arg::with_name("genome_length")
.short("L")
Arg::new("genome_length")
.short('L')
.long("genome_length")
.help("Genome length (continuous units). Default = 1e6.")
.takes_value(true),
)
.arg(
Arg::with_name("simplification_interval")
.short("s")
Arg::new("simplification_interval")
.short('s')
.long("simplify")
.help("Number of birth steps between simplifications. Default = 100.")
.takes_value(true),
)
.arg(
Arg::with_name("treefile")
.short("t")
Arg::new("treefile")
.short('t')
.long("treefile")
.help("Name of output file. The format is a tskit \"trees\" file. Default = \"treefile.trees\".")
.takes_value(true),
)
.arg(
Arg::with_name("seed")
.short("S")
Arg::new("seed")
.short('S')
.long("seed")
.help("Random number seed. Default = 0.")
.takes_value(true),
)
.arg(
Arg::with_name("psurvival")
.short("P")
Arg::new("psurvival")
.short('P')
.long("psurvival")
.help("Survival probability. A value of 0.0 is the Wright-Fisher model of non-overlapping generations. Values must b 0.0 <= p < 1.0. Default = 0.0.")
.takes_value(true),
)
.get_matches();

params.popsize = value_t!(matches.value_of("popsize"), u32).unwrap_or(params.popsize);
params.nsteps = value_t!(matches.value_of("nsteps"), u32).unwrap_or(params.nsteps);
params.xovers = value_t!(matches.value_of("xovers"), f64).unwrap_or(params.xovers);
params.genome_length =
value_t!(matches.value_of("genome_length"), f64).unwrap_or(params.genome_length);
params.simplification_interval = value_t!(matches.value_of("simplification_interval"), u32)
params.popsize = matches.value_of_t("popsize").unwrap_or(params.popsize);
params.nsteps = matches.value_of_t("nsteps").unwrap_or(params.nsteps);
params.xovers = matches.value_of_t("xovers").unwrap_or(params.xovers);
params.genome_length = matches
.value_of_t("genome_length")
.unwrap_or(params.genome_length);
params.simplification_interval = matches
.value_of_t("simplification_interval")
.unwrap_or(params.simplification_interval);
params.seed = value_t!(matches.value_of("seed"), u64).unwrap_or(params.seed);
params.psurvival = value_t!(matches.value_of("psurvival"), f64).unwrap_or(params.psurvival);
params.treefile = value_t!(matches.value_of("treefile"), String).unwrap_or(params.treefile);
params.seed = matches.value_of_t("seed").unwrap_or(params.seed);
params.psurvival = matches.value_of_t("psurvival").unwrap_or(params.psurvival);
params.treefile = matches.value_of_t("treefile").unwrap_or(params.treefile);

params
}
Expand Down
8 changes: 4 additions & 4 deletions examples/tree_traversals.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::{value_t_or_exit, App, Arg};
use clap::{App, Arg};
use tskit::prelude::*;

// "Manual" traversal from samples to root
Expand Down Expand Up @@ -27,15 +27,15 @@ fn preorder_traversal(tree: &tskit::Tree) {
fn main() {
let matches = App::new("tree_traversals")
.arg(
Arg::with_name("treefile")
.short("t")
Arg::new("treefile")
.short('t')
.long("treefile")
.help("Tree file name")
.takes_value(true),
)
.get_matches();

let treefile = value_t_or_exit!(matches.value_of("treefile"), String);
let treefile: String = matches.value_of_t_or_exit("treefile");

let treeseq = tskit::TreeSequence::load(&treefile).unwrap();

Expand Down

0 comments on commit 4efddb6

Please sign in to comment.