Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2bc48ee

Browse files
committed
feat: addshared-with-me flag to list command
1 parent42dd544 commit2bc48ee

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎cli/list.go‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (r *RootCmd) list() *serpent.Command {
9595
),
9696
cliui.JSONFormat(),
9797
)
98+
sharedWithMebool
9899
)
99100
cmd:=&serpent.Command{
100101
Annotations:workspaceCommand,
@@ -104,13 +105,36 @@ func (r *RootCmd) list() *serpent.Command {
104105
Middleware:serpent.Chain(
105106
serpent.RequireNArgs(0),
106107
),
108+
Options: serpent.OptionSet{
109+
{
110+
Name:"shared-with-me",
111+
Description:"Show workspaces shared with you.",
112+
Flag:"shared-with-me",
113+
Value:serpent.BoolOf(&sharedWithMe),
114+
Hidden:true,
115+
},
116+
},
107117
Handler:func(inv*serpent.Invocation)error {
108118
client,err:=r.InitClient(inv)
109119
iferr!=nil {
110120
returnerr
111121
}
112122

113-
res,err:=QueryConvertWorkspaces(inv.Context(),client,filter.Filter(),WorkspaceListRowFromWorkspace)
123+
workspaceFilter:=filter.Filter()
124+
ifsharedWithMe {
125+
user,err:=client.User(inv.Context(),codersdk.Me)
126+
iferr!=nil {
127+
returnxerrors.Errorf("fetch current user: %w",err)
128+
}
129+
workspaceFilter.SharedWithUser=user.ID.String()
130+
131+
// Unset the default query that conflicts with the --shared-with-me flag
132+
ifworkspaceFilter.FilterQuery=="owner:me" {
133+
workspaceFilter.FilterQuery=""
134+
}
135+
}
136+
137+
res,err:=QueryConvertWorkspaces(inv.Context(),client,workspaceFilter,WorkspaceListRowFromWorkspace)
114138
iferr!=nil {
115139
returnerr
116140
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp