"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
feat(firefly-iii): enhance existing modules with full CRUD
wangyubin274d260e22d8
diff --git a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/bills.py b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/bills.pyindex 3afa47cf7..c7cf66a36 100644--- a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/bills.py+++ b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/bills.py@@ -3,6 +3,7 @@ Bill management command group"""import click+from datetime import datetimefrom ..firefly_iii_cli import get_backend, output@@ -21,3 +22,116 @@ def bills_list(limit, page):params = {"limit": limit, "page": page}result = backend.get_bills(params)output(result)++[email protected](name="get")[email protected]("--id", required=True, type=int, help="Bill ID")+def bills_get(id):+ """Get bill details"""+ backend = get_backend()+ result = backend.get_bill(id)+ output(result)++[email protected](name="create")[email protected]("--name", required=True, help="Bill name")[email protected]("--amount-min", required=True, help="Minimum amount")[email protected]("--amount-max", required=True, help="Maximum amount")[email protected]("--currency-code", default="USD", help="Currency code")[email protected]("--frequency",+ type=click.Choice(['weekly', 'monthly', 'quarterly', 'half-yearly', 'yearly']),+ default='monthly',+ help="Bill frequency")[email protected]("--start-date", help="Start date (YYYY-MM-DD)")[email protected]("--end-date", help="End date (YYYY-MM-DD)")[email protected]("--pay-date", help="Expected pay date (YYYY-MM-DD)")[email protected]("--payment-date", help="Payment date (YYYY-MM-DD)")[email protected]("--notes", help="Notes")+def bills_create(name, amount_min, amount_max, currency_code, frequency,+ start_date, end_date, pay_date, payment_date, notes):+ """Create a new bill"""+ backend = get_backend()++ data = {+ "name": name,+ "amount_min": amount_min,+ "amount_max": amount_max,+ "currency_code": currency_code,+ "frequency": frequency,+ }++ if start_date:+ data["start_date"] = start_date+ if end_date:+ data["end_date"] = end_date+ if pay_date:+ data["pay_date"] = pay_date+ if payment_date:+ data["payment_date"] = payment_date+ if notes:+ data["notes"] = notes++ result = backend.create_bill(data)+ output(result)++[email protected](name="update")[email protected]("--id", required=True, type=int, help="Bill ID")[email protected]("--name", help="Bill name")[email protected]("--amount-min", help="Minimum amount")[email protected]("--amount-max", help="Maximum amount")[email protected]("--currency-code", help="Currency code")[email protected]("--frequency",+ type=click.Choice(['weekly', 'monthly', 'quarterly', 'half-yearly', 'yearly']),+ help="Bill frequency")[email protected]("--start-date", help="Start date (YYYY-MM-DD)")[email protected]("--end-date", help="End date (YYYY-MM-DD)")[email protected]("--pay-date", help="Expected pay date (YYYY-MM-DD)")[email protected]("--payment-date", help="Payment date (YYYY-MM-DD)")[email protected]("--notes", help="Notes")[email protected]("--active", type=bool, help="Is active")+def bills_update(id, name, amount_min, amount_max, currency_code, frequency,+ start_date, end_date, pay_date, payment_date, notes, active):+ """Update an existing bill"""+ backend = get_backend()++ data = {}+ if name:+ data["name"] = name+ if amount_min:+ data["amount_min"] = amount_min+ if amount_max:+ data["amount_max"] = amount_max+ if currency_code:+ data["currency_code"] = currency_code+ if frequency:+ data["frequency"] = frequency+ if start_date:+ data["start_date"] = start_date+ if end_date:+ data["end_date"] = end_date+ if pay_date:+ data["pay_date"] = pay_date+ if payment_date:+ data["payment_date"] = payment_date+ if notes:+ data["notes"] = notes+ if active is not None:+ data["active"] = active++ if not data:+ click.echo("Error: At least one update field is required", err=True)+ return++ result = backend.update_bill(id, data)+ output(result)++[email protected](name="delete")[email protected]("--id", required=True, type=int, help="Bill ID")[email protected]_option(prompt="Are you sure you want to delete this bill?")+def bills_delete(id):+ """Delete a bill"""+ backend = get_backend()+ result = backend.delete_bill(id)+ output(result)diff --git a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/budgets.py b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/budgets.pyindex 772dd71db..c8c61d08e 100644--- a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/budgets.py+++ b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/budgets.py@@ -3,6 +3,7 @@ Budget management command group"""import click+from datetime import datetimefrom ..firefly_iii_cli import get_backend, output@@ -30,3 +31,118 @@ def budgets_get(id):backend = get_backend()result = backend.get_budget(id)output(result)++[email protected](name="create")[email protected]("--name", required=True, help="Budget name")[email protected]("--notes", help="Notes")+def budgets_create(name, notes):+ """Create a new budget"""+ backend = get_backend()++ data = {"name": name}+ if notes:+ data["notes"] = notes++ result = backend.create_budget(data)+ output(result)++[email protected](name="update")[email protected]("--id", required=True, type=int, help="Budget ID")[email protected]("--name", help="Budget name")[email protected]("--notes", help="Notes")+def budgets_update(id, name, notes):+ """Update an existing budget"""+ backend = get_backend()++ data = {}+ if name:+ data["name"] = name+ if notes:+ data["notes"] = notes++ if not data:+ click.echo("Error: At least one update field is required", err=True)+ return++ result = backend.update_budget(id, data)+ output(result)++[email protected](name="delete")[email protected]("--id", required=True, type=int, help="Budget ID")[email protected]_option(prompt="Are you sure you want to delete this budget?")+def budgets_delete(id):+ """Delete a budget"""+ backend = get_backend()+ result = backend.delete_budget(id)+ output(result)+++# ========== Budget Limits ==========+[email protected](name="limits")[email protected]("--budget-id", required=True, type=int, help="Budget ID")[email protected]("--start", help="Start date (YYYY-MM-DD)")[email protected]("--end", help="End date (YYYY-MM-DD)")+def budgets_limits(budget_id, start, end):+ """List budget limits for a budget"""+ backend = get_backend()+ params = {}+ if start:+ params["start"] = start+ if end:+ params["end"] = end+ result = backend.get_budget_limits(budget_id, params)+ output(result)++[email protected](name="limit-create")[email protected]("--budget-id", required=True, type=int, help="Budget ID")[email protected]("--amount", required=True, help="Amount")[email protected]("--start", required=True, help="Start date (YYYY-MM-DD)")[email protected]("--end", required=True, help="End date (YYYY-MM-DD)")[email protected]("--currency-code", default="USD", help="Currency code")+def budgets_limit_create(budget_id, amount, start, end, currency_code):+ """Create a budget limit"""+ backend = get_backend()++ data = {+ "amount": amount,+ "start": start,+ "end": end,+ "currency_id": currency_code,+ }++ result = backend.create_budget_limit(budget_id, data)+ output(result)++[email protected](name="limit-update")[email protected]("--id", required=True, type=int, help="Budget limit ID")[email protected]("--amount", help="Amount")+def budgets_limit_update(id, amount):+ """Update a budget limit"""+ backend = get_backend()++ data = {}+ if amount:+ data["amount"] = amount++ if not data:+ click.echo("Error: Amount is required", err=True)+ return++ result = backend.update_budget_limit(id, data)+ output(result)++[email protected](name="limit-delete")[email protected]("--id", required=True, type=int, help="Budget limit ID")[email protected]_option(prompt="Are you sure you want to delete this budget limit?")+def budgets_limit_delete(id):+ """Delete a budget limit"""+ backend = get_backend()+ result = backend.delete_budget_limit(id)+ output(result)diff --git a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/categories.py b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/categories.pyindex ea9f92a93..76fbb653d 100644--- a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/categories.py+++ b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/categories.py@@ -21,3 +21,59 @@ def categories_list(limit, page):params = {"limit": limit, "page": page}result = backend.get_categories(params)output(result)++[email protected](name="get")[email protected]("--id", required=True, type=int, help="Category ID")+def categories_get(id):+ """Get category details"""+ backend = get_backend()+ result = backend.get_category(id)+ output(result)++[email protected](name="create")[email protected]("--name", required=True, help="Category name")[email protected]("--notes", help="Notes")+def categories_create(name, notes):+ """Create a new category"""+ backend = get_backend()++ data = {"name": name}+ if notes:+ data["notes"] = notes++ result = backend.create_category(data)+ output(result)++[email protected](name="update")[email protected]("--id", required=True, type=int, help="Category ID")[email protected]("--name", help="Category name")[email protected]("--notes", help="Notes")+def categories_update(id, name, notes):+ """Update an existing category"""+ backend = get_backend()++ data = {}+ if name:+ data["name"] = name+ if notes:+ data["notes"] = notes++ if not data:+ click.echo("Error: At least one update field is required", err=True)+ return++ result = backend.update_category(id, data)+ output(result)++[email protected](name="delete")[email protected]("--id", required=True, type=int, help="Category ID")[email protected]_option(prompt="Are you sure you want to delete this category?")+def categories_delete(id):+ """Delete a category"""+ backend = get_backend()+ result = backend.delete_category(id)+ output(result)diff --git a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/piggy_banks.py b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/piggy_banks.pyindex 9fd118418..c16550b8a 100644--- a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/piggy_banks.py+++ b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/piggy_banks.py@@ -3,6 +3,7 @@ Piggy bank management command group"""import click+from datetime import datetimefrom ..firefly_iii_cli import get_backend, output@@ -21,3 +22,112 @@ def piggy_banks_list(limit, page):params = {"limit": limit, "page": page}result = backend.get_piggy_banks(params)output(result)+++@piggy_banks.command(name="get")[email protected]("--id", required=True, type=int, help="Piggy bank ID")+def piggy_banks_get(id):+ """Get piggy bank details"""+ backend = get_backend()+ result = backend.get_piggy_bank(id)+ output(result)+++@piggy_banks.command(name="create")[email protected]("--name", required=True, help="Piggy bank name")[email protected]("--account-id", required=True, type=int, help="Account ID")[email protected]("--target-amount", help="Target amount")[email protected]("--start-date", help="Start date (YYYY-MM-DD)")[email protected]("--notes", help="Notes")+def piggy_banks_create(name, account_id, target_amount, start_date, notes):+ """Create a new piggy bank"""+ backend = get_backend()++ data = {+ "name": name,+ "account_id": account_id,+ }++ if target_amount:+ data["target_amount"] = target_amount+ if start_date:+ data["start_date"] = start_date+ if notes:+ data["notes"] = notes++ result = backend.create_piggy_bank(data)+ output(result)+++@piggy_banks.command(name="update")[email protected]("--id", required=True, type=int, help="Piggy bank ID")[email protected]("--name", help="Piggy bank name")[email protected]("--target-amount", help="Target amount")[email protected]("--start-date", help="Start date (YYYY-MM-DD)")[email protected]("--end-date", help="End date (YYYY-MM-DD)")[email protected]("--notes", help="Notes")[email protected]("--active", type=bool, help="Is active")+def piggy_banks_update(id, name, target_amount, start_date, end_date, notes, active):+ """Update an existing piggy bank"""+ backend = get_backend()++ data = {}+ if name:+ data["name"] = name+ if target_amount:+ data["target_amount"] = target_amount+ if start_date:+ data["start_date"] = start_date+ if end_date:+ data["end_date"] = end_date+ if notes:+ data["notes"] = notes+ if active is not None:+ data["active"] = active++ if not data:+ click.echo("Error: At least one update field is required", err=True)+ return++ result = backend.update_piggy_bank(id, data)+ output(result)+++@piggy_banks.command(name="delete")[email protected]("--id", required=True, type=int, help="Piggy bank ID")[email protected]_option(prompt="Are you sure you want to delete this piggy bank?")+def piggy_banks_delete(id):+ """Delete a piggy bank"""+ backend = get_backend()+ result = backend.delete_piggy_bank(id)+ output(result)+++@piggy_banks.command(name="events")[email protected]("--id", required=True, type=int, help="Piggy bank ID")+def piggy_banks_events(id):+ """List piggy bank events"""+ backend = get_backend()+ result = backend.get_piggy_bank_events(id)+ output(result)+++@piggy_banks.command(name="add-money")[email protected]("--id", required=True, type=int, help="Piggy bank ID")[email protected]("--amount", required=True, help="Amount to add")[email protected]("--date", default=lambda: datetime.now().strftime('%Y-%m-%d'),+ help="Date (YYYY-MM-DD)")[email protected]("--note", help="Note")+def piggy_banks_add_money(id, amount, date, note):+ """Add money to piggy bank"""+ backend = get_backend()++ data = {+ "amount": amount,+ "date": date,+ }+ if note:+ data["note"] = note++ result = backend.create_piggy_bank_event(id, data)+ output(result)diff --git a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/tags.py b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/tags.pyindex f12ef8f4c..8996eb288 100644--- a/firefly-iii/agent-harness/cli_anything/firefly_iii/core/tags.py+++ b/firefly-iii/agent-harness/cli_anything/firefly_iii/core/tags.py@@ -21,3 +21,65 @@ def tags_list(limit, page):params = {"limit": limit, "page": page}result = backend.get_tags(params)output(result)++[email protected](name="get")[email protected]("--id", required=True, help="Tag ID (can be UUID or integer)")+def tags_get(id):+ """Get tag details"""+ backend = get_backend()+ result = backend.get_tag(id)+ output(result)++[email protected](name="create")[email protected]("--tag", required=True, help="Tag value")[email protected]("--description", help="Description")[email protected]("--date", help="Date (YYYY-MM-DD)")+def tags_create(tag, description, date):+ """Create a new tag"""+ backend = get_backend()++ data = {"tag": tag}+ if description:+ data["description"] = description+ if date:+ data["date"] = date++ result = backend.create_tag(data)+ output(result)++[email protected](name="update")[email protected]("--id", required=True, help="Tag ID")[email protected]("--tag", help="Tag value")[email protected]("--description", help="Description")[email protected]("--date", help="Date (YYYY-MM-DD)")+def tags_update(id, tag, description, date):+ """Update an existing tag"""+ backend = get_backend()++ data = {}+ if tag:+ data["tag"] = tag+ if description:+ data["description"] = description+ if date:+ data["date"] = date++ if not data:+ click.echo("Error: At least one update field is required", err=True)+ return++ result = backend.update_tag(id, data)+ output(result)++[email protected](name="delete")[email protected]("--id", required=True, help="Tag ID")[email protected]_option(prompt="Are you sure you want to delete this tag?")+def tags_delete(id):+ """Delete a tag"""+ backend = get_backend()+ result = backend.delete_tag(id)+ output(result)