feat: add bl wiki count/tag/star/attachment/shared-file commands#102
feat: add bl wiki count/tag/star/attachment/shared-file commands#102
Conversation
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
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds 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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 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✨ Simplify code
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 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, andshared-file list/link/unlink. - Extended the API layer with new wiki endpoint methods and corresponding
BacklogApitrait 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. |
There was a problem hiding this comment.
🧹 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-ofor parity with the other download commands.
wiki attachment getonly 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 addhttpmockcoverage 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
httpmocktests 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, 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/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
📒 Files selected for processing (19)
src/api/mod.rssrc/api/wiki.rssrc/cmd/wiki/attachment/add.rssrc/cmd/wiki/attachment/delete.rssrc/cmd/wiki/attachment/get.rssrc/cmd/wiki/attachment/mod.rssrc/cmd/wiki/count.rssrc/cmd/wiki/mod.rssrc/cmd/wiki/shared_file/link.rssrc/cmd/wiki/shared_file/list.rssrc/cmd/wiki/shared_file/mod.rssrc/cmd/wiki/shared_file/unlink.rssrc/cmd/wiki/star/list.rssrc/cmd/wiki/star/mod.rssrc/cmd/wiki/tag/list.rssrc/cmd/wiki/tag/mod.rssrc/main.rswebsite/docs/commands.mdwebsite/i18n/ja/docusaurus-plugin-content-docs/current/commands.md
…dd API tests Addresses review comment: return type inconsistency between list/link/unlink
Checklist
mainwebsite/docs/,website/i18n/ja/,README.md)Summary
bl wiki count— GET /api/v2/wikis/countbl wiki tag list— GET /api/v2/wikis/tagsbl wiki star list <id>— GET /api/v2/wikis/{wikiId}/starsbl wiki attachment add/get/delete— POST/GET/DELETE /api/v2/wikis/{wikiId}/attachmentsbl wiki shared-file list/link/unlink— GET/POST/DELETE /api/v2/wikis/{wikiId}/sharedFilesReason for change
Implements the remaining wiki subcommands planned in #49.
Changes
src/api/wiki.rs: AddedWikiCount,WikiSharedFilestructs and 9 newBacklogClientmethodssrc/api/mod.rs: Added correspondingBacklogApitrait methods and implssrc/cmd/wiki/: New modulescount,tag,star,shared_file; extendedattachmentmodule withadd,get,deletesrc/main.rs: AddedWikiCommands::Count/Tag/Star/SharedFile, extendedWikiAttachmentCommandswebsite/docs/commands.mdand JA equivalent: Added command docs and updated coverage tableNotes
Closes #49