Make number of days configurable for transactions

This commit is contained in:
2026-05-25 23:15:20 +02:00
parent da0d80f4f4
commit 415a1f8684
3 changed files with 27 additions and 9 deletions
+12 -6
View File
@@ -26,10 +26,11 @@ enum Command {
#[arg(short = 'P', long, group = "planref")]
plan_id: Option<String>,
},
// List transactions in the last 30 days
//
// You have to give a plan to list transactions from. You can optionally
// also give an account to show only transactions from that account.
/// List transactions
///
/// You have to give a plan to list transactions from. You can optionally
/// also give an account to show only transactions from that account. You can specify the
/// number of days, the default is 30.
Transactions {
/// Your YNAB token, available from developer settings in YNAB
#[arg(short, long, env = "YNAB_API_TOKEN", hide_env_values = true)]
@@ -50,6 +51,10 @@ enum Command {
/// Alternatively, give the YNAB account ID directly
#[arg(short = 'A', long, group = "accountref")]
account_id: Option<String>,
/// The number of days to look back for transactions
#[arg(short, long, default_value_t = 30)]
days: i64,
},
/// Convert from a bank export to a CSV you can import manually to YNAB
Convert {
@@ -135,6 +140,7 @@ async fn main() -> anyhow::Result<()> {
plan_id,
account,
account_id,
days,
} => {
let client = Client::new(&token);
let plan = match (plan, plan_id) {
@@ -151,8 +157,8 @@ async fn main() -> anyhow::Result<()> {
};
let transactions = match account {
Some(account) => account.list_transactions().await?,
None => plan.list_transactions(None).await?,
Some(account) => account.list_transactions(days).await?,
None => plan.list_transactions(None, days).await?,
};
println!("Transactions{} in the last 30 days:", accountstr);
for t in transactions {