1use chrono::{DateTime, Utc};
2use clap::{Parser, Subcommand};
3
4#[derive(Parser)]
5#[command(author, version, about)]
6pub struct Cli {
7 #[arg(index=1, help="The path of the yarl database")]
8 pub path: String,
9
10 #[command(subcommand)]
11 pub command: Command,
12}
13
14#[derive(Subcommand)]
15pub enum Command {
16 #[command(about="A mere test command")]
17 Test,
18
19 #[command(about="Gets the current balance of your account")]
20 Balance,
21
22 #[command(about="Exports the ledger (most recent transaction first) in RON format")]
23 Export {
24 #[arg(index=1, help="The path to export the ledger to")]
25 path: String,
26 #[arg(short, long, num_args=.., help="Filters the exported transactions to have to contain the specified tags")]
27 tags: Vec<String>,
28 #[arg(short, long, help="Filters the exported transactions by a currency")]
29 currency: Option<String>,
30 },
31
32 #[command(about="Imports an exported ledger")]
33 Import {
34 #[arg(index=1, help="The path to the ledger to import")]
35 path: String,
36 },
37
38 #[command(about="Lists all the tags used in the ledger (most recent first)")]
39 Tags,
40
41 #[command(about="Inserts a `deposit` transaction into the ledger")]
42 Deposit {
43 #[arg(short='i', long, help="Sets the time of which the transaction had occured (defaults to now)")]
44 time: Option<DateTime<Utc>>,
45 #[arg(short, long, default_value_t={"USD".to_string()}, help="The kind of currency the transaction involves")]
46 currency: String,
47 #[arg(index=1, help="The amount you've deposited")]
48 amount: f32,
49 #[arg(short, long, help="A message that describes the purpose of this transaction")]
50 message: Option<String>,
51 #[arg(short, long, num_args=.., help="The tags to give the transaction")]
52 tags: Vec<String>,
53 },
54
55 #[command(about="Inserts a `withdraw` transaction into the ledger")]
56 Withdraw {
57 #[arg(short='i', long, help="Sets the time of which the transaction had occured (defaults to now)")]
58 time: Option<DateTime<Utc>>,
59 #[arg(short, long, default_value_t={"USD".to_string()}, help="The kind of currency the transaction involves")]
60 currency: String,
61 #[arg(index=1, help="The amount you've withdrawn")]
62 amount: f32,
63 #[arg(short, long, help="A message that describes the purpose of this transaction")]
64 message: Option<String>,
65 #[arg(short, long, num_args=.., help="The tags to give the transaction")]
66 tags: Vec<String>,
67 },
68}