feat(cli): show workspace favorite status in list output (#11878)

This commit is contained in:
Cian Johnston 2024-01-29 14:14:12 +00:00 committed by GitHub
parent 9abf6ec170
commit eeef56a655
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 5 deletions

View File

@ -22,6 +22,7 @@ type workspaceListRow struct {
codersdk.Workspace `table:"-"`
// For table format:
Favorite bool `json:"-" table:"favorite"`
WorkspaceName string `json:"-" table:"workspace,default_sort"`
Template string `json:"-" table:"template"`
Status string `json:"-" table:"status"`
@ -46,9 +47,15 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace)
if status == "Starting" || status == "Started" {
healthy = strconv.FormatBool(workspace.Health.Healthy)
}
favIco := " "
if workspace.Favorite {
favIco = "★"
}
workspaceName := favIco + " " + workspace.OwnerName + "/" + workspace.Name
return workspaceListRow{
Favorite: workspace.Favorite,
Workspace: workspace,
WorkspaceName: workspace.OwnerName + "/" + workspace.Name,
WorkspaceName: workspaceName,
Template: workspace.TemplateName,
Status: status,
Healthy: healthy,

View File

@ -12,9 +12,9 @@ OPTIONS:
Specifies whether all workspaces will be listed or not.
-c, --column string-array (default: workspace,template,status,healthy,last built,current version,outdated,starts at,stops after)
Columns to display in table output. Available columns: workspace,
template, status, healthy, last built, current version, outdated,
starts at, starts next, stops after, stops next, daily cost.
Columns to display in table output. Available columns: favorite,
workspace, template, status, healthy, last built, current version,
outdated, starts at, starts next, stops after, stops next, daily cost.
-o, --output string (default: table)
Output format. Available formats: table, json.

2
docs/cli/list.md generated
View File

@ -31,7 +31,7 @@ Specifies whether all workspaces will be listed or not.
| Type | <code>string-array</code> |
| Default | <code>workspace,template,status,healthy,last built,current version,outdated,starts at,stops after</code> |
Columns to display in table output. Available columns: workspace, template, status, healthy, last built, current version, outdated, starts at, starts next, stops after, stops next, daily cost.
Columns to display in table output. Available columns: favorite, workspace, template, status, healthy, last built, current version, outdated, starts at, starts next, stops after, stops next, daily cost.
### -o, --output