Skip to content

feat: add bl star add / delete commands#99

Merged
23prime merged 2 commits intomainfrom
feature/51-star-commands
Mar 21, 2026
Merged

feat: add bl star add / delete commands#99
23prime merged 2 commits intomainfrom
feature/51-star-commands

Conversation

@23prime
Copy link
Owner

@23prime 23prime commented Mar 21, 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 star add — POST /api/v2/stars (adds a star to an issue, comment, wiki, pull request, or pull request comment)
  • Add bl star delete <id> — DELETE /api/v2/stars/{starId} (removes a star by its ID)

Reason for change

Implements the star management commands requested in #51.

Changes

  • src/api/user.rs: add add_star and delete_star methods to BacklogClient
  • src/api/mod.rs: add add_star / delete_star to BacklogApi trait and BacklogClient impl
  • src/cmd/star/: new module with add.rs and delete.rs command handlers
  • src/cmd/mod.rs: register star module
  • src/main.rs: add Star command with Add / Delete subcommands and StarCommands enum
  • website/docs/commands.md / website/i18n/ja/.../commands.md: document new commands and mark as implemented in coverage table

Notes

Both endpoints return 204 No Content, so neither command produces output on success.
Validation: bl star add requires exactly one of --issue-id, --comment-id, --wiki-id, --pull-request-id, --pull-request-comment-id.

Closes #51

Copilot AI review requested due to automatic review settings March 21, 2026 07:05
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 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: 01f96b3b-da1b-41d4-a4dd-0bd23ae5ac14

📥 Commits

Reviewing files that changed from the base of the PR and between 32449f5 and eb95ae0.

📒 Files selected for processing (1)
  • src/cmd/star/add.rs

📝 Walkthrough

Walkthrough

Adds star management: new BacklogApi trait methods add_star/delete_star and BacklogClient implementations; CLI subcommands bl star add and bl star delete with argument validation; wiring into main dispatcher; and English/Japanese docs updated.

Changes

Cohort / File(s) Summary
API trait & client
src/api/mod.rs, src/api/user.rs
Added fn add_star(&self, params: &[(String, String)]) -> Result<()> and fn delete_star(&self, star_id: u64) -> Result<()> to BacklogApi; implemented delegations in BacklogClient performing POST /stars and DELETE /stars/{star_id}.
CLI command modules
src/cmd/mod.rs, src/cmd/star/mod.rs, src/cmd/star/add.rs, src/cmd/star/delete.rs
Added star submodule with add and delete. StarAddArgs::try_new enforces exactly one target ID; add_with builds params and calls api.add_star. StarDeleteArgs and delete_with call api.delete_star. Unit tests added.
CLI wiring
src/main.rs
Added top-level Star command with Add (multiple optional IDs) and Delete (id) subcommands, wired to corresponding cmd handlers.
Documentation
website/docs/commands.md, website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md
Documented bl star add and bl star delete usage and updated command-to-API coverage table to mark POST/DELETE stars endpoints as implemented.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI (bl star add)
    participant Cmd as cmd::star::add
    participant API as BacklogApi (trait)
    participant Client as BacklogClient
    participant Server as Backlog HTTP API

    CLI->>Cmd: parse args -> StarAddArgs
    Cmd->>API: add_with(params)
    API-->>Client: BacklogClient impl invoked
    Client->>Server: POST /api/v2/stars (form params)
    Server-->>Client: 204 No Content
    Client-->>API: Ok(())
    API-->>Cmd: Ok(())
    Cmd-->>CLI: exit success
Loading
sequenceDiagram
    participant CLI as CLI (bl star delete)
    participant Cmd as cmd::star::delete
    participant API as BacklogApi (trait)
    participant Client as BacklogClient
    participant Server as Backlog HTTP API

    CLI->>Cmd: parse args -> StarDeleteArgs
    Cmd->>API: delete_with(star_id)
    API-->>Client: BacklogClient impl invoked
    Client->>Server: DELETE /api/v2/stars/{star_id}
    Server-->>Client: 204 No Content
    Client-->>API: Ok(())
    API-->>Cmd: Ok(())
    Cmd-->>CLI: exit success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 34.29% 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: add bl star add / delete commands' clearly and concisely summarizes the main changes in this PR, which implement two new CLI commands for star management.
Description check ✅ Passed The description provides a clear and detailed explanation of what was added, why it was added (referencing issue #51), and includes documentation updates and validation notes.
Linked Issues check ✅ Passed The PR implements two of four requested features in issue #51: 'bl star add' (POST /api/v2/stars) and 'bl star delete' (DELETE /api/v2/stars/{starId}) are fully implemented with proper validation and documentation.
Out of Scope Changes check ✅ Passed All changes directly support the implementation of the star add/delete commands or their documentation. Documentation updates for both English and Japanese versions are appropriate for user-visible feature additions.

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

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feature/51-star-commands

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

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 CLI support for managing Backlog “stars” by wiring new bl star add / bl star delete commands through the command layer, API trait/client, and user-facing documentation.

Changes:

  • Add new star command module with add (POST /api/v2/stars) and delete (DELETE /api/v2/stars/{starId}) handlers and validation.
  • Extend BacklogApi + BacklogClient with add_star / delete_star API methods.
  • Document the new commands (EN + JA) and mark them as implemented in the command coverage tables.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md Adds JA docs for bl star add/delete and updates coverage status.
website/docs/commands.md Adds EN docs for bl star add/delete and updates coverage status.
src/main.rs Registers the new Star top-level command and subcommands; wires args into handlers.
src/cmd/star/mod.rs Introduces cmd::star module exports for add/delete.
src/cmd/star/add.rs Implements bl star add validation (exactly one target) and request param construction + tests.
src/cmd/star/delete.rs Implements bl star delete + tests.
src/cmd/mod.rs Registers the new star module.
src/api/user.rs Adds BacklogClient::add_star / delete_star HTTP methods.
src/api/mod.rs Adds add_star / delete_star to BacklogApi and forwards in BacklogClient impl.

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.

🧹 Nitpick comments (2)
src/cmd/star/mod.rs (1)

1-5: Prefer a single consolidated star command file instead of per-subcommand files.

This split (add.rs / delete.rs) diverges from the repository’s established sub-resource command layout and will increase fragmentation over time.

Based on learnings: “In the 23prime/backlog-cli repository, sub-resource command files under src/cmd/<resource>/ … should consolidate all subcommands … into a single file per resource.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cmd/star/mod.rs` around lines 1 - 5, Consolidate the split subcommand
modules into one resource module by inlining the add.rs and delete.rs contents
into this single module: remove the mod add; mod delete; declarations and copy
the implementations of add, delete, StarAddArgs and StarDeleteArgs into this
file, keeping the public exports (pub use add::{StarAddArgs, add}; pub use
delete::{StarDeleteArgs, delete};) replaced by direct pub declarations or
re-exports from the local implementations so callers still reference add,
delete, StarAddArgs and StarDeleteArgs the same way; delete the now-empty add.rs
and delete.rs files and ensure module-level tests/visibility are preserved.
src/api/user.rs (1)

157-165: Move /stars endpoint methods to a dedicated API resource module and add endpoint tests.

The wrappers work, but placing star-specific endpoints in src/api/user.rs breaks the API resource organization pattern and makes discovery harder. Please move these methods to src/api/star.rs (with module registration) and add httpmock tests for POST /stars and DELETE /stars/{starId} behavior.

As per coding guidelines: “For new API endpoints, add response struct and impl BacklogClient block in src/api/<resource>.rs, add method to BacklogApi trait in src/api/mod.rs, and add pub mod <resource> to src/api/mod.rs,” and “For api/ layer tests, use httpmock … with BacklogClient::new_with(base_url, api_key).”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/api/user.rs` around lines 157 - 165, Move the star-specific methods out
of src/api/user.rs into a new src/api/star.rs: create a response struct for the
endpoints, add an impl BacklogClient block containing add_star(&self, params:
&[(String,String)])->Result<()> and delete_star(&self, star_id:
u64)->Result<()>, and remove the old methods from user.rs; then register the
module by adding pub mod star; and add corresponding method signatures to the
BacklogApi trait in src/api/mod.rs. Finally add httpmock tests exercising POST
/stars and DELETE /stars/{starId} using BacklogClient::new_with(base_url,
api_key) to assert request paths, methods and expected responses.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/api/user.rs`:
- Around line 157-165: Move the star-specific methods out of src/api/user.rs
into a new src/api/star.rs: create a response struct for the endpoints, add an
impl BacklogClient block containing add_star(&self, params:
&[(String,String)])->Result<()> and delete_star(&self, star_id:
u64)->Result<()>, and remove the old methods from user.rs; then register the
module by adding pub mod star; and add corresponding method signatures to the
BacklogApi trait in src/api/mod.rs. Finally add httpmock tests exercising POST
/stars and DELETE /stars/{starId} using BacklogClient::new_with(base_url,
api_key) to assert request paths, methods and expected responses.

In `@src/cmd/star/mod.rs`:
- Around line 1-5: Consolidate the split subcommand modules into one resource
module by inlining the add.rs and delete.rs contents into this single module:
remove the mod add; mod delete; declarations and copy the implementations of
add, delete, StarAddArgs and StarDeleteArgs into this file, keeping the public
exports (pub use add::{StarAddArgs, add}; pub use delete::{StarDeleteArgs,
delete};) replaced by direct pub declarations or re-exports from the local
implementations so callers still reference add, delete, StarAddArgs and
StarDeleteArgs the same way; delete the now-empty add.rs and delete.rs files and
ensure module-level tests/visibility are preserved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3a05f7a3-c9d8-4445-a539-2cd8914de933

📥 Commits

Reviewing files that changed from the base of the PR and between fbdf2c8 and 32449f5.

📒 Files selected for processing (9)
  • src/api/mod.rs
  • src/api/user.rs
  • src/cmd/mod.rs
  • src/cmd/star/add.rs
  • src/cmd/star/delete.rs
  • src/cmd/star/mod.rs
  • src/main.rs
  • website/docs/commands.md
  • website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md

Addresses review comment: add tests that capture params and assert correct key/value for each target
@23prime 23prime merged commit 75bb1c3 into main Mar 21, 2026
8 checks passed
@23prime 23prime deleted the feature/51-star-commands branch March 21, 2026 07:16
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 star add / delete + bl user star list / count

2 participants