summaryrefslogtreecommitdiffstats
path: root/firefly_cli/cli.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-06-30 15:09:34 +0200
committerDanilo M. <danix@danix.xyz>2026-06-30 15:09:34 +0200
commit9c15e172eb5b50796eb050cc5704471bce09e024 (patch)
tree01433901ddd2bb8db3f2498a225c49faae26d295 /firefly_cli/cli.py
parent93dbbe18e934d87ebf6ae6c614bb26f0e9e5afa5 (diff)
downloadfirefly-cli-19d82d1532fb2497ce7c401a00bcb50a58f95f3c.tar.gz
firefly-cli-19d82d1532fb2497ce7c401a00bcb50a58f95f3c.zip
help, completion: descriptive help text and bash completionv0.2.1
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 <noreply@anthropic.com>
Diffstat (limited to 'firefly_cli/cli.py')
-rw-r--r--firefly_cli/cli.py15
1 files changed, 13 insertions, 2 deletions
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 <group> --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)