use std::path::PathBuf;
use clap::{Args, Parser, Subcommand, crate_authors, crate_description, crate_name, crate_version};
pub use crate::helper::types::OutputFormat;
#[derive(Parser)]
#[command(name = crate_name!(), version = crate_version!(), about = crate_description!(), author = crate_authors!())]
pub enum Cli {
#[command(name = "unpack", about = "Parse MDD data and export different formats")]
Unpack(UnpackArgs),
#[command(
subcommand,
name = "filter",
about = "Filter MDD data by country codes"
)]
Filter(FilterSubcommand),
#[command(name = "mil", about = "Merge MIL and MDD metadata and export as JSON")]
Mil(MilArgs),
#[command(name = "prepare", about = "Unpack MDD data and prepare MIL metadata")]
Prepare(PrepareArgs),
}
#[derive(Subcommand)]
pub enum FilterSubcommand {
#[command(name = "country", about = "Filter MDD data by country codes")]
ByCountry(FilterByCountryArgs),
}
#[derive(Args)]
pub struct FilterByCountryArgs {
#[command(flatten)]
pub input: CommonInput,
#[command(flatten)]
pub output: CommonOutput,
#[arg(
long,
short,
value_delimiter = ',',
help = "Country codes to filter by"
)]
pub country_codes: Vec<String>,
}
#[derive(Args)]
pub struct UnpackArgs {
#[command(flatten)]
pub input: CommonInput,
#[arg(long = "mdd", help = "MDD data version", require_equals = true)]
pub mdd_version: Option<String>,
#[arg(long = "date", help = "MDD release date")]
pub release_date: Option<String>,
#[command(flatten)]
pub output: CommonOutput,
}
#[derive(Args)]
pub struct CommonOutput {
#[arg(long, short, default_value = ".", help = "Output directory")]
pub output: PathBuf,
#[arg(
value_enum,
long,
short = 'F',
default_value = "csv",
help = "Output file format"
)]
pub output_format: OutputFormat,
#[arg(long = "limit", help = "Limit number of records")]
pub limit: Option<usize>,
#[arg(long, help = "Add prefix to output files")]
pub prefix: Option<String>,
}
#[derive(Args)]
pub struct CommonInput {
#[arg(
long,
short,
default_value = "MDD.csv",
help = "Input MDD species CSV file"
)]
pub input: PathBuf,
#[arg(long, short = 'f', default_value = "zip", help = "Output format")]
pub format: String,
}
#[derive(Args)]
pub struct MilArgs {
#[arg(
long,
short = 'm',
help = "Path to the MIL metadata file or compressed archive"
)]
pub mil_file: PathBuf,
#[arg(long, short = 'd', help = "Path to the MDD metadata file")]
pub mdd_file: PathBuf,
#[arg(long, short = 'i', help = "Path to the MIL image directory")]
pub mil_img_dir: Option<PathBuf>,
#[arg(long, short = 'o', help = "Output path for the exported JSON file")]
pub output: PathBuf,
}
#[derive(Args)]
pub struct PrepareArgs {
#[arg(long, short = 'z', help = "Path to the MDD zip archive")]
pub mdd_zip: PathBuf,
#[arg(
long,
short = 'm',
help = "Path to the MIL metadata file or compressed archive"
)]
pub mil_file: PathBuf,
#[arg(long, short = 'i', help = "Path to the MIL image directory")]
pub mil_img_dir: Option<PathBuf>,
#[arg(long, short = 'o', help = "Output directory")]
pub output: PathBuf,
}