Skip to content

feat: bl project category add / update / delete#82

Merged
23prime merged 2 commits intomainfrom
feature/40-project-category-add-update-delete
Mar 20, 2026
Merged

feat: bl project category add / update / delete#82
23prime merged 2 commits intomainfrom
feature/40-project-category-add-update-delete

Conversation

@23prime
Copy link
Owner

@23prime 23prime commented Mar 20, 2026

Checklist

  • Target branch is main
  • Status checks are passing
  • Documentation updated if user-visible behavior changed (website/docs/, website/i18n/ja/, README.md)

Summary

  • Add bl project category add, update, delete subcommands
  • Implement add_project_category, update_project_category, delete_project_category in BacklogClient and BacklogApi trait

Reason for change

Implements #40.

Changes

  • src/api/project.rs: Add add_project_category, update_project_category, delete_project_category
  • src/api/mod.rs: Declare trait methods and delegate to BacklogClient
  • src/cmd/project/category.rs: Add add_with, update_with, delete_with with tests
  • src/main.rs: Wire up new subcommands via clap
  • website/docs/commands.md, website/i18n/ja/.../commands.md: Add docs and mark as implemented

Notes

Closes #40

Copilot AI review requested due to automatic review settings March 20, 2026 04:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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|delete CLI subcommands and wire them in src/main.rs.
  • Implement add_project_category, update_project_category, delete_project_category in BacklogClient and expose them on the BacklogApi trait.
  • 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.

@23prime
Copy link
Owner Author

23prime commented Mar 20, 2026

@coderabbitai hi

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

Tip

For best results, initiate chat on the files or code changes.

@23prime Hi there! 👋 How can I help you with this PR? Feel free to ask if you'd like me to review specific parts, answer questions about the changes, or anything else!

@23prime
Copy link
Owner Author

23prime commented Mar 20, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ef839d70-162a-4c11-adb1-54b62864f92f

📥 Commits

Reviewing files that changed from the base of the PR and between 7301843 and 259d658.

📒 Files selected for processing (2)
  • src/api/project.rs
  • src/cmd/project/category.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/api/project.rs
  • src/cmd/project/category.rs

📝 Walkthrough

Walkthrough

Adds 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 add, update, and delete commands.

Changes

Cohort / File(s) Summary
API Trait & Client
src/api/mod.rs, src/api/project.rs
Added add_project_category, update_project_category, delete_project_category to BacklogApi and implemented them on BacklogClient. New HTTP flows: POST /projects/{key}/categories, PATCH /projects/{key}/categories/{id}, DELETE /projects/{key}/categories/{id}. Added ProjectCategory::project_id and JSON deserialization with enriched error context.
CLI Commands & Tests
src/cmd/project/category.rs
Introduced ProjectCategoryAddArgs, ProjectCategoryUpdateArgs, ProjectCategoryDeleteArgs and command handlers (add/add_with, update/update_with, delete/delete_with) that call the API and print JSON or formatted text. Updated unit test mocks and added tests for success and error cases.
CLI Wiring
src/main.rs
Extended CLI enum and dispatch to include project category add/update/delete variants with --json and --category-id flags; routes to new command handlers.
Docs (EN & JA)
website/docs/commands.md, website/i18n/ja/.../commands.md
Added documentation and examples for bl project category add/update/delete, updated command coverage matrix, and changed update/delete syntax to use --category-id <id> named flag.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped to add a category bright,
Patched and deleted with gentle might,
CLI whispers JSON or plain delight,
Projects tidy now — hop, hop, alright! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.08% 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
Title check ✅ Passed The title 'feat: bl project category add / update / delete' clearly describes the primary changes: three new CLI subcommands for managing project categories.
Description check ✅ Passed The description is related to the changeset, providing a clear summary of objectives, implementation details, and files modified for the feature.
Linked Issues check ✅ Passed The PR successfully implements all three objectives from issue #40: add/update/delete CLI subcommands with corresponding API methods and proper HTTP endpoints.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the three new project category commands specified in issue #40; no out-of-scope modifications detected.

✏️ 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 feature/40-project-category-add-update-delete
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feature/40-project-category-add-update-delete
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/api/project.rs (1)

249-290: Add httpmock coverage 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, use httpmock to spin up a local HTTP server and construct BacklogClient::new_with(base_url, api_key) instead of calling BacklogClient::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

📥 Commits

Reviewing files that changed from the base of the PR and between e73f470 and 7301843.

📒 Files selected for processing (6)
  • src/api/mod.rs
  • src/api/project.rs
  • src/cmd/project/category.rs
  • src/main.rs
  • website/docs/commands.md
  • website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md

Addresses review comment: ProjectCategory is losing projectId
@23prime 23prime merged commit 5350dd8 into main Mar 20, 2026
11 checks passed
@23prime 23prime deleted the feature/40-project-category-add-update-delete branch March 20, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: bl project category add / update / delete

2 participants