From 28bde5b10abf904212dfc3cae937112134293053 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 30 Jun 2026 11:04:38 +0200 Subject: feat: account, category, tag, auth commands --- firefly_cli/commands/account.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 firefly_cli/commands/account.py (limited to 'firefly_cli/commands/account.py') diff --git a/firefly_cli/commands/account.py b/firefly_cli/commands/account.py new file mode 100644 index 0000000..fa2dc65 --- /dev/null +++ b/firefly_cli/commands/account.py @@ -0,0 +1,28 @@ +# Copyright (C) 2026 Danilo M. GPL-2.0-only +from firefly_cli import registry, output + +def _list_args(p): + p.add_argument("--type", help="filter: asset, expense, revenue, liability, ...") + +@registry.command("account list", help="list accounts", args=_list_args) +def cmd_list(args, ctx): + params = {"type": args.type} if getattr(args, "type", None) else None + resp = ctx.client.request("GET", "/api/v1/accounts", params=params) + output.emit(output.unwrap(resp), human=ctx.human) + return 0 + +def _name_arg(p): + p.add_argument("account", help="account name or id") + +@registry.command("account get", help="show one account", args=_name_arg) +def cmd_get(args, ctx): + acc = ctx.resolver.account(args.account) + output.emit(acc, human=ctx.human) + return 0 + +@registry.command("account balance", help="show account balance", args=_name_arg) +def cmd_balance(args, ctx): + acc = ctx.resolver.account(args.account) + output.emit({"id": acc["id"], "name": acc.get("name"), + "current_balance": acc.get("current_balance")}, human=ctx.human) + return 0 -- cgit v1.2.3