use clap::Parser;
use std::path::PathBuf;
use csvenum::{generate_configured_enum_from_csv, EnumOptions};
#[derive(Parser, Debug)]
#[command(version, about)]
struct Cli {
filename_csv: String,
#[arg(short, long)]
outpath: Option<String>,
#[arg(short, long)]
split_properties: Option<bool>,
#[arg(short, long)]
variant_str_fns: Option<bool>,
#[arg(short, long)]
impl_links: Option<bool>,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Cli::parse();
let csv = args.filename_csv;
let csv_path = PathBuf::from(&csv);
let csv_dir = csv_path.parent().expect("Failed to get CSV file directory");
let mut output_path = PathBuf::from(csv_dir);
if let Some(outpath) = &args.outpath {
output_path.push(outpath);
}
let split_files = args.split_properties.unwrap_or_else(|| false);
let gen_variant_str_fns = args.variant_str_fns.unwrap_or_else(|| true);
let gen_impl_links = args.impl_links.unwrap_or_else(|| true);
let options = EnumOptions {
path_to_outfile: output_path,
split_files,
gen_variant_str_fns,
gen_impl_links,
experimental_no_type_restrictions: false,
};
generate_configured_enum_from_csv(Some(options), csv)?;
Ok(())
}