From db1389dc554e089991ccb51c96c6a241cc6d6f55 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 29 Jan 2024 10:23:21 +0000 Subject: [PATCH 1/3] feat(cli): show workspace favorite status in list output --- cli/list.go | 3 +++ cli/testdata/coder_list_--help.golden | 8 ++++---- docs/cli/list.md | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cli/list.go b/cli/list.go index c88c9a7563581..952c905784c66 100644 --- a/cli/list.go +++ b/cli/list.go @@ -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"` @@ -47,6 +48,7 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) healthy = strconv.FormatBool(workspace.Health.Healthy) } return workspaceListRow{ + Favorite: workspace.Favorite, Workspace: workspace, WorkspaceName: workspace.OwnerName + "/" + workspace.Name, Template: workspace.TemplateName, @@ -70,6 +72,7 @@ func (r *RootCmd) list() *clibase.Cmd { cliui.TableFormat( []workspaceListRow{}, []string{ + "favorite", "workspace", "template", "status", diff --git a/cli/testdata/coder_list_--help.golden b/cli/testdata/coder_list_--help.golden index 615787278345d..0ae126d0d5725 100644 --- a/cli/testdata/coder_list_--help.golden +++ b/cli/testdata/coder_list_--help.golden @@ -11,10 +11,10 @@ OPTIONS: -a, --all bool 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. + -c, --column string-array (default: favorite,workspace,template,status,healthy,last built,current version,outdated,starts at,stops after) + 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. diff --git a/docs/cli/list.md b/docs/cli/list.md index 9681d32c1a5a4..17481f1f1ec74 100644 --- a/docs/cli/list.md +++ b/docs/cli/list.md @@ -26,12 +26,12 @@ Specifies whether all workspaces will be listed or not. ### -c, --column -| | | -| ------- | -------------------------------------------------------------------------------------------------------- | -| Type | string-array | -| Default | workspace,template,status,healthy,last built,current version,outdated,starts at,stops after | +| | | +| ------- | ----------------------------------------------------------------------------------------------------------------- | +| Type | string-array | +| Default | favorite,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 From 7c8eda5b35d4e62ed5d1efdb794a58d521f93e03 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 29 Jan 2024 13:52:10 +0000 Subject: [PATCH 2/3] remove favorite from default columns, prefix name with star if favorite --- cli/list.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/list.go b/cli/list.go index 952c905784c66..655427f2a15e1 100644 --- a/cli/list.go +++ b/cli/list.go @@ -47,10 +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, @@ -72,7 +77,6 @@ func (r *RootCmd) list() *clibase.Cmd { cliui.TableFormat( []workspaceListRow{}, []string{ - "favorite", "workspace", "template", "status", From 6d3f752a960b66a39f901fad1e7badd41f098398 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 29 Jan 2024 14:02:19 +0000 Subject: [PATCH 3/3] make gen --- cli/testdata/coder_list_--help.golden | 2 +- docs/cli/list.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/testdata/coder_list_--help.golden b/cli/testdata/coder_list_--help.golden index 0ae126d0d5725..adc1ae74a7d03 100644 --- a/cli/testdata/coder_list_--help.golden +++ b/cli/testdata/coder_list_--help.golden @@ -11,7 +11,7 @@ OPTIONS: -a, --all bool Specifies whether all workspaces will be listed or not. - -c, --column string-array (default: favorite,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: favorite, workspace, template, status, healthy, last built, current version, outdated, starts at, starts next, stops after, stops next, daily cost. diff --git a/docs/cli/list.md b/docs/cli/list.md index 17481f1f1ec74..6366898622859 100644 --- a/docs/cli/list.md +++ b/docs/cli/list.md @@ -26,10 +26,10 @@ Specifies whether all workspaces will be listed or not. ### -c, --column -| | | -| ------- | ----------------------------------------------------------------------------------------------------------------- | -| Type | string-array | -| Default | favorite,workspace,template,status,healthy,last built,current version,outdated,starts at,stops after | +| | | +| ------- | -------------------------------------------------------------------------------------------------------- | +| Type | string-array | +| Default | workspace,template,status,healthy,last built,current version,outdated,starts at,stops after | 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.