summaryrefslogtreecommitdiffstats
path: root/firefly_cli/commands/account.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-06-30 11:04:38 +0200
committerDanilo M. <danix@danix.xyz>2026-06-30 11:04:38 +0200
commit28bde5b10abf904212dfc3cae937112134293053 (patch)
treeb12aba30abeaba15a10458032e11e7d01cb69bd2 /firefly_cli/commands/account.py
parent49c9af4c213d5f420a405d860c0454fade26c297 (diff)
downloadfirefly-cli-28bde5b10abf904212dfc3cae937112134293053.tar.gz
firefly-cli-28bde5b10abf904212dfc3cae937112134293053.zip
feat: account, category, tag, auth commands
Diffstat (limited to 'firefly_cli/commands/account.py')
-rw-r--r--firefly_cli/commands/account.py28
1 files changed, 28 insertions, 0 deletions
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. <danix@danix.xyz> 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