Add filter to transactions command

This commit is contained in:
2026-06-03 09:16:05 +02:00
parent e205280176
commit c9e005475c
3 changed files with 31 additions and 4 deletions
+11 -2
View File
@@ -55,6 +55,11 @@ enum Command {
/// The number of days to look back for transactions
#[arg(short, long, default_value_t = 30)]
days: i64,
/// Filter transactions by a search term in the payee field. This will match any transaction
/// whose payee contains the search term, case-insensitive.
#[arg(short, long)]
filter: Option<String>,
},
/// Convert from a bank export to a CSV you can import manually to YNAB
Convert {
@@ -141,6 +146,7 @@ async fn main() -> anyhow::Result<()> {
account,
account_id,
days,
filter,
} => {
let client = Client::new(&token);
let plan = match (plan, plan_id) {
@@ -157,8 +163,11 @@ async fn main() -> anyhow::Result<()> {
};
let transactions = match account {
Some(account) => account.list_transactions(days).await?,
None => plan.list_transactions(None, days).await?,
Some(account) => account.list_transactions(days, filter.as_deref()).await?,
None => {
plan.list_transactions(None, days, filter.as_deref())
.await?
}
};
println!("Transactions{} in the last 30 days:", accountstr);
for t in transactions {