about summary refs log tree commit diff stats
path: root/crates/rocie-cli/src/cli.rs
blob: 3f2662b11f787ac0d3418758be25de1057731452 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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 products
    Unit {
        #[command(subcommand)]
        command: UnitCommand,
    },
}

#[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<String>,
    },

    /// 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 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<String>,

        /// Optional parent of the new product
        #[arg(short, long)]
        parent: Option<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 {},
}