use clap::Args;
use ixa::prelude::*;
use ixa::runner::run_with_custom_args;
#[derive(Args, Debug)]
struct CustomArgs {
#[arg(long)]
say_hello: bool,
#[arg(short = 'p', long)]
starting_population: Option<u8>,
}
define_global_property!(Name, String);
fn main() {
let context = run_with_custom_args(|context, args, custom_args: Option<CustomArgs>| {
println!("Setting random seed to {}", args.random_seed);
let custom_args = custom_args.unwrap();
if custom_args.say_hello {
println!("Hello");
}
context.set_global_property_value(Name, "Sim123".to_string())?;
println!("Name: {}", context.get_global_property_value(Name).unwrap());
if let Some(population) = custom_args.starting_population {
for _ in 0..population {
context.add_person(()).unwrap();
}
}
context.add_plan(2.0, |context| {
println!("Adding two people at t=2");
context.add_person(()).unwrap();
context.add_person(()).unwrap();
});
Ok(())
})
.unwrap();
let final_count = context.get_current_population();
println!("Simulation complete. The number of people is: {final_count}");
}