Skip to content

Commit a5f77d0

Browse files
committed
add github user id filter to the users list cli command
1 parent 449c595 commit a5f77d0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

cli/userlist.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func (r *RootCmd) userList() *serpent.Command {
1919
cliui.JSONFormat(),
2020
)
2121
client := new(codersdk.Client)
22+
var githubUserID int64
2223

2324
cmd := &serpent.Command{
2425
Use: "list",
@@ -27,8 +28,23 @@ func (r *RootCmd) userList() *serpent.Command {
2728
serpent.RequireNArgs(0),
2829
r.InitClient(client),
2930
),
31+
Options: serpent.OptionSet{
32+
{
33+
Name: "github-user-id",
34+
Description: "Filter users by their GitHub user ID.",
35+
Default: "",
36+
Flag: "github-user-id",
37+
Required: false,
38+
Value: serpent.Int64Of(&githubUserID),
39+
},
40+
},
3041
Handler: func(inv *serpent.Invocation) error {
31-
res, err := client.Users(inv.Context(), codersdk.UsersRequest{})
42+
req := codersdk.UsersRequest{}
43+
if githubUserID != 0 {
44+
req.Search = fmt.Sprintf("github_com_user_id:%d", githubUserID)
45+
}
46+
47+
res, err := client.Users(inv.Context(), req)
3248
if err != nil {
3349
return err
3450
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy