aboutsummaryrefslogtreecommitdiffstats
path: root/firefly_cli
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-03 17:43:28 +0200
committerDanilo M. <danix@danix.xyz>2026-07-03 17:43:28 +0200
commit5d4d393a0de8a6c429a34dc1a51cde4e703cc033 (patch)
treeaf1a83bebe3c59f6bd28487531ef4b8bb4a89c0d /firefly_cli
parentb125853ab2e5fe3d8d0ad045609a5863e46a607a (diff)
downloadfirefly-cli-5d4d393a0de8a6c429a34dc1a51cde4e703cc033.tar.gz
firefly-cli-5d4d393a0de8a6c429a34dc1a51cde4e703cc033.zip
feat(budget): budget create
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'firefly_cli')
-rw-r--r--firefly_cli/commands/budget.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/firefly_cli/commands/budget.py b/firefly_cli/commands/budget.py
index 257bba7..990d2ad 100644
--- a/firefly_cli/commands/budget.py
+++ b/firefly_cli/commands/budget.py
@@ -41,3 +41,34 @@ def cmd_list(args, ctx):
rows = [{**r, "spent": _spent_scalar(r)} for r in rows]
output.emit(rows, human=ctx.human)
return 0
+
+
+def _create_args(p):
+ p.add_argument("name", help="budget name (must be unique)")
+ g = p.add_mutually_exclusive_group()
+ g.add_argument("--active", dest="active", action="store_true", default=True,
+ help="create active (default)")
+ g.add_argument("--inactive", dest="active", action="store_false",
+ help="create inactive")
+ p.add_argument("--currency", default=None, help="auto-budget currency code, e.g. EUR")
+ p.add_argument("--auto-budget-amount", dest="auto_budget_amount", default=None,
+ help="recurring auto-budget amount")
+ p.add_argument("--auto-budget-period", dest="auto_budget_period", default=None,
+ help="daily|weekly|monthly|quarterly|half_year|yearly")
+ p.add_argument("--auto-budget-type", dest="auto_budget_type", default=None,
+ help="reset|rollover|adjusted|none")
+
+@registry.command("budget create", help="create a budget", args=_create_args)
+def cmd_create(args, ctx):
+ body = {"name": args.name, "active": args.active}
+ if args.auto_budget_amount is not None:
+ body["auto_budget_amount"] = str(args.auto_budget_amount)
+ if args.auto_budget_period is not None:
+ body["auto_budget_period"] = args.auto_budget_period
+ if args.auto_budget_type is not None:
+ body["auto_budget_type"] = args.auto_budget_type
+ if args.currency:
+ body["currency_code"] = args.currency
+ resp = ctx.client.request("POST", "/api/v1/budgets", body=body)
+ output.emit(output.unwrap(resp), human=ctx.human)
+ return 0