feat: add bl user add/update/delete, recently-viewed-projects/wikis, and star commands#61
feat: add bl user add/update/delete, recently-viewed-projects/wikis, and star commands#61
Conversation
…and star commands Implements GitHub issue #53: - POST /api/v2/users → bl user add - PATCH /api/v2/users/{userId} → bl user update (requires at least one field) - DELETE /api/v2/users/{userId} → bl user delete - GET /api/v2/users/myself/recentlyViewedProjects → bl user recently-viewed-projects - GET /api/v2/users/myself/recentlyViewedWikis → bl user recently-viewed-wikis - GET /api/v2/users/{userId}/stars → bl user star list - GET /api/v2/users/{userId}/stars/count → bl user star count Adds BacklogApi trait methods and updates all existing MockApi implementations.
📝 WalkthroughWalkthroughThis PR extends the Backlog API client with user management capabilities and recently-viewed data retrieval. It introduces seven new BacklogApi trait methods (add_user, update_user, delete_user, get_recently_viewed_projects, get_recently_viewed_wikis, get_user_stars, count_user_stars), corresponding data structures, concrete implementations in BacklogClient, and CLI command handlers for user operations. Mock implementations are added across existing test modules. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes The PR introduces substantive new logic in multiple user command modules with parameter validation, multi-mode output, and error handling patterns. While many test files receive identical mechanical updates (7 stub methods), the spread across 30+ files and the density of new public types and command routing require careful verification of command semantics, API parameter mapping, and integration correctness. 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 a suite of new bl user subcommands (CRUD + “recently viewed” + stars) by extending the Backlog API layer and wiring new clap subcommands through main.rs, with corresponding command implementations and test updates across the repo to satisfy the expanded BacklogApi trait.
Changes:
- Extend
BacklogApi/BacklogClientwith user CRUD, recently-viewed projects/wikis, and stars endpoints. - Add new
cmd::user::*subcommands (add,update,delete,recently-viewed-projects,recently-viewed-wikis,star list/count) and wire them intosrc/main.rs. - Update many existing command tests’
MockApiimplementations to include the new trait methods.
Reviewed changes
Copilot reviewed 52 out of 52 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Adds clap subcommands and dispatch for new bl user commands (including nested user star). |
| src/api/user.rs | Adds response structs + BacklogClient methods for new user endpoints. |
| src/api/mod.rs | Extends BacklogApi trait and implements new methods for BacklogClient. |
| src/cmd/user/mod.rs | Registers new user subcommand modules and re-exports. |
| src/cmd/user/add.rs | Implements bl user add command + unit tests with MockApi. |
| src/cmd/user/update.rs | Implements bl user update command + unit tests with MockApi. |
| src/cmd/user/delete.rs | Implements bl user delete command + unit tests with MockApi. |
| src/cmd/user/recently_viewed_projects.rs | Implements bl user recently-viewed-projects + args validation/tests. |
| src/cmd/user/recently_viewed_wikis.rs | Implements bl user recently-viewed-wikis + args validation/tests. |
| src/cmd/user/star.rs | Implements bl user star list/count + unit tests with MockApi. |
| src/cmd/user/show.rs | Exposes shared user text formatting and updates MockApi in tests. |
| src/cmd/user/list.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/user/activities.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/user/recently_viewed.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/auth.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/space/activities.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/space/disk_usage.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/space/notification.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/space/show.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/project/activities.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/project/category.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/project/disk_usage.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/project/issue_type.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/project/list.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/project/show.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/project/status.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/project/user.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/project/version.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/team/list.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/team/show.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/wiki/create.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/wiki/update.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/wiki/delete.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/wiki/list.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/wiki/show.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/wiki/history.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/wiki/attachment/list.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/create.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/update.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/delete.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/list.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/show.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/count.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/attachment/list.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/comment/add.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/comment/update.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/comment/delete.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/issue/comment/list.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/notification/list.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/notification/count.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/notification/read.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
| src/cmd/notification/reset_unread.rs | Updates MockApi in tests to satisfy expanded BacklogApi. |
Comments suppressed due to low confidence (1)
src/cmd/user/show.rs:40
format_user_textwas made fullypub(andcmd::user::showwas made a public module) to share formatting with sibling subcommands. To avoid expanding the crate's public API surface and to stay consistent with other cmd modules, consider keepingshowprivate and changing this function topub(super)/pub(crate)(or re-exporting apub(crate)helper fromcmd::user::mod).
You can also share your feedback on Copilot code review. Take the survey.
| pub struct Star { | ||
| pub id: u64, | ||
| pub comment: Option<String>, | ||
| pub url: String, | ||
| pub title: String, | ||
| pub presenter: User, | ||
| pub created: String, |
| pub fn add_user(&self, params: &[(String, String)]) -> Result<User> { | ||
| let value = self.post_form("/users", params)?; | ||
| deserialize(value, "user response") | ||
| } | ||
|
|
||
| pub fn update_user(&self, user_id: u64, params: &[(String, String)]) -> Result<User> { | ||
| let value = self.patch_form(&format!("/users/{user_id}"), params)?; | ||
| deserialize(value, "user response") | ||
| } | ||
|
|
||
| pub fn delete_user(&self, user_id: u64) -> Result<User> { | ||
| let value = self.delete_req(&format!("/users/{user_id}"))?; | ||
| deserialize(value, "user response") | ||
| } |
| /// Add a new user | ||
| Add { | ||
| /// User ID (login name) | ||
| #[arg(long)] | ||
| user_id: String, |
| /// Password | ||
| #[arg(long)] | ||
| password: String, | ||
| /// Display name |
| impl UserAddArgs { | ||
| pub fn new( | ||
| user_id: String, | ||
| password: String, | ||
| name: String, | ||
| mail_address: String, | ||
| role_type: u8, | ||
| json: bool, | ||
| ) -> Self { |
| pub fn try_new( | ||
| user_id: u64, | ||
| name: Option<String>, | ||
| password: Option<String>, | ||
| mail_address: Option<String>, | ||
| role_type: Option<u8>, | ||
| json: bool, | ||
| ) -> anyhow::Result<Self> { | ||
| if name.is_none() && password.is_none() && mail_address.is_none() && role_type.is_none() { | ||
| anyhow::bail!( | ||
| "at least one of --name, --password, --mail-address, or --role-type must be specified" | ||
| ); |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
src/cmd/user/recently_viewed_projects.rs (1)
41-47: Add a regression test for forwarded query parameters.Current tests validate success/error, but not that
count/offset/orderare actually passed through.✅ Suggested test-oriented patch
struct MockApi { items: Option<Vec<RecentlyViewedProject>>, + captured: std::cell::RefCell<Vec<(String, String)>>, } @@ - fn get_recently_viewed_projects( - &self, - _: &[(String, String)], - ) -> anyhow::Result<Vec<RecentlyViewedProject>> { + fn get_recently_viewed_projects( + &self, + params: &[(String, String)], + ) -> anyhow::Result<Vec<RecentlyViewedProject>> { + *self.captured.borrow_mut() = params.to_vec(); self.items.clone().ok_or_else(|| anyhow!("no items")) } @@ let api = MockApi { items: Some(vec![sample_item()]), + captured: std::cell::RefCell::new(vec![]), }; @@ let api = MockApi { items: Some(vec![sample_item()]), + captured: std::cell::RefCell::new(vec![]), }; @@ - let api = MockApi { items: None }; + let api = MockApi { + items: None, + captured: std::cell::RefCell::new(vec![]), + }; @@ + #[test] + fn recently_viewed_projects_with_builds_query_params() { + let api = MockApi { + items: Some(vec![sample_item()]), + captured: std::cell::RefCell::new(vec![]), + }; + let args = UserRecentlyViewedProjectsArgs::try_new( + false, + 50, + 10, + Some("asc".to_string()), + ) + .unwrap(); + recently_viewed_projects_with(&args, &api).unwrap(); + let params = api.captured.borrow(); + assert!(params.iter().any(|(k, v)| k == "count" && v == "50")); + assert!(params.iter().any(|(k, v)| k == "offset" && v == "10")); + assert!(params.iter().any(|(k, v)| k == "order" && v == "asc")); + }Also applies to: 346-401
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cmd/user/recently_viewed_projects.rs` around lines 41 - 47, Add a regression test that verifies the query parameters are forwarded to the API when calling get_recently_viewed_projects: create a test that constructs args with specific count/offset and an order, invoke the command path that builds the params (the code that pushes ("count", args.count), ("offset", args.offset), and ("order", args.order) into params) and use a mock HTTP server or request inspector for get_recently_viewed_projects to assert the outgoing request's query string contains the expected count, offset and order values; ensure you cover both Some(order) and None(order) cases so the code path that conditionally pushes ("order", ...) is exercised.src/cmd/user/recently_viewed_wikis.rs (1)
37-47: Add a query-param capture test forrecently_viewed_wikis_with.Please add a capture-style test asserting that
count,offset, and optionalorderare sent with expected names and values. This command is query-shape-sensitive and currently only tests success/error paths.Also applies to: 345-400
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cmd/user/recently_viewed_wikis.rs` around lines 37 - 47, Add a capture-style unit test for recently_viewed_wikis_with that verifies the query parameters sent to api.get_recently_viewed_wikis: assert the captured params vector contains entries for "count" with args.count.to_string(), "offset" with args.offset.to_string(), and when args.order.is_some() also contains "order" with the provided value; implement the test by mocking BacklogApi.get_recently_viewed_wikis to capture its &Vec<(String,String)> argument and assert names/values, and add an additional variant covering None for order; apply the same pattern for the other related tests referenced around lines 345-400 that exercise query-shape sensitivity.src/cmd/user/update.rs (1)
46-60: Add a param-capture unit test forupdate_withform keys.Current tests verify success/error, but not that keys are exactly
name,password,mailAddress, androleType. A capture-style test would prevent subtle request-shape regressions.Also applies to: 349-392
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cmd/user/update.rs` around lines 46 - 60, The tests lack a capture-style unit test ensuring update_with builds params with exact form keys; add a unit test that calls update_with with a mocked BacklogApi implementation (or a test double) that captures the params passed into update_user and asserts the keys are exactly "name", "password", "mailAddress", and "roleType" (and present only when the corresponding UserUpdateArgs fields are Some), using the update_with function and UserUpdateArgs to exercise each optional field; locate the call site by referencing update_with and the api.update_user(...) invocation to capture the Vec<(String,String)> and assert keys and presence/absence to prevent request-shape regressions.src/api/user.rs (1)
114-127: Add endpoint-level tests for the new user API methods.The newly added methods (
add_user,update_user,delete_user,get_recently_viewed_projects,get_recently_viewed_wikis,get_user_stars,count_user_stars) are not covered in this module’shttpmocktests yet. Please add happy-path + API-error tests to lock down path/query/form mapping and response deserialization.As per coding guidelines:
Never call BacklogClient::from_config() in tests — it requires real credentials on disk. Use httpmock for api/ layer tests and MockApi struct for cmd/ layer tests.Also applies to: 146-170
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/user.rs` around lines 114 - 127, Add httpmock-based endpoint tests covering happy-path and API-error cases for the new API methods so their request mapping and deserialization are locked down: write tests for add_user, update_user, delete_user, get_recently_viewed_projects, get_recently_viewed_wikis, get_user_stars, and count_user_stars using httpmock server to stub expected POST/PATCH/DELETE/GET endpoints and responses, asserting correct form/query payloads and successful deserialize behavior as well as error-path responses; do not call BacklogClient::from_config() in tests—construct the client pointed at the httpmock server or use the existing test helper that injects base URL—and for cmd/ layer tests use MockApi instead of real network calls.
🤖 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/user/update.rs`:
- Around line 17-38: In UserUpdateArgs::try_new validate the optional role_type
early: if role_type.is_some() check the inner u8 is in the allowed range 1..=6
and otherwise return an error (use anyhow::bail with a clear message); keep the
existing presence check for all fields and construct Self only when role_type is
either None or within 1–6. This touches the try_new function and the role_type
parameter validation.
---
Nitpick comments:
In `@src/api/user.rs`:
- Around line 114-127: Add httpmock-based endpoint tests covering happy-path and
API-error cases for the new API methods so their request mapping and
deserialization are locked down: write tests for add_user, update_user,
delete_user, get_recently_viewed_projects, get_recently_viewed_wikis,
get_user_stars, and count_user_stars using httpmock server to stub expected
POST/PATCH/DELETE/GET endpoints and responses, asserting correct form/query
payloads and successful deserialize behavior as well as error-path responses; do
not call BacklogClient::from_config() in tests—construct the client pointed at
the httpmock server or use the existing test helper that injects base URL—and
for cmd/ layer tests use MockApi instead of real network calls.
In `@src/cmd/user/recently_viewed_projects.rs`:
- Around line 41-47: Add a regression test that verifies the query parameters
are forwarded to the API when calling get_recently_viewed_projects: create a
test that constructs args with specific count/offset and an order, invoke the
command path that builds the params (the code that pushes ("count", args.count),
("offset", args.offset), and ("order", args.order) into params) and use a mock
HTTP server or request inspector for get_recently_viewed_projects to assert the
outgoing request's query string contains the expected count, offset and order
values; ensure you cover both Some(order) and None(order) cases so the code path
that conditionally pushes ("order", ...) is exercised.
In `@src/cmd/user/recently_viewed_wikis.rs`:
- Around line 37-47: Add a capture-style unit test for
recently_viewed_wikis_with that verifies the query parameters sent to
api.get_recently_viewed_wikis: assert the captured params vector contains
entries for "count" with args.count.to_string(), "offset" with
args.offset.to_string(), and when args.order.is_some() also contains "order"
with the provided value; implement the test by mocking
BacklogApi.get_recently_viewed_wikis to capture its &Vec<(String,String)>
argument and assert names/values, and add an additional variant covering None
for order; apply the same pattern for the other related tests referenced around
lines 345-400 that exercise query-shape sensitivity.
In `@src/cmd/user/update.rs`:
- Around line 46-60: The tests lack a capture-style unit test ensuring
update_with builds params with exact form keys; add a unit test that calls
update_with with a mocked BacklogApi implementation (or a test double) that
captures the params passed into update_user and asserts the keys are exactly
"name", "password", "mailAddress", and "roleType" (and present only when the
corresponding UserUpdateArgs fields are Some), using the update_with function
and UserUpdateArgs to exercise each optional field; locate the call site by
referencing update_with and the api.update_user(...) invocation to capture the
Vec<(String,String)> and assert keys and presence/absence to prevent
request-shape regressions.
🪄 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: 94c12b79-fae9-471b-8273-21e8967a68e4
📒 Files selected for processing (52)
src/api/mod.rssrc/api/user.rssrc/cmd/auth.rssrc/cmd/issue/attachment/list.rssrc/cmd/issue/comment/add.rssrc/cmd/issue/comment/delete.rssrc/cmd/issue/comment/list.rssrc/cmd/issue/comment/update.rssrc/cmd/issue/count.rssrc/cmd/issue/create.rssrc/cmd/issue/delete.rssrc/cmd/issue/list.rssrc/cmd/issue/show.rssrc/cmd/issue/update.rssrc/cmd/notification/count.rssrc/cmd/notification/list.rssrc/cmd/notification/read.rssrc/cmd/notification/reset_unread.rssrc/cmd/project/activities.rssrc/cmd/project/category.rssrc/cmd/project/disk_usage.rssrc/cmd/project/issue_type.rssrc/cmd/project/list.rssrc/cmd/project/show.rssrc/cmd/project/status.rssrc/cmd/project/user.rssrc/cmd/project/version.rssrc/cmd/space/activities.rssrc/cmd/space/disk_usage.rssrc/cmd/space/notification.rssrc/cmd/space/show.rssrc/cmd/team/list.rssrc/cmd/team/show.rssrc/cmd/user/activities.rssrc/cmd/user/add.rssrc/cmd/user/delete.rssrc/cmd/user/list.rssrc/cmd/user/mod.rssrc/cmd/user/recently_viewed.rssrc/cmd/user/recently_viewed_projects.rssrc/cmd/user/recently_viewed_wikis.rssrc/cmd/user/show.rssrc/cmd/user/star.rssrc/cmd/user/update.rssrc/cmd/wiki/attachment/list.rssrc/cmd/wiki/create.rssrc/cmd/wiki/delete.rssrc/cmd/wiki/history.rssrc/cmd/wiki/list.rssrc/cmd/wiki/show.rssrc/cmd/wiki/update.rssrc/main.rs
| pub fn try_new( | ||
| user_id: u64, | ||
| name: Option<String>, | ||
| password: Option<String>, | ||
| mail_address: Option<String>, | ||
| role_type: Option<u8>, | ||
| json: bool, | ||
| ) -> anyhow::Result<Self> { | ||
| if name.is_none() && password.is_none() && mail_address.is_none() && role_type.is_none() { | ||
| anyhow::bail!( | ||
| "at least one of --name, --password, --mail-address, or --role-type must be specified" | ||
| ); | ||
| } | ||
| Ok(Self { | ||
| user_id, | ||
| name, | ||
| password, | ||
| mail_address, | ||
| role_type, | ||
| json, | ||
| }) | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Backlog API "Update User" roleType allowed values for PATCH /api/v2/users/:userId
💡 Result:
For Backlog API v2 PATCH /api/v2/users/:userId (“Update User”), the roleType field (Number) allows these values: Administrator (1), Normal User (2), Reporter (3), Viewer (4), Guest Reporter (5), Guest Viewer (6). [1]
Validate --role-type range in UserUpdateArgs::try_new.
try_new accepts any u8, but the API only allows values 1–6 (Administrator through Guest Viewer). Reject out-of-range values early in the domain-validation layer:
Suggested fix
) -> anyhow::Result<Self> {
if name.is_none() && password.is_none() && mail_address.is_none() && role_type.is_none() {
anyhow::bail!(
"at least one of --name, --password, --mail-address, or --role-type must be specified"
);
}
+ if let Some(role) = role_type
+ && !(1..=6).contains(&role)
+ {
+ anyhow::bail!("--role-type must be between 1 and 6");
+ }
Ok(Self {
user_id,
name,
password,
mail_address,
role_type,
json,
})
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| pub fn try_new( | |
| user_id: u64, | |
| name: Option<String>, | |
| password: Option<String>, | |
| mail_address: Option<String>, | |
| role_type: Option<u8>, | |
| json: bool, | |
| ) -> anyhow::Result<Self> { | |
| if name.is_none() && password.is_none() && mail_address.is_none() && role_type.is_none() { | |
| anyhow::bail!( | |
| "at least one of --name, --password, --mail-address, or --role-type must be specified" | |
| ); | |
| } | |
| Ok(Self { | |
| user_id, | |
| name, | |
| password, | |
| mail_address, | |
| role_type, | |
| json, | |
| }) | |
| } | |
| pub fn try_new( | |
| user_id: u64, | |
| name: Option<String>, | |
| password: Option<String>, | |
| mail_address: Option<String>, | |
| role_type: Option<u8>, | |
| json: bool, | |
| ) -> anyhow::Result<Self> { | |
| if name.is_none() && password.is_none() && mail_address.is_none() && role_type.is_none() { | |
| anyhow::bail!( | |
| "at least one of --name, --password, --mail-address, or --role-type must be specified" | |
| ); | |
| } | |
| if let Some(role) = role_type | |
| && !(1..=6).contains(&role) | |
| { | |
| anyhow::bail!("--role-type must be between 1 and 6"); | |
| } | |
| Ok(Self { | |
| user_id, | |
| name, | |
| password, | |
| mail_address, | |
| role_type, | |
| json, | |
| }) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/cmd/user/update.rs` around lines 17 - 38, In UserUpdateArgs::try_new
validate the optional role_type early: if role_type.is_some() check the inner u8
is in the allowed range 1..=6 and otherwise return an error (use anyhow::bail
with a clear message); keep the existing presence check for all fields and
construct Self only when role_type is either None or within 1–6. This touches
the try_new function and the role_type parameter validation.
|
Closing due to large conflicts with main. Will reimplement from scratch on current main. |
Checklist
mainSummary
bl user add,bl user update,bl user deletebl user recently-viewed-projects,bl user recently-viewed-wikisbl user star list <id>,bl user star count <id>Reason for change
Closes #53
Changes
src/api/user.rs—RecentlyViewedProject,RecentlyViewedWiki,Star,StarCountstructs + 7 new methodssrc/api/mod.rs— trait + implsrc/cmd/user/add.rs,update.rs,delete.rs,recently_viewed_projects.rs,recently_viewed_wikis.rs,star.rssrc/main.rs— clap wiringNotes
bl user updaterequires at least one optional field viatry_newvalidation.