aboutsummaryrefslogtreecommitdiffstats
path: root/firefly_cli
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-03 17:49:20 +0200
committerDanilo M. <danix@danix.xyz>2026-07-03 17:49:20 +0200
commite30b3f203059d8d116f77185f0764c391cae07dc (patch)
treee7a322c63be7100897f778ed9be680677fa0c69f /firefly_cli
parente0843da28eaa5828665a700b8a06f7fe1e27d2b8 (diff)
downloadfirefly-cli-e30b3f203059d8d116f77185f0764c391cae07dc.tar.gz
firefly-cli-e30b3f203059d8d116f77185f0764c391cae07dc.zip
feat(budget): limit list and limit set
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'firefly_cli')
-rw-r--r--firefly_cli/commands/budget.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/firefly_cli/commands/budget.py b/firefly_cli/commands/budget.py
index 3994958..733d092 100644
--- a/firefly_cli/commands/budget.py
+++ b/firefly_cli/commands/budget.py
@@ -105,3 +105,31 @@ def cmd_enable(args, ctx):
@registry.command("budget disable", help="mark a budget inactive", args=_ref_arg)
def cmd_disable(args, ctx):
return _set_active(ctx, args.ref, False)
+
+
+@registry.command("budget limit list", help="list a budget's limits (name or id)", args=_ref_arg)
+def cmd_limit_list(args, ctx):
+ b = ctx.resolver.budget(args.ref)
+ resp = ctx.client.request("GET", f"/api/v1/budgets/{b['id']}/limits")
+ output.emit(output.unwrap(resp), human=ctx.human)
+ return 0
+
+def _limit_set_args(p):
+ _ref_arg(p)
+ p.add_argument("--amount", required=True, help="limit amount (positive)")
+ p.add_argument("--start", default=None, help="YYYY-MM-DD (default: 1st of this month)")
+ p.add_argument("--end", default=None, help="YYYY-MM-DD (default: last of this month)")
+ p.add_argument("--currency", default=None, help="currency code, e.g. EUR")
+
+@registry.command("budget limit set", help="set (create) a spending limit for a budget over a period", args=_limit_set_args)
+def cmd_limit_set(args, ctx):
+ b = ctx.resolver.budget(args.ref)
+ first, last = _current_month()
+ body = {"amount": str(args.amount),
+ "start": args.start or first,
+ "end": args.end or last}
+ if args.currency:
+ body["currency_code"] = args.currency
+ resp = ctx.client.request("POST", f"/api/v1/budgets/{b['id']}/limits", body=body)
+ output.emit(output.unwrap(resp), human=ctx.human)
+ return 0