diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-01 10:18:39 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-01 10:18:39 +0200 |
| commit | 0c9939c5961a3cef50e6378c0eefbeaae00f4c67 (patch) | |
| tree | ca75f91cf69cf085621fd22241d4081bb118edaf /firefly_cli | |
| parent | 38d7357f36e6eeb91216d1c5668fb29406c7e076 (diff) | |
| download | firefly-cli-0c9939c5961a3cef50e6378c0eefbeaae00f4c67.tar.gz firefly-cli-0c9939c5961a3cef50e6378c0eefbeaae00f4c67.zip | |
feat: tx list --all + truncation signal (v0.3.1)
tx list silently returned only --limit rows (default 20) with no signal
when more matched, making a correct ledger look wrong during reconciliation.
- --all auto-paginates every page via meta.pagination.total_pages
- without --all, print "showing N of M (use --all for all)" to stderr
when the result is truncated (stdout JSON stays clean)
PATCH: new optional flag + stderr note, contract unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'firefly_cli')
| -rw-r--r-- | firefly_cli/__init__.py | 2 | ||||
| -rw-r--r-- | firefly_cli/commands/transaction.py | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/firefly_cli/__init__.py b/firefly_cli/__init__.py index f41267d..79ea6e3 100644 --- a/firefly_cli/__init__.py +++ b/firefly_cli/__init__.py @@ -2,4 +2,4 @@ # Copyright (C) 2026 Danilo M. <danix@danix.xyz> # Licensed under the GNU General Public License v2.0 only. -__version__ = "0.3.0" +__version__ = "0.3.1" diff --git a/firefly_cli/commands/transaction.py b/firefly_cli/commands/transaction.py index af8a4fb..1d6f219 100644 --- a/firefly_cli/commands/transaction.py +++ b/firefly_cli/commands/transaction.py @@ -110,6 +110,8 @@ def _list_args(p): p.add_argument("--until", default=None, help="end date YYYY-MM-DD") p.add_argument("--account", default=None, help="filter by account name") p.add_argument("--limit", type=int, default=20) + p.add_argument("--all", action="store_true", + help="fetch every page (ignores --limit truncation)") @registry.command("tx list", help="list recent transactions (newest first)", args=_list_args) def cmd_list(args, ctx): @@ -123,7 +125,25 @@ def cmd_list(args, ctx): params["start"] = args.since if args.until: params["end"] = args.until + + if args.all: + rows, page = [], 1 + while True: + resp = ctx.client.request("GET", path, params={**params, "page": page}) + rows.extend(output.unwrap(resp)) + pg = (resp.get("meta") or {}).get("pagination") or {} + if page >= (pg.get("total_pages") or 1): + break + page += 1 + output.emit(rows, human=ctx.human) + return 0 + resp = ctx.client.request("GET", path, params=params) + pg = (resp.get("meta") or {}).get("pagination") or {} + total, count = pg.get("total"), pg.get("count") + if total is not None and count is not None and count < total: + import sys + print(f"showing {count} of {total} (use --all for all)", file=sys.stderr) output.emit(output.unwrap(resp), human=ctx.human) return 0 |
