Skip to content

feat(budgets): add budgets and budget-categories commands#17

Merged
dgilperez merged 2 commits into
mainfrom
feat/cli-budgets-cmds
May 23, 2026
Merged

feat(budgets): add budgets and budget-categories commands#17
dgilperez merged 2 commits into
mainfrom
feat/cli-budgets-cmds

Conversation

@dgilperez
Copy link
Copy Markdown
Collaborator

@dgilperez dgilperez commented May 23, 2026

Part of #11 (P1).

Adds CLI coverage for /api/v1/budgets and /api/v1/budget_categories, both of which Sure exposes as read-only resources.

Commands

  • budgets list [--start-date Y-M-D] [--end-date Y-M-D] — mirrors the upstream apply_filters (start_date >=, end_date <=).
  • budgets show <id>
  • budget-categories list [--budget-id UUID] [--category-id UUID] [--start-date Y-M-D] [--end-date Y-M-D] — full upstream filter set.
  • budget-categories show <id>

Path escaping on the show routes. Args: cobra.NoArgs on the list subcommands.

Verification

  • Endpoints confirmed in we-promise/sure config/routes.rb api/v1 namespace.
  • Filter list matches the controllers' apply_filters (budgets_controller.rb, budget_categories_controller.rb).
  • go build ./... + go test ./cmd/sure-cli/root/... green.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added budgets command with list and show subcommands for viewing budget information
    • Added budget-categories command with list and show subcommands for managing budget categories
    • Both commands support date range filtering, pagination, and ID-based filtering
    • Updated documentation with budget management usage examples

Review Change Stack

Refs #11.

- budgets list with start-date/end-date filters, show.
- budget-categories list with budget-id/category-id/start-date/end-date
  filters, show.
- Read-only commands; Sure exposes only :index and :show on both
  resources via api/v1.

Path escaping on the new show routes. Args: cobra.NoArgs on list
subcommands so a typo doesn't get silently ignored.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds two new CLI command groups—budgets and budget-categories—to the sure-cli tool. Each command supports list and show operations with pagination, optional date filtering, and resource ID lookups, fully wired into the root command, tested, and documented.

Changes

Budgets CLI Commands

Layer / File(s) Summary
Budget command implementations
cmd/sure-cli/root/budgets_cmds.go
newBudgetsCmd() and newBudgetCategoriesCmd() define Cobra command trees. Both include list (with pagination, optional start/end-date, and budget/category ID filters) and show <id> subcommands that construct query URLs and issue GET requests to the REST API.
Command registration and tests
cmd/sure-cli/root/root.go, cmd/sure-cli/root/budgets_cmds_test.go
Root command registers both new command builders. Three tests validate command structure (subcommand resolution, Args validators), flag definitions (pagination, dates, IDs), and command path resolution from root to leaf.
Usage documentation
README.md
Usage section adds examples for budgets list/show and budget-categories list/show commands.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A budgets command hops into view,
With list and show, both shiny and new,
Dates and filters in tow,
Tests passing—here we go!
Documentation complete, the feature is true. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding two new CLI commands (budgets and budget-categories) with their subcommands for read-only API endpoint coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cli-budgets-cmds

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@superagent-security superagent-security Bot added contributor:verified Contributor passed trust analysis. pr:verified PR passed security analysis. labels May 23, 2026
cobra's Find returns the nearest matching ancestor with no error when
a leaf is missing, so the prior test would have silently passed even
if a subcommand had been deregistered. Compare the resolved cmd's
Name() to the expected leaf to actually verify registration.
@dgilperez dgilperez merged commit 00c8d9c into main May 23, 2026
4 of 5 checks passed
@dgilperez dgilperez deleted the feat/cli-budgets-cmds branch May 23, 2026 19:31
dgilperez added a commit that referenced this pull request May 23, 2026
Same fix as #17: cobra's Find returns the nearest matching ancestor
when a leaf is missing, so the prior test would silently pass even
if a subcommand had been deregistered. Compare resolved Name() to
the expected leaf.
dgilperez added a commit that referenced this pull request May 23, 2026
* feat(transfers): add transfers and rejected-transfers commands

Read-only coverage for `/api/v1/transfers` and `/api/v1/rejected_transfers`:

- `transfers list` with `--status`, `--account-id`, `--start-date`,
  `--end-date`, and paging flags. Mirrors the upstream
  `Api::V1::TransferDecisionFiltering` concern (status is validated
  upstream against `Transfer.statuses`; account_id against UUID; dates
  filter the underlying entries.date).
- `transfers show <id>`.
- `rejected-transfers list` — same filters minus `--status` (the
  RejectedTransfer model has no status column).
- `rejected-transfers show <id>`.

Tests cover command shape, registration, expected flag set, and the
invariant that `rejected-transfers list` must NOT expose `--status`.

Part of #11 (P1.2).

* test(transfers): tighten registration test against cobra's loose Find

Same fix as #17: cobra's Find returns the nearest matching ancestor
when a leaf is missing, so the prior test would silently pass even
if a subcommand had been deregistered. Compare resolved Name() to
the expected leaf.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:verified Contributor passed trust analysis. pr:verified PR passed security analysis.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant