Skip to content

Commit b6fce5d

Browse files
committed
feat: add description option for deposit
1 parent aab5d23 commit b6fce5d

File tree

4 files changed

+59
-11
lines changed

4 files changed

+59
-11
lines changed

src/config.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use serde::Deserialize;
2+
3+
use crate::accounts::AccountType;
4+
5+
#[derive(Deserialize)]
6+
struct Destinations {
7+
destinations: Vec<Destination>,
8+
}
9+
10+
#[derive(Deserialize)]
11+
struct Destination {
12+
source: AccountType,
13+
pot_name: String,
14+
}
15+
16+
// [destinations.personal]
17+
// account = "998877665"
18+
// source = "personal"
19+
20+
// [destinations.joint]
21+
// account = "112233445"
22+
// source = "joint"

src/main.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@ enum BatchCommands {
5353

5454
#[derive(Subcommand)]
5555
enum PotsCommands {
56-
List { name: Option<String> },
57-
Deposit { name: String, value: Amount },
56+
List {
57+
name: Option<String>,
58+
},
59+
Deposit {
60+
name: String,
61+
value: Amount,
62+
63+
#[arg(short, long)]
64+
description: Option<String>,
65+
},
5866
}
5967

6068
#[derive(Subcommand)]
@@ -87,8 +95,12 @@ async fn main() -> Result<()> {
8795
PotsCommands::List { name: _ } => {
8896
pots::list(&args.monzo_access_token).await?;
8997
}
90-
PotsCommands::Deposit { name, value } => {
91-
pots::deposit(&args.monzo_access_token, &name, &value).await?;
98+
PotsCommands::Deposit {
99+
name,
100+
value,
101+
description,
102+
} => {
103+
pots::deposit(&args.monzo_access_token, &name, &value, description).await?;
92104
}
93105
},
94106
Commands::Transactions { tx_cmd } => match tx_cmd {

src/pots.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,22 @@ pub async fn list(token: &str) -> Result<()> {
3535
Ok(())
3636
}
3737

38-
pub async fn deposit(token: &str, pot_name: &str, amount: &Amount) -> Result<()> {
38+
pub async fn deposit(
39+
token: &str,
40+
pot_name: &str,
41+
amount: &Amount,
42+
description: Option<String>,
43+
) -> Result<()> {
3944
let client = Client::new(token);
4045

4146
let found_pot = find_pot(token, pot_name).await?;
4247

4348
match found_pot {
49+
None => {
50+
println!("No pot found with name: {}", pot_name);
51+
return Ok(());
52+
}
53+
4454
Some(pot) => {
4555
let balance = Amount::try_from(pot.balance)?;
4656
println!("Found pot. Name: {}, Balance: {}", pot.name, balance,);
@@ -49,9 +59,11 @@ pub async fn deposit(token: &str, pot_name: &str, amount: &Amount) -> Result<()>
4959
.await?;
5060
println!("Completed deposit. Name: {}, Amount: {}", pot.name, amount);
5161
}
52-
None => {
53-
println!("No pot found with name: {}", pot_name);
54-
}
62+
}
63+
64+
if let Some(description) = description {
65+
// find transaction
66+
// annotate transaction
5567
}
5668

5769
Ok(())

src/transactions.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ pub async fn list(token: &str, account_type: accounts::AccountType) -> Result<()
1616
.find(|acc| acc.account_type == account_type.into());
1717

1818
match found_account {
19+
None => {
20+
println!("No account found for type: {}", account_type.value());
21+
return Ok(());
22+
}
23+
1924
Some(acc) => {
2025
println!("Transactions for account: {}", account_type.value());
2126
println!("");
@@ -35,9 +40,6 @@ pub async fn list(token: &str, account_type: accounts::AccountType) -> Result<()
3540
print_transaction_row(created, &tx.category, &tx.id, &amount.to_string());
3641
}
3742
}
38-
None => {
39-
println!("No account found for type: {}", account_type.value());
40-
}
4143
}
4244

4345
Ok(())

0 commit comments

Comments
 (0)