feat: bl project status add / update / delete / reorder#77
Conversation
📝 WalkthroughWalkthroughAdds four project-status operations (add, update, delete, reorder): BacklogApi trait methods and BacklogClient implementations, HTTP handlers in project API, CLI subcommands/args/validation + tests, and updated documentation and i18n. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as "CLI (main/status)"
participant API as "BacklogApi / BacklogClient"
participant HTTP as "HTTP client"
participant Server as "Backlog API server"
CLI->>API: call add/update/delete/reorder(args)
API->>HTTP: build HTTP request (POST/PATCH/DELETE/PATCH) to /projects/{key}/statuses...
HTTP->>Server: send HTTP request
Server-->>HTTP: JSON response
HTTP-->>API: return raw JSON
API->>API: deserialize -> ProjectStatus / Vec<ProjectStatus]
API-->>CLI: return Result<ProjectStatus|Vec<ProjectStatus]>
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
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 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.
Pull request overview
Adds full CRUD-style support for project statuses to the bl project status command group, including corresponding Backlog API client methods and documentation updates (English + Japanese).
Changes:
- Add new CLI subcommands:
bl project status add|update|delete|reorder(plus wiring inmain.rs) - Implement new
BacklogApitrait methods andBacklogClientendpoints for project status management - Update command reference docs and mark the endpoints as implemented in the commands/API mapping table
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/commands.md | Documents the new project status subcommands and updates the API↔command coverage table (EN). |
| website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md | Same documentation and coverage table updates for Japanese docs. |
| src/main.rs | Adds clap subcommands + routes to the new cmd handlers/Args structs. |
| src/cmd/project/status.rs | Implements cmd-layer handlers (*_with) + Args structs + unit tests for add/update/delete/reorder. |
| src/api/project.rs | Adds BacklogClient methods for POST/PATCH/DELETE/PATCH endpoints for project statuses. |
| src/api/mod.rs | Extends BacklogApi trait + implements the new methods for BacklogClient. |
You can also share your feedback on Copilot code review. Take the survey.
…ry_new Addresses review comment: empty status_ids list is semantically invalid
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/api/project.rs (1)
231-306: Add API-layer tests for the new project status endpoints.These four methods are the only new
src/api/project.rsbindings without matchinghttpmockcoverage. That leaves the verb/path/form wiring unverified, especially the repeatedstatusId[]payload inreorder_project_statuses.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 231 - 306, Add httpmock-based API-layer tests for the four new functions add_project_status, update_project_status, delete_project_status, and reorder_project_statuses: spin up an httpmock server and construct the client with BacklogClient::new_with(base_url, api_key), then assert the HTTP verb, path, and form body for each endpoint (including repeated "statusId[]" entries for reorder_project_statuses) and return representative responses to validate successful serde via the existing methods; ensure each test verifies the exact form parameters, status_id/substituteStatusId usage, and that the client deserializes the response into ProjectStatus/Vec<ProjectStatus>.
🤖 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/cmd/project/status.rs`:
- Around line 137-145: The constructor ProjectStatusDeleteArgs::new currently
allows creating a delete request where substitute_status_id == status_id; add a
domain-level validation in Args::try_new (not just in the CLI parser) to detect
this case and return an Err indicating the substitute status cannot equal the
status being deleted, and stop callers from invoking the API path; keep
ProjectStatusDeleteArgs::new as a simple initializer if desired but ensure
Args::try_new checks the invariant (compare status_id and substitute_status_id)
and returns a clear error so cmd/*_with code never sends a request that
round-trips to the server for an obvious domain error.
- Around line 37-53: ProjectStatusAddArgs::new (and
ProjectStatusUpdateArgs::try_new) currently accept any string for color; add
validation to reject values that do not match the required "#RRGGBB" hex format
before any API call: implement a simple domain-invariant check (e.g., regex
/^#[0-9A-Fa-f]{6}$/) inside ProjectStatusAddArgs::new and inside
ProjectStatusUpdateArgs::try_new (or their constructors) and return an error (or
propagate a Result::Err) on invalid input so callers in cmd/*_with never
dispatch invalid colors to the network; ensure the error type/message matches
existing argument-validation conventions.
---
Nitpick comments:
In `@src/api/project.rs`:
- Around line 231-306: Add httpmock-based API-layer tests for the four new
functions add_project_status, update_project_status, delete_project_status, and
reorder_project_statuses: spin up an httpmock server and construct the client
with BacklogClient::new_with(base_url, api_key), then assert the HTTP verb,
path, and form body for each endpoint (including repeated "statusId[]" entries
for reorder_project_statuses) and return representative responses to validate
successful serde via the existing methods; ensure each test verifies the exact
form parameters, status_id/substituteStatusId usage, and that the client
deserializes the response into ProjectStatus/Vec<ProjectStatus>.
🪄 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: fa6071c7-3e82-43f0-9004-46c498e694fc
📒 Files selected for processing (6)
src/api/mod.rssrc/api/project.rssrc/cmd/project/status.rssrc/main.rswebsite/docs/commands.mdwebsite/i18n/ja/docusaurus-plugin-content-docs/current/commands.md
…t status commands
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/cmd/project/status.rs (1)
248-291: Strengthen the new command-layer tests.The success cases only assert
is_ok(), andMockApiignores the forwarded key/IDs/params. That means request-shaping and output-formatting regressions can slip through even though*_withowns both behaviors.As per coding guidelines, "Validation boundaries:
main.rs(clap) handles syntactic/type-level checks;Args::try_newhandles domain invariants;cmd/*_withhandles API call logic, output formatting, and API-spec constraints;api/handles HTTP-level error translation only".Also applies to: 304-493
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cmd/project/status.rs` around lines 248 - 291, The MockApi methods (get_project_statuses, add_project_status, update_project_status, delete_project_status, reorder_project_statuses) currently ignore incoming key/IDs/params and only return canned statuses; update MockApi to validate and/or record the forwarded arguments so tests can assert request shaping: add fields like expected_key/expected_status_id/expected_params/expected_status_ids or a last_call enum on MockApi and have each method compare incoming args against expectations (or populate last_call) and return Err when mismatched; then tighten the tests to set those expectations and assert specific call parameters and formatted output (not just is_ok()) for the cmd/*_with paths that own API call logic and formatting.
🤖 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/cmd/project/status.rs`:
- Around line 189-200: ProjectStatusReorderArgs::try_new currently only rejects
empty status_ids but must also reject duplicate IDs; update try_new to validate
that the provided status_ids Vec<u64> contains no duplicates (e.g., by inserting
into a HashSet and comparing lengths or checking for any repeated entry) and
return an anyhow::Error with a clear message like "Duplicate --status-id values
are not allowed for reorder" when duplicates are found; keep this domain
invariant in try_new so invalid duplicate inputs are caught locally before any
API call.
---
Nitpick comments:
In `@src/cmd/project/status.rs`:
- Around line 248-291: The MockApi methods (get_project_statuses,
add_project_status, update_project_status, delete_project_status,
reorder_project_statuses) currently ignore incoming key/IDs/params and only
return canned statuses; update MockApi to validate and/or record the forwarded
arguments so tests can assert request shaping: add fields like
expected_key/expected_status_id/expected_params/expected_status_ids or a
last_call enum on MockApi and have each method compare incoming args against
expectations (or populate last_call) and return Err when mismatched; then
tighten the tests to set those expectations and assert specific call parameters
and formatted output (not just is_ok()) for the cmd/*_with paths that own API
call logic and formatting.
🪄 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: 3dd5b9c4-706e-4e36-a74f-38cfdb78eceb
📒 Files selected for processing (3)
.cspell/dicts/project.txtsrc/cmd/project/status.rssrc/main.rs
✅ Files skipped from review due to trivial changes (1)
- .cspell/dicts/project.txt
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main.rs
Addresses review comment: duplicate --status-id values cannot describe a valid display order
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/cmd/project/status.rs`:
- Around line 57-232: Extract each subcommand (add, update, delete, reorder)
into its own module file under src/cmd/project: create add.rs, update.rs,
delete.rs and reorder.rs; move the corresponding public functions and their
*_with variants (add / add_with, update / update_with, delete / delete_with,
reorder / reorder_with) and their related Args structs and impls into their
respective files preserving signatures (e.g., ProjectStatusAddArgs +
add/add_with, ProjectStatusUpdateArgs + update/update_with, etc.) and keep
serialization/printing logic in those files; leave src/cmd/project/status.rs as
the wiring module that pub mod {add, update, delete, reorder}; and re-export the
public functions (pub use add::add; pub use add::add_with; etc.), ensuring the
top-level functions that call BacklogClient::from_config() remain in the wiring
file (or moved with identical behavior) so callers keep the same API.
🪄 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: 7817ac17-6ad0-4a30-9a4f-1287c9636be8
📒 Files selected for processing (1)
src/cmd/project/status.rs
Checklist
mainwebsite/docs/,website/i18n/ja/,README.md)Summary
bl project status add <id-or-key> --name <name> --color <color>—POST /api/v2/projects/{key}/statusesbl project status update <id-or-key> --status-id <id>—PATCH /api/v2/projects/{key}/statuses/{id}bl project status delete <id-or-key> --status-id <id> --substitute-status-id <id>—DELETE /api/v2/projects/{key}/statuses/{id}bl project status reorder <id-or-key> --status-id <id>...—PATCH /api/v2/projects/{key}/statuses/updateDisplayOrderReason for change
Implements the project status management commands requested in #38.
Changes
src/api/project.rs: added four newBacklogClientmethods and corresponding testssrc/api/mod.rs: added trait method declarations andBacklogApi for BacklogClientdelegationssrc/cmd/project/status.rs: addedadd/update/delete/reordersubcommands alongside existinglist;updateusestry_newrequiring at least one of--name/--colorsrc/main.rs: clap wiring for new subcommandswebsite/docs/commands.md,website/i18n/ja/.../commands.md: documentation and coverage table updatedNotes
Closes #38