Refactor: update officers to use new huh logic#166
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the CLI’s officers commands to follow the newer “huh-based form + shared HTTP client helper” approach (from #160), and applies the same request helper to announcements to reduce duplicated request/response handling.
Changes:
- Added a reusable
client.SendRequestAndReadResponsehelper for CLI HTTP calls (optionally with OAuth). - Refactored officers
get/post/put/deleteto use the shared client helper and simplified command structure. - Updated announcements commands to use the shared client helper; regenerated/updated API docs + dbmodels for
CreatePositionParams, and added server-side logging on announcement create failures.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/cli/client/client.go | New shared helper to send HTTP requests and read responses (with optional OAuth). |
| internal/cli/officers/root.go | New officers command root wiring subcommands. |
| internal/cli/officers/get.go | Uses shared client helper for GET (pretty-prints JSON). |
| internal/cli/officers/post.go | Uses huh form + shared client helper for POST. |
| internal/cli/officers/put.go | Fetches existing officer then uses huh form + shared client helper for PUT. |
| internal/cli/officers/delete.go | Uses shared client helper for DELETE. |
| internal/cli/officers/officers.go | Removes old interactive menu/flags implementation. |
| internal/cli/announcements/get.go | Uses shared client helper for GET. |
| internal/cli/announcements/post.go | Uses shared client helper for POST. |
| internal/cli/announcements/put.go | Uses shared client helper for GET+PUT update flow. |
| internal/cli/announcements/delete.go | Uses shared client helper for DELETE. |
| internal/cli/oauth/request_with_auth.go | Adds a clarifying doc comment. |
| internal/api/handlers/announcement.go | Adds server-side logging when create fails. |
| internal/api/dbmodels/board.sql.go | Regenerates/updates CreatePosition insert + params (adds full_name/title/team). |
| internal/api/docs/swagger.yaml | Updates API docs for CreatePositionParams fields. |
| internal/api/docs/swagger.json | Updates generated swagger JSON accordingly. |
| internal/api/docs/docs.go | Updates embedded swagger template accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f6df77d to
d6165a3
Compare
|
@GaballaGit just resolved all the issues copilot found. This PR is ready now |
d6165a3 to
1c3c3d3
Compare
GaballaGit
left a comment
There was a problem hiding this comment.
@TheJolman When using ./acmcsuf-cli officers post:
Input: All fields have been inputted with strings
Output: Error: failed to marshal JSON: <nil>
d8524de to
df98c02
Compare
good catch, I was misusing cobra's error handling function. Fixed |
Created a reusable function in a
clientpackage and also applied it to announcements stuff since I noticed the code was nearly the exact same.Related to #160
Note: The reason this modifies the dbmodels package is because sqlc didn't get rerun when the queries were last modified.