use clap::{Parser, Subcommand}; use uuid::Uuid; #[derive(Parser)] pub(crate) struct CliArgs { #[command(subcommand)] pub(crate) command: Command, } #[derive(Subcommand)] pub(crate) enum Command { /// Deal with products Product { #[command(subcommand)] command: ProductCommand, }, /// Deal with units Unit { #[command(subcommand)] command: UnitCommand, }, /// Deal with unit properties UnitProperty { #[command(subcommand)] command: UnitPropertyCommand, }, /// Deal with Barcodes Barcode { #[command(subcommand)] command: BarcodeCommand, }, } #[derive(Subcommand)] pub(crate) enum UnitCommand { /// Register a new unit Register { /// The full singular name of the new unit /// E.g.: 1 kilogram #[arg(short = 's', long)] full_name_singular: String, /// The full plural name of the new unit /// E.g.: 5 kilograms #[arg(short = 'p', long)] full_name_plural: String, /// The short name of the new unit (short names have no plural) /// E.g.: 1 kg or 5 kg #[arg(short = 'n', long)] short_name: String, /// Optional description of the new unit #[arg(short, long)] description: Option, /// The id of the unit property this unit measures. #[arg(short, long)] unit_property: Uuid, }, /// Fetch an unit based on id GetById { /// The id of the unit #[arg(short, long)] id: Uuid, }, /// List all available units List {}, } #[derive(Subcommand)] pub(crate) enum UnitPropertyCommand { /// Register a new unit Register { /// The name of the new unit property /// /// E.g.: /// - Mass /// - Volume #[arg(short = 'n', long)] name: String, /// Optional description of the new unit property #[arg(short, long)] description: Option, }, /// Fetch an unit property based on id GetById { /// The id of the unit property #[arg(short, long)] id: Uuid, }, /// List all available unit properties List {}, } #[derive(Subcommand)] #[expect(variant_size_differences, reason = "It's just a testing cli")] pub(crate) enum BarcodeCommand { /// Buy an barcode Buy { /// The numeric value of the barcode #[arg(short, long)] id: u32, /// How often to buy this barcode #[arg(short, long, default_value = "1")] times: u16, }, /// Consume an barcode Consume { /// The numeric value of the barcode #[arg(short, long)] id: u32, /// The amount to consume #[arg(short, long)] amount: u32, /// The unit of the consumed amount #[arg(short, long)] unit_id: Uuid, }, } #[derive(Subcommand)] pub(crate) enum ProductCommand { /// Register a new product Register { /// The name of the new product #[arg(short, long)] name: String, /// Optional description of the new product #[arg(short, long)] description: Option, /// Optional parent of the new product #[arg(short, long)] parent: Option, /// The id of the unit property this product is measured in. #[arg(short, long)] unit_property: Uuid, }, AssociateBarcode { /// The id of the product to associated the barcode with #[arg(short, long)] product_id: Uuid, /// The barcode number #[arg(short, long)] barcode_number: u32, /// The quantity of amount, this barcode signifies #[arg(short = 'v', long)] amount_value: u32, /// The unit the amount value is in #[arg(short = 'u', long)] amount_unit_id: Uuid, }, /// Get a already registered product by id Get { /// The id of the product #[arg(short, long)] id: Uuid, }, /// List all available products List {}, }