Skip to content

feat: add bl wiki count/tag/star/attachment/shared-file commands#102

Merged
23prime merged 3 commits intomainfrom
feature/49-wiki-enhancements
Mar 21, 2026
Merged

feat: add bl wiki count/tag/star/attachment/shared-file commands#102
23prime merged 3 commits intomainfrom
feature/49-wiki-enhancements

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 wiki count — GET /api/v2/wikis/count
  • Add bl wiki tag list — GET /api/v2/wikis/tags
  • Add bl wiki star list <id> — GET /api/v2/wikis/{wikiId}/stars
  • Add bl wiki attachment add/get/delete — POST/GET/DELETE /api/v2/wikis/{wikiId}/attachments
  • Add bl wiki shared-file list/link/unlink — GET/POST/DELETE /api/v2/wikis/{wikiId}/sharedFiles

Reason for change

Implements the remaining wiki subcommands planned in #49.

Changes

  • src/api/wiki.rs: Added WikiCount, WikiSharedFile structs and 9 new BacklogClient methods
  • src/api/mod.rs: Added corresponding BacklogApi trait methods and impls
  • src/cmd/wiki/: New modules count, tag, star, shared_file; extended attachment module with add, get, delete
  • src/main.rs: Added WikiCommands::Count/Tag/Star/SharedFile, extended WikiAttachmentCommands
  • website/docs/commands.md and JA equivalent: Added command docs and updated coverage table

Notes

Closes #49

Implements bl wiki count, bl wiki tag list, bl wiki star list,
bl wiki attachment add/get/delete, bl wiki shared-file list/link/unlink.

Closes #49
Copilot AI review requested due to automatic review settings March 21, 2026 08:12
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

Warning

Rate limit exceeded

@23prime has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7593a1a0-9b1a-4ae5-a09b-90c513d78a76

📥 Commits

Reviewing files that changed from the base of the PR and between 36321c4 and e471241.

📒 Files selected for processing (3)
  • src/api/mod.rs
  • src/api/wiki.rs
  • src/cmd/wiki/shared_file/link.rs
📝 Walkthrough

Walkthrough

Adds Wiki API models and BacklogApi methods, implements them in BacklogClient, and provides CLI commands for wiki count, tags, stars, attachment add/get/delete, and shared-file list/link/unlink, with tests and documentation updates.

Changes

Cohort / File(s) Summary
API Layer
src/api/mod.rs, src/api/wiki.rs
Added WikiCount, WikiSharedFile, WikiTag imports; extended BacklogApi trait with wiki methods (count, tags, stars, attachment add/download/delete, shared-file list/link/unlink) and implemented them on BacklogClient.
Wiki Attachment Commands
src/cmd/wiki/attachment/add.rs, src/cmd/wiki/attachment/get.rs, src/cmd/wiki/attachment/delete.rs, src/cmd/wiki/attachment/mod.rs
New CLI subcommands for attachment add/get/delete with argument validation, API delegation, text/JSON output, file write on download, and unit tests; module re-exports updated.
Wiki Shared-file Commands
src/cmd/wiki/shared_file/link.rs, src/cmd/wiki/shared_file/list.rs, src/cmd/wiki/shared_file/unlink.rs, src/cmd/wiki/shared_file/mod.rs
Implemented shared-file list/link/unlink commands; link validates non-empty IDs; supports text/JSON output and includes unit tests and module re-exports.
Wiki Metadata Commands
src/cmd/wiki/count.rs, src/cmd/wiki/tag/list.rs, src/cmd/wiki/tag/mod.rs, src/cmd/wiki/star/list.rs, src/cmd/wiki/star/mod.rs
Added wiki count, tag list, and star list commands with optional project filter, JSON/text output, API calls, and tests.
CLI Integration
src/cmd/wiki/mod.rs, src/main.rs
Extended WikiCommands and nested enums for attachments, tags, stars, shared-files, and count; wired new commands into run() dispatcher and argument validation.
Docs / i18n
website/docs/commands.md, website/i18n/ja/.../commands.md
Documented all new wiki CLI commands with examples and updated API coverage table (marked implemented).

Sequence Diagram(s)

sequenceDiagram
  participant CLI as "bl (CLI)"
  participant Cmd as "cmd::wiki::<action>"
  participant API as "BacklogApi (BacklogClient)"
  participant Server as "Backlog HTTP API"
  participant FS as "Filesystem"

  CLI->>Cmd: invoke command (args)
  Cmd->>API: call method (e.g., get_wiki_count / add_wiki_attachments / download_wiki_attachment / link_wiki_shared_files)
  API->>Server: HTTP request (GET/POST/DELETE /api/v2/wikis/...)
  Server-->>API: HTTP response (JSON or bytes + filename)
  API-->>Cmd: deserialized result or bytes+filename
  alt download attachment
    Cmd->>FS: write bytes to resolved path
    FS-->>Cmd: write result
    Cmd-->>CLI: print "Saved: <path> (<bytes>)"
  else non-download responses
    Cmd-->>CLI: print text or pretty JSON
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% 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 accurately summarizes the main changes: adding multiple wiki CLI commands (count, tag, star, attachment, shared-file operations).
Description check ✅ Passed The description clearly explains the changes, lists all new commands with their API endpoints, references the related issue #49, and includes implementation details.
Linked Issues check ✅ Passed The PR fully implements all requirements from issue #49: wiki count command, tag list command, star list command, attachment add/get/delete operations, and shared-file list/link/unlink operations with corresponding API endpoints.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing the wiki enhancements specified in issue #49; no unrelated modifications were introduced.

✏️ 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/49-wiki-enhancements

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 the remaining planned bl wiki subcommands by wiring new CLI surfaces to new Backlog API client/trait methods, and documenting the new commands in the Docusaurus docs.

Changes:

  • Implemented new wiki commands: count, tag list, star list, attachment add/get/delete, and shared-file list/link/unlink.
  • Extended the API layer with new wiki endpoint methods and corresponding BacklogApi trait entries.
  • Updated English/Japanese command documentation and the command coverage table.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md Adds JA docs for new wiki subcommands and marks them implemented in the coverage table.
website/docs/commands.md Adds EN docs for new wiki subcommands and marks them implemented in the coverage table.
src/main.rs Wires new clap subcommands/args to the new cmd::wiki::* handlers.
src/cmd/wiki/mod.rs Registers new wiki submodules (count/tag/star/shared_file) and re-exports count.
src/cmd/wiki/count.rs Implements bl wiki count command + unit tests with MockApi.
src/cmd/wiki/tag/mod.rs Adds wiki tag module re-exports.
src/cmd/wiki/tag/list.rs Implements bl wiki tag list + unit tests with MockApi.
src/cmd/wiki/star/mod.rs Adds wiki star module re-exports.
src/cmd/wiki/star/list.rs Implements bl wiki star list + unit tests with MockApi.
src/cmd/wiki/attachment/mod.rs Adds attachment add/get/delete modules and re-exports their args/handlers.
src/cmd/wiki/attachment/add.rs Implements bl wiki attachment add + validation + unit tests.
src/cmd/wiki/attachment/get.rs Implements bl wiki attachment get (download) + unit tests.
src/cmd/wiki/attachment/delete.rs Implements bl wiki attachment delete + unit tests.
src/cmd/wiki/shared_file/mod.rs Adds shared-file list/link/unlink modules and re-exports args/handlers.
src/cmd/wiki/shared_file/list.rs Implements bl wiki shared-file list + unit tests.
src/cmd/wiki/shared_file/link.rs Implements bl wiki shared-file link + validation + unit tests.
src/cmd/wiki/shared_file/unlink.rs Implements bl wiki shared-file unlink + unit tests.
src/api/wiki.rs Adds new wiki API structs and BacklogClient methods for the new endpoints.
src/api/mod.rs Extends BacklogApi trait + BacklogClient impl with the new wiki methods.

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 (4)
src/cmd/wiki/tag/list.rs (1)

71-85: Consider asserting formatted output in success tests.

The current tests verify execution success but not the actual printed output format; adding output assertions would better prevent regressions in CLI UX.

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

In `@src/cmd/wiki/tag/list.rs` around lines 71 - 85, The tests
list_with_text_output_succeeds and list_with_json_output_succeeds only check for
Ok but not the actual stdout; update each test to capture the command output
produced by list_with (use the same mechanism your crate uses to capture stdout
in tests), assert the call still returns Ok, and then assert the captured output
contains the expected formatted representation of sample_tag (for the text test
assert substrings like the tag name/description or table headers, for the json
test assert valid JSON containing the sample_tag fields or a JSON array). Locate
list_with, args, MockApi, and sample_tag to implement the capture and concrete
assertions.
src/cmd/wiki/star/list.rs (1)

79-93: Strengthen tests by asserting rendered output, not just success.

Current success tests only check is_ok(). Adding assertions for text/JSON output content would better lock the CLI output contract.

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

In `@src/cmd/wiki/star/list.rs` around lines 79 - 93, The tests currently only
assert list_with(...).is_ok() — change them to also assert the rendered output
matches expectations: call list_with(&args(false), &api) and unwrap the Ok value
or capture stdout, then assert the text output contains identifying fields from
sample_star() (e.g., title, id or url) for the text test; for the JSON test call
list_with(&args(true), &api), unwrap the Ok value and parse it with
serde_json::from_str and assert the parsed JSON array contains an object equal
to sample_star()'s serialized representation (or at least contains the expected
id/title fields). Use MockApi, sample_star(), list_with, and args to locate the
code to modify.
src/main.rs (1)

1498-1506: Add -o for parity with the other download commands.

wiki attachment get only exposes --output, while the other download flows in this file accept -o/--output. Adding the short alias keeps the CLI consistent.

♻️ Suggested tweak
-        #[arg(long)]
+        #[arg(long, short)]
         output: Option<std::path::PathBuf>,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.rs` around lines 1498 - 1506, The Get variant for the wiki
attachment download exposes only a long flag for output; update the attribute on
the output field in the Get enum (symbol: Get, field: output) to add a short
alias -o (e.g. change #[arg(long)] to #[arg(short, long)] or #[arg(short = 'o',
long)]) so the command supports -o/--output like the other download commands and
retains the Option<std::path::PathBuf> type.
src/api/wiki.rs (1)

138-212: Please add httpmock coverage for the new wiki endpoints.

This new surface adds nine wiki API methods, but the tests shown in this file still only exercise the pre-existing wiki calls. A few focused httpmock tests for count/tag/star/shared-file paths and response shapes would catch regressions like the shared-file link contract mismatch much earlier.

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/wiki.rs` around lines 138 - 212, Add focused httpmock-based tests
covering the nine new wiki API methods (get_wiki_count, get_wiki_tags,
get_wiki_stars, add_wiki_attachments, download_wiki_attachment,
delete_wiki_attachment, get_wiki_shared_files, link_wiki_shared_files,
unlink_wiki_shared_file): spin up an httpmock server, construct
BacklogClient::new_with(mock.base_url(), api_key), stub the expected HTTP paths
and verbs (including form bodies for post_form and query params for
get_with_query), return representative JSON/binary responses, call each client
method and assert the deserialized shapes and status handling; include a test
specifically asserting the POST /wikis/{id}/sharedFiles contract (fileId[] vs
expected shape) to catch the shared-file link mismatch.
🤖 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/wiki.rs`:
- Around line 138-212: Add focused httpmock-based tests covering the nine new
wiki API methods (get_wiki_count, get_wiki_tags, get_wiki_stars,
add_wiki_attachments, download_wiki_attachment, delete_wiki_attachment,
get_wiki_shared_files, link_wiki_shared_files, unlink_wiki_shared_file): spin up
an httpmock server, construct BacklogClient::new_with(mock.base_url(), api_key),
stub the expected HTTP paths and verbs (including form bodies for post_form and
query params for get_with_query), return representative JSON/binary responses,
call each client method and assert the deserialized shapes and status handling;
include a test specifically asserting the POST /wikis/{id}/sharedFiles contract
(fileId[] vs expected shape) to catch the shared-file link mismatch.

In `@src/cmd/wiki/star/list.rs`:
- Around line 79-93: The tests currently only assert list_with(...).is_ok() —
change them to also assert the rendered output matches expectations: call
list_with(&args(false), &api) and unwrap the Ok value or capture stdout, then
assert the text output contains identifying fields from sample_star() (e.g.,
title, id or url) for the text test; for the JSON test call
list_with(&args(true), &api), unwrap the Ok value and parse it with
serde_json::from_str and assert the parsed JSON array contains an object equal
to sample_star()'s serialized representation (or at least contains the expected
id/title fields). Use MockApi, sample_star(), list_with, and args to locate the
code to modify.

In `@src/cmd/wiki/tag/list.rs`:
- Around line 71-85: The tests list_with_text_output_succeeds and
list_with_json_output_succeeds only check for Ok but not the actual stdout;
update each test to capture the command output produced by list_with (use the
same mechanism your crate uses to capture stdout in tests), assert the call
still returns Ok, and then assert the captured output contains the expected
formatted representation of sample_tag (for the text test assert substrings like
the tag name/description or table headers, for the json test assert valid JSON
containing the sample_tag fields or a JSON array). Locate list_with, args,
MockApi, and sample_tag to implement the capture and concrete assertions.

In `@src/main.rs`:
- Around line 1498-1506: The Get variant for the wiki attachment download
exposes only a long flag for output; update the attribute on the output field in
the Get enum (symbol: Get, field: output) to add a short alias -o (e.g. change
#[arg(long)] to #[arg(short, long)] or #[arg(short = 'o', long)]) so the command
supports -o/--output like the other download commands and retains the
Option<std::path::PathBuf> type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 25c35c22-7578-4683-9f23-620913ae6791

📥 Commits

Reviewing files that changed from the base of the PR and between 9f1df2b and 36321c4.

📒 Files selected for processing (19)
  • src/api/mod.rs
  • src/api/wiki.rs
  • src/cmd/wiki/attachment/add.rs
  • src/cmd/wiki/attachment/delete.rs
  • src/cmd/wiki/attachment/get.rs
  • src/cmd/wiki/attachment/mod.rs
  • src/cmd/wiki/count.rs
  • src/cmd/wiki/mod.rs
  • src/cmd/wiki/shared_file/link.rs
  • src/cmd/wiki/shared_file/list.rs
  • src/cmd/wiki/shared_file/mod.rs
  • src/cmd/wiki/shared_file/unlink.rs
  • src/cmd/wiki/star/list.rs
  • src/cmd/wiki/star/mod.rs
  • src/cmd/wiki/tag/list.rs
  • src/cmd/wiki/tag/mod.rs
  • src/main.rs
  • website/docs/commands.md
  • website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md

23prime added 2 commits March 21, 2026 17:23
…dd API tests

Addresses review comment: return type inconsistency between list/link/unlink
@23prime 23prime merged commit 1e4a13c into main Mar 21, 2026
7 checks passed
@23prime 23prime deleted the feature/49-wiki-enhancements branch March 21, 2026 08:31
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 wiki enhancements (count / tag list / stars / attachment add-get / shared-file ops)

2 participants