use clap::Parser;

mod gather;
mod names_database;
mod pick;

type DynError = Box<dyn std::error::Error + Send + Sync>;
type DynResult<A> = Result<A, DynError>;

#[derive(Parser, Debug)]
#[clap(about, version, author)]
struct Args {
    database: String,
    count: u16,
    #[clap(long, arg_enum)]
    gather: Option<gather::Gender>,
}

#[tokio::main]
async fn main() -> DynResult<()> {
    let args = Args::parse();
    let db = names_database::AsyncConnection::open(args.database).await?;
    pick::pick(&db, args.count, args.gather).await?;
    Ok(())
}