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
3 changed files with 12 additions and 5 deletions

View File

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

View File

@ -12,9 +12,9 @@ OPTIONS:
Specifies whether all workspaces will be listed or not. 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) -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, Columns to display in table output. Available columns: favorite,
template, status, healthy, last built, current version, outdated, workspace, template, status, healthy, last built, current version,
starts at, starts next, stops after, stops next, daily cost. outdated, starts at, starts next, stops after, stops next, daily cost.
-o, --output string (default: table) -o, --output string (default: table)
Output format. Available formats: table, json. 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> | | Type | <code>string-array</code> |
| Default | <code>workspace,template,status,healthy,last built,current version,outdated,starts at,stops after</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 ### -o, --output