Add filter to transactions command
This commit is contained in:
+11
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user