feat: Add suspend/active user to cli#1422
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1422 +/- ##
==========================================
+ Coverage 67.07% 67.19% +0.12%
==========================================
Files 287 292 +5
Lines 19307 19612 +305
Branches 241 258 +17
==========================================
+ Hits 12950 13179 +229
- Misses 5016 5079 +63
- Partials 1341 1354 +13
Continue to review full report at Codecov.
|
|
|
||
| func (c *Client) userByIdentifier(ctx context.Context, ident string) (User, error) { | ||
| // UserByIdentifier returns a user for the username or uuid provided. | ||
| func (c *Client) UserByIdentifier(ctx context.Context, ident string) (User, error) { |
There was a problem hiding this comment.
Should we change User to be this instead of creating a new handler? It seems like User is just wrong right now.
There was a problem hiding this comment.
For all /users/<param> routes, we could create a generic that accepts a string or UUID. Right now it's incorrectly stated that they require UUIDs.
There was a problem hiding this comment.
I tried to make a generic, but unfortunately you cannot make struct methods generics 😢
There was a problem hiding this comment.
I thought about changing User, then you have to do client.User(id.String()) because it can't take a uuid.
I can't even make it take a Stringer because string isn't a Stringer. I hit this trying to make it "generic" in some way, and kept falling short.
There was a problem hiding this comment.
I guess I'd rather just keep User with the UUID and add UserByUsername then. UserByIdentifier tells us very little about what the identifier is.
|
Thoughts on outdenting it to My thinking is |
I'm cool with that. I had that originally, but don't have a strong opinion either way. |
|
|
||
| func (c *Client) userByIdentifier(ctx context.Context, ident string) (User, error) { | ||
| // UserByIdentifier returns a user for the username or uuid provided. | ||
| func (c *Client) UserByIdentifier(ctx context.Context, ident string) (User, error) { |
There was a problem hiding this comment.
I guess I'd rather just keep User with the UUID and add UserByUsername then. UserByIdentifier tells us very little about what the identifier is.
|
The annoying thing about If we have The appropriate code would be to try and parse the arg as a uuid, and if it fails, try as a username. But the api already does that, and it seems excessive to check locally as well. So having a function accept either is useful when just passing input along. |
|
Fair enough. I don't think doing |
The nasty thing would be to accept an I'll use |
|
This is werid now |
|
We could just make |
kylecarbs
left a comment
There was a problem hiding this comment.
LGTM. User changes are really nice!
|
|
||
| // Prompt to confirm the action | ||
| _, err = cliui.Prompt(cmd, cliui.PromptOptions{ | ||
| Text: fmt.Sprintf("Are you sure you want to %s this user?", verb), |
There was a problem hiding this comment.
The use of this verb is really nice here!
* feat: Add suspend/active user to cli * UserID is now a string and allows for username too
Uh oh!
There was an error while loading. Please reload this page.