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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
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<String>,
/// 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<String>,
},
/// 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<String>,
/// Optional parent of the new product
#[arg(short, long)]
parent: Option<Uuid>,
/// 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 {},
}
|