From 9c15e172eb5b50796eb050cc5704471bce09e024 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 30 Jun 2026 15:09:34 +0200 Subject: help, completion: descriptive help text and bash completion Add group/leaf descriptions to argparse help and richer command help strings. Add generated bash completion (completions/firefly.bash) plus its generator (scripts/gen_completion.py), wired into the command checklist in CLAUDE.md and documented in the README. Bump to 0.2.1. Co-Authored-By: Claude Opus 4.8 --- firefly_cli/cli.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'firefly_cli/cli.py') diff --git a/firefly_cli/cli.py b/firefly_cli/cli.py index d547455..ad54504 100644 --- a/firefly_cli/cli.py +++ b/firefly_cli/cli.py @@ -11,6 +11,16 @@ import firefly_cli.commands # noqa: F401 triggers registration # Commands that must work without a configured client. _NO_CLIENT = {"auth set"} +# Short blurb per command group, shown in `firefly --help` and as the +# description in `firefly --help`. +_GROUP_HELP = { + "auth": "configure and verify the Firefly III connection (url + token)", + "account": "list, create, and inspect accounts (asset, expense, revenue)", + "category": "list categories (categories auto-create when used on a tx)", + "tag": "list tags (tags auto-create when attached to a tx)", + "tx": "record, list, and search transactions", +} + def _build_parser(): parser = argparse.ArgumentParser(prog="firefly", description="CLI for Firefly III") @@ -25,9 +35,10 @@ def _build_parser(): for cmd in registry.all_commands(): group, _, leaf = cmd.name.partition(" ") if group not in groups: - gp = sub.add_parser(group) + blurb = _GROUP_HELP.get(group) + gp = sub.add_parser(group, help=blurb, description=blurb) groups[group] = gp.add_subparsers(dest="_leaf", required=True) - lp = groups[group].add_parser(leaf, help=cmd.help) + lp = groups[group].add_parser(leaf, help=cmd.help, description=cmd.help) if cmd.args: cmd.args(lp) lp.set_defaults(_handler=cmd.handler, _cmdname=cmd.name) -- cgit v1.2.3