Skip to content

feat: implement user deletion via pullbasectl CLI#2

Merged
hacktivist123 merged 1 commit into
pullbase:mainfrom
JohnAkindipe:feat/user-deletion-cli
May 27, 2026
Merged

feat: implement user deletion via pullbasectl CLI#2
hacktivist123 merged 1 commit into
pullbase:mainfrom
JohnAkindipe:feat/user-deletion-cli

Conversation

@JohnAkindipe
Copy link
Copy Markdown
Contributor

@JohnAkindipe JohnAkindipe commented May 27, 2026

feat: implement user deletion via pullbasectl

Summary

Adds pullbasectl users delete — a CLI subcommand for deleting a user account.
This was previously noted in the documentation as a planned capability (the web UI and REST API already supported deletion; the CLI did not).

A companion docs PR will be opened at pullbase/docs that updates the CLI reference and workflow guide to reflect this change.

Changes

server/cmd/pullbasectl/users.go

  • Added runUsersDelete — parses --user-id and --delete-acct-username flags, validates inputs, sends a DELETE /api/v1/users/{userID} request with the confirmation username in the request body, and prints a success message on receiving a 204 No Content response.

server/cmd/pullbasectl/root.go

  • Added newUsersDeleteCommand() and registered it under the users subcommand group alongside the existing list and create commands.

server/cmd/pullbasectl/tokens_commands_test.go

  • Added TestRunUsersDelete — spins up an httptest server, verifies the correct HTTP method, Authorization header, path value, and confirm_username body field, and asserts the success output.

Usage

pullbasectl users delete \
  --server-url http://localhost:8080 \
  --admin-token $ADMIN_JWT \
  --user-id 7 \
  --delete-acct-username "SomeAccount123"

Flags

Flag Required Description
--user-id Yes Numeric ID of the user to delete
--delete-acct-username Yes Username of the account — used as confirmation
--server-url Yes Pullbase server base URL

Testing

cd server && go test -tags=test -count=1 -run TestRunUsersDelete ./cmd/pullbasectl/

All existing tests continue to pass:

cd server && go test -tags=test ./...

Summary by CodeRabbit

  • New Features

    • Added a new users delete subcommand to the CLI that enables user account deletion with built-in confirmation validation and authentication checks.
  • Tests

    • Added comprehensive test coverage for the delete user command, including API endpoint validation, authentication headers, and credential handling verification.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66107997-78b1-476e-8cd3-335018c28bb6

📥 Commits

Reviewing files that changed from the base of the PR and between fdb4c2a and af246ed.

📒 Files selected for processing (3)
  • server/cmd/pullbasectl/root.go
  • server/cmd/pullbasectl/tokens_commands_test.go
  • server/cmd/pullbasectl/users.go

📝 Walkthrough

Walkthrough

This PR introduces a new users delete subcommand to the Pullbase CLI. The command accepts a user ID and a confirmation username, validates the inputs, sends an authenticated HTTP DELETE request to the API, and prints a success message upon 204 response.

Changes

Delete user command

Layer / File(s) Summary
Command definition and registration
server/cmd/pullbasectl/root.go
The users command registers the new delete subcommand; newUsersDeleteCommand() defines a cobra command that dispatches to runUsersDelete with a help handler.
Delete implementation
server/cmd/pullbasectl/users.go
runUsersDelete validates required flags (server URL, positive user ID, non-empty confirmation username matching bootstrapUsernamePattern), resolves admin credentials, sends an authenticated DELETE request with the confirmation username in the payload, requires HTTP 204, and prints a success message.
Delete user test
server/cmd/pullbasectl/tokens_commands_test.go
Test mocks a DELETE endpoint to verify the HTTP method, authorization header, path parameter extraction, request body structure, and validates the captured success output text.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 A delete command hops into view,
With validation through and through,
Confirmation names confirm the way,
HTTP 204 says "okay!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: implementing user deletion functionality via the pullbasectl CLI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="Running error: context loading failed: no go files to analyze: running go mod tidy may solve the problem"


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.

@hacktivist123 hacktivist123 merged commit 6b3637d into pullbase:main May 27, 2026
1 of 2 checks passed
@JohnAkindipe JohnAkindipe deleted the feat/user-deletion-cli branch May 29, 2026 21:09
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.

2 participants