diff --git a/cli/cliui/table.go b/cli/cliui/table.go
index dde36da67d39b..478bbe2260f91 100644
--- a/cli/cliui/table.go
+++ b/cli/cliui/table.go
@@ -31,10 +31,33 @@ func Table() table.Writer {
// e.g. `[]any{someRow, TableSeparator, someRow}`
type TableSeparator struct{}
-// filterTableColumns returns configurations to hide columns
+// filterHeaders filters the headers to only include the columns
+// that are provided in the array. If the array is empty, all
+// headers are included.
+func filterHeaders(header table.Row, columns []string) table.Row {
+ if len(columns) == 0 {
+ return header
+ }
+
+ filteredHeaders := make(table.Row, len(columns))
+ for i, column := range columns {
+ column = strings.ReplaceAll(column, "_", " ")
+
+ for _, headerTextRaw := range header {
+ headerText, _ := headerTextRaw.(string)
+ if strings.EqualFold(column, headerText) {
+ filteredHeaders[i] = headerText
+ break
+ }
+ }
+ }
+ return filteredHeaders
+}
+
+// createColumnConfigs returns configuration to hide columns
// that are not provided in the array. If the array is empty,
// no filtering will occur!
-func filterTableColumns(header table.Row, columns []string) []table.ColumnConfig {
+func createColumnConfigs(header table.Row, columns []string) []table.ColumnConfig {
if len(columns) == 0 {
return nil
}
@@ -157,10 +180,13 @@ func DisplayTable(out any, sort string, filterColumns []string) (string, error)
func renderTable(out any, sort string, headers table.Row, filterColumns []string) (string, error) {
v := reflect.Indirect(reflect.ValueOf(out))
+ headers = filterHeaders(headers, filterColumns)
+ columnConfigs := createColumnConfigs(headers, filterColumns)
+
// Setup the table formatter.
tw := Table()
tw.AppendHeader(headers)
- tw.SetColumnConfigs(filterTableColumns(headers, filterColumns))
+ tw.SetColumnConfigs(columnConfigs)
if sort != "" {
tw.SortBy([]table.SortBy{{
Name: sort,
diff --git a/cli/provisionerjobs.go b/cli/provisionerjobs.go
index 17c5ad26fbaa7..c2b6b78658447 100644
--- a/cli/provisionerjobs.go
+++ b/cli/provisionerjobs.go
@@ -41,7 +41,7 @@ func (r *RootCmd) provisionerJobsList() *serpent.Command {
client = new(codersdk.Client)
orgContext = NewOrganizationContext()
formatter = cliui.NewOutputFormatter(
- cliui.TableFormat([]provisionerJobRow{}, []string{"created at", "id", "organization", "status", "type", "queue", "tags"}),
+ cliui.TableFormat([]provisionerJobRow{}, []string{"created at", "id", "type", "template display name", "status", "queue", "tags"}),
cliui.JSONFormat(),
)
status []string
diff --git a/cli/provisioners.go b/cli/provisioners.go
index 5dd3a703619e5..8f90a52589939 100644
--- a/cli/provisioners.go
+++ b/cli/provisioners.go
@@ -36,7 +36,7 @@ func (r *RootCmd) provisionerList() *serpent.Command {
client = new(codersdk.Client)
orgContext = NewOrganizationContext()
formatter = cliui.NewOutputFormatter(
- cliui.TableFormat([]provisionerDaemonRow{}, []string{"name", "organization", "status", "key name", "created at", "last seen at", "version", "tags"}),
+ cliui.TableFormat([]provisionerDaemonRow{}, []string{"created at", "last seen at", "key name", "name", "version", "status", "tags"}),
cliui.JSONFormat(),
)
limit int64
diff --git a/cli/testdata/coder_provisioner_jobs_list.golden b/cli/testdata/coder_provisioner_jobs_list.golden
index b41f4fc531316..d5cc728a9f73a 100644
--- a/cli/testdata/coder_provisioner_jobs_list.golden
+++ b/cli/testdata/coder_provisioner_jobs_list.golden
@@ -1,3 +1,3 @@
-ID CREATED AT STATUS TAGS TYPE ORGANIZATION QUEUE
-==========[version job ID]========== ====[timestamp]===== succeeded map[owner: scope:organization] template_version_import Coder
-======[workspace build job ID]====== ====[timestamp]===== succeeded map[owner: scope:organization] workspace_build Coder
+CREATED AT ID TYPE TEMPLATE DISPLAY NAME STATUS QUEUE TAGS
+====[timestamp]===== ==========[version job ID]========== template_version_import succeeded map[owner: scope:organization]
+====[timestamp]===== ======[workspace build job ID]====== workspace_build succeeded map[owner: scope:organization]
diff --git a/cli/testdata/coder_provisioner_jobs_list_--help.golden b/cli/testdata/coder_provisioner_jobs_list_--help.golden
index d6eb9a7681a07..7a72605f0c288 100644
--- a/cli/testdata/coder_provisioner_jobs_list_--help.golden
+++ b/cli/testdata/coder_provisioner_jobs_list_--help.golden
@@ -11,7 +11,7 @@ OPTIONS:
-O, --org string, $CODER_ORGANIZATION
Select which organization (uuid or name) to use.
- -c, --column [id|created at|started at|completed at|canceled at|error|error code|status|worker id|file id|tags|queue position|queue size|organization id|template version id|workspace build id|type|available workers|template version name|template id|template name|template display name|template icon|workspace id|workspace name|organization|queue] (default: created at,id,organization,status,type,queue,tags)
+ -c, --column [id|created at|started at|completed at|canceled at|error|error code|status|worker id|file id|tags|queue position|queue size|organization id|template version id|workspace build id|type|available workers|template version name|template id|template name|template display name|template icon|workspace id|workspace name|organization|queue] (default: created at,id,type,template display name,status,queue,tags)
Columns to display in table output.
-l, --limit int, $CODER_PROVISIONER_JOB_LIST_LIMIT (default: 50)
diff --git a/cli/testdata/coder_provisioner_list.golden b/cli/testdata/coder_provisioner_list.golden
index 056571547939e..64941eebf5b89 100644
--- a/cli/testdata/coder_provisioner_list.golden
+++ b/cli/testdata/coder_provisioner_list.golden
@@ -1,2 +1,2 @@
-CREATED AT LAST SEEN AT NAME VERSION TAGS KEY NAME STATUS ORGANIZATION
-====[timestamp]===== ====[timestamp]===== test v0.0.0-devel map[owner: scope:organization] built-in idle Coder
+CREATED AT LAST SEEN AT KEY NAME NAME VERSION STATUS TAGS
+====[timestamp]===== ====[timestamp]===== built-in test v0.0.0-devel idle map[owner: scope:organization]
diff --git a/cli/testdata/coder_provisioner_list_--help.golden b/cli/testdata/coder_provisioner_list_--help.golden
index ac889fb6dcf58..7a1807bb012f5 100644
--- a/cli/testdata/coder_provisioner_list_--help.golden
+++ b/cli/testdata/coder_provisioner_list_--help.golden
@@ -11,7 +11,7 @@ OPTIONS:
-O, --org string, $CODER_ORGANIZATION
Select which organization (uuid or name) to use.
- -c, --column [id|organization id|created at|last seen at|name|version|api version|tags|key name|status|current job id|current job status|current job template name|current job template icon|current job template display name|previous job id|previous job status|previous job template name|previous job template icon|previous job template display name|organization] (default: name,organization,status,key name,created at,last seen at,version,tags)
+ -c, --column [id|organization id|created at|last seen at|name|version|api version|tags|key name|status|current job id|current job status|current job template name|current job template icon|current job template display name|previous job id|previous job status|previous job template name|previous job template icon|previous job template display name|organization] (default: created at,last seen at,key name,name,version,status,tags)
Columns to display in table output.
-l, --limit int, $CODER_PROVISIONER_LIST_LIMIT (default: 50)
diff --git a/docs/reference/cli/provisioner_jobs_list.md b/docs/reference/cli/provisioner_jobs_list.md
index 2cd40049e2400..a7f2fa74384d2 100644
--- a/docs/reference/cli/provisioner_jobs_list.md
+++ b/docs/reference/cli/provisioner_jobs_list.md
@@ -48,7 +48,7 @@ Select which organization (uuid or name) to use.
| | |
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Type | [id\|created at\|started at\|completed at\|canceled at\|error\|error code\|status\|worker id\|file id\|tags\|queue position\|queue size\|organization id\|template version id\|workspace build id\|type\|available workers\|template version name\|template id\|template name\|template display name\|template icon\|workspace id\|workspace name\|organization\|queue]
|
-| Default | created at,id,organization,status,type,queue,tags
|
+| Default | created at,id,type,template display name,status,queue,tags
|
Columns to display in table output.
diff --git a/docs/reference/cli/provisioner_list.md b/docs/reference/cli/provisioner_list.md
index 4aadb22064755..128d76caf4c7e 100644
--- a/docs/reference/cli/provisioner_list.md
+++ b/docs/reference/cli/provisioner_list.md
@@ -39,7 +39,7 @@ Select which organization (uuid or name) to use.
| | |
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Type | [id\|organization id\|created at\|last seen at\|name\|version\|api version\|tags\|key name\|status\|current job id\|current job status\|current job template name\|current job template icon\|current job template display name\|previous job id\|previous job status\|previous job template name\|previous job template icon\|previous job template display name\|organization]
|
-| Default | name,organization,status,key name,created at,last seen at,version,tags
|
+| Default | created at,last seen at,key name,name,version,status,tags
|
Columns to display in table output.
diff --git a/enterprise/cli/testdata/coder_provisioner_jobs_list_--help.golden b/enterprise/cli/testdata/coder_provisioner_jobs_list_--help.golden
index d6eb9a7681a07..7a72605f0c288 100644
--- a/enterprise/cli/testdata/coder_provisioner_jobs_list_--help.golden
+++ b/enterprise/cli/testdata/coder_provisioner_jobs_list_--help.golden
@@ -11,7 +11,7 @@ OPTIONS:
-O, --org string, $CODER_ORGANIZATION
Select which organization (uuid or name) to use.
- -c, --column [id|created at|started at|completed at|canceled at|error|error code|status|worker id|file id|tags|queue position|queue size|organization id|template version id|workspace build id|type|available workers|template version name|template id|template name|template display name|template icon|workspace id|workspace name|organization|queue] (default: created at,id,organization,status,type,queue,tags)
+ -c, --column [id|created at|started at|completed at|canceled at|error|error code|status|worker id|file id|tags|queue position|queue size|organization id|template version id|workspace build id|type|available workers|template version name|template id|template name|template display name|template icon|workspace id|workspace name|organization|queue] (default: created at,id,type,template display name,status,queue,tags)
Columns to display in table output.
-l, --limit int, $CODER_PROVISIONER_JOB_LIST_LIMIT (default: 50)
diff --git a/enterprise/cli/testdata/coder_provisioner_list_--help.golden b/enterprise/cli/testdata/coder_provisioner_list_--help.golden
index ac889fb6dcf58..7a1807bb012f5 100644
--- a/enterprise/cli/testdata/coder_provisioner_list_--help.golden
+++ b/enterprise/cli/testdata/coder_provisioner_list_--help.golden
@@ -11,7 +11,7 @@ OPTIONS:
-O, --org string, $CODER_ORGANIZATION
Select which organization (uuid or name) to use.
- -c, --column [id|organization id|created at|last seen at|name|version|api version|tags|key name|status|current job id|current job status|current job template name|current job template icon|current job template display name|previous job id|previous job status|previous job template name|previous job template icon|previous job template display name|organization] (default: name,organization,status,key name,created at,last seen at,version,tags)
+ -c, --column [id|organization id|created at|last seen at|name|version|api version|tags|key name|status|current job id|current job status|current job template name|current job template icon|current job template display name|previous job id|previous job status|previous job template name|previous job template icon|previous job template display name|organization] (default: created at,last seen at,key name,name,version,status,tags)
Columns to display in table output.
-l, --limit int, $CODER_PROVISIONER_LIST_LIMIT (default: 50)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: