Skip to content

Commit aab5d23

Browse files
committed
feat: print out batch row before executing
1 parent 6f601b8 commit aab5d23

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/batch.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::path::Path;
1+
use std::{fmt::Display, path::Path};
22

33
use crate::{accounts, currency::Amount, error::Result};
44

@@ -10,14 +10,33 @@ struct Row {
1010
amount: Amount,
1111
}
1212

13-
pub async fn run(_token: String, file: String) -> Result<()> {
13+
impl Display for Row {
14+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15+
write!(
16+
f,
17+
"account={}, category={}, description={}, amount={}",
18+
self.account.value(),
19+
self.category,
20+
self.description,
21+
self.amount
22+
)
23+
}
24+
}
25+
26+
pub async fn run(token: String, file: String) -> Result<()> {
1427
let path = Path::new(&file);
15-
println!("batch file path: {}", path.display());
28+
println!("starting batch run for file: {}", path.display());
1629

1730
let mut reader = csv::Reader::from_path(path)?;
1831
for result in reader.deserialize() {
1932
let row: Row = result?;
20-
dbg!(row);
33+
34+
println!("executing batch row, {}", row);
35+
36+
// let pot_name = config::pot_for(row.account, row.category);
37+
// let deposit = pots::deposit(&token, pot_name, &row.amount).await?;
38+
// let deposit_tx = transactions::find_transaction(&token, depo).await?;
39+
// transactions::annotate(&token, &deposit_tx.id, row.description).await?;
2140
}
2241
Ok(())
2342
}

0 commit comments

Comments
 (0)