feat: bl project category add / update / delete#82
Conversation
There was a problem hiding this comment.
Pull request overview
Adds full CRUD support for Backlog project categories to the bl CLI, implementing the endpoints described in issue #40 and exposing them via new subcommands plus API client/trait methods.
Changes:
- Add
bl project category add|update|deleteCLI subcommands and wire them insrc/main.rs. - Implement
add_project_category,update_project_category,delete_project_categoryinBacklogClientand expose them on theBacklogApitrait. - Document the new commands (EN/JA) and mark the endpoints as implemented in the command coverage tables.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/main.rs |
Adds clap subcommands for category add/update/delete and routes to cmd handlers. |
src/cmd/project/category.rs |
Implements add/update/delete handlers and extends tests for new paths. |
src/api/project.rs |
Adds client methods calling the corresponding category endpoints (POST/PATCH/DELETE). |
src/api/mod.rs |
Extends BacklogApi trait and delegates new methods in the BacklogClient impl. |
website/docs/commands.md |
Adds EN docs sections for the new commands and updates the endpoint mapping table. |
website/i18n/ja/.../commands.md |
Adds JA docs sections and updates the endpoint mapping table accordingly. |
|
Tip For best results, initiate chat on the files or code changes.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds project category CRUD: trait methods and BacklogClient HTTP implementations, CLI subcommands and args, command handlers with JSON/text output, tests, and English/Japanese docs updates reflecting the new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (bl)
participant Cmd as Command Handler
participant API as BacklogApi (trait)
participant Client as BacklogClient (HTTP)
participant Server as Backlog Server
CLI->>Cmd: parse args (add/update/delete)
Cmd->>API: call add_project_category/update_project_category/delete_project_category
API->>Client: forwarded call (key, category_id?, name?)
Client->>Server: HTTP POST/PATCH/DELETE /api/v2/projects/{key}/categories(/id)
Server-->>Client: 200 OK + JSON body
Client-->>API: deserialize JSON -> ProjectCategory
API-->>Cmd: Result<ProjectCategory>
Cmd-->>CLI: print JSON or formatted text
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/api/project.rs (1)
249-290: Addhttpmockcoverage for these endpoints.A wrong verb, path, or form key here will compile and only fail against the real service. Please add API-layer tests for add/update/delete category next to the existing project endpoint coverage.
As per coding guidelines, "For
api/layer tests, usehttpmockto spin up a local HTTP server and constructBacklogClient::new_with(base_url, api_key)instead of callingBacklogClient::from_config()."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/project.rs` around lines 249 - 290, Add httpmock-based tests covering add_project_category, update_project_category, and delete_project_category: spin up an httpmock::MockServer, create a BacklogClient with BacklogClient::new_with(server.url(""), "api_key"), and register mocks that assert the correct HTTP method (POST for add_project_category, PATCH for update_project_category, DELETE for delete_project_category), correct paths (/projects/{key}/categories and /projects/{key}/categories/{id}), and form keys (e.g., "name") and return representative JSON responses; then call the client methods and assert successful deserialization into ProjectCategory and that the server received the expected requests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/api/project.rs`:
- Around line 249-290: The ProjectCategory responses returned by
add_project_category, update_project_category, and delete_project_category are
missing the project_id field; update the ProjectCategory model to include a
project_id (snake_case) with appropriate serde mapping and type (e.g., u64 or
Option<u64> matching API), then ensure any (de)serialization derives or impls
reflect the new field so the results returned by those functions include
project_id when serializing to JSON.
---
Nitpick comments:
In `@src/api/project.rs`:
- Around line 249-290: Add httpmock-based tests covering add_project_category,
update_project_category, and delete_project_category: spin up an
httpmock::MockServer, create a BacklogClient with
BacklogClient::new_with(server.url(""), "api_key"), and register mocks that
assert the correct HTTP method (POST for add_project_category, PATCH for
update_project_category, DELETE for delete_project_category), correct paths
(/projects/{key}/categories and /projects/{key}/categories/{id}), and form keys
(e.g., "name") and return representative JSON responses; then call the client
methods and assert successful deserialization into ProjectCategory and that the
server received the expected requests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9ce39bd0-8194-49b0-91aa-e478043df682
📒 Files selected for processing (6)
src/api/mod.rssrc/api/project.rssrc/cmd/project/category.rssrc/main.rswebsite/docs/commands.mdwebsite/i18n/ja/docusaurus-plugin-content-docs/current/commands.md
Addresses review comment: ProjectCategory is losing projectId
Checklist
mainwebsite/docs/,website/i18n/ja/,README.md)Summary
bl project category add,update,deletesubcommandsadd_project_category,update_project_category,delete_project_categoryinBacklogClientandBacklogApitraitReason for change
Implements #40.
Changes
src/api/project.rs: Addadd_project_category,update_project_category,delete_project_categorysrc/api/mod.rs: Declare trait methods and delegate toBacklogClientsrc/cmd/project/category.rs: Addadd_with,update_with,delete_withwith testssrc/main.rs: Wire up new subcommands via clapwebsite/docs/commands.md,website/i18n/ja/.../commands.md: Add docs and mark as implementedNotes
Closes #40