Skip to content

fix: Show the users workspaces by default on coder ls #3947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions cli/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]coders

func list() *cobra.Command {
var (
columns []string
searchQuery string
me bool
all bool
columns []string
defaultQuery = "owner:me"
searchQuery string
)
cmd := &cobra.Command{
Annotations: workspaceCommand,
Expand All @@ -76,12 +77,8 @@ func list() *cobra.Command {
filter := codersdk.WorkspaceFilter{
FilterQuery: searchQuery,
}
if me {
myUser, err := client.User(cmd.Context(), codersdk.Me)
if err != nil {
return err
}
filter.Owner = myUser.Username
if all && searchQuery == defaultQuery {
filter.FilterQuery = ""
}
workspaces, err := client.Workspaces(cmd.Context(), filter)
if err != nil {
Expand Down Expand Up @@ -118,9 +115,10 @@ func list() *cobra.Command {
return err
},
}
cmd.Flags().BoolVarP(&all, "all", "a", false,
"Specifies whether all workspaces will be listed or not.")
cmd.Flags().StringArrayVarP(&columns, "column", "c", nil,
"Specify a column to filter in the table.")
cmd.Flags().StringVar(&searchQuery, "search", "", "Search for a workspace with a query.")
cmd.Flags().BoolVar(&me, "me", false, "Only show workspaces owned by the current user.")
cmd.Flags().StringVar(&searchQuery, "search", defaultQuery, "Search for a workspace with a query.")
return cmd
}