Skip to content

Commit 8d63e1a

Browse files
authored
Add TUI table overrides for high-traffic list commands (#4732)
## Why PR #4731 added curated TUI table overrides for 15 list commands. This follow-up covers 5 additional commands that are among the most frequently used in the CLI, but were missing curated columns. ## Changes Before: these 5 commands used either generic text templates (secrets, cluster-policies) or raw JSON output (lakeview, pipeline events) with no curated TUI table columns. Now: all 5 register curated TableConfig overrides so they show useful columns in the interactive TUI. Commands that had no text template override (lakeview list, pipelines list-pipeline-events) also get template annotations for the non-interactive fallback. This PR stacks on #4731. It only adds per-command overrides, no engine changes. ### Post-review fixes - Sanitize control whitespace (`\n`, `\r`, `\t`) in pipeline event messages to prevent table row corruption - Increase MaxWidth for pipeline event Message column from 60 to 200 (pragmatic cap until non-destructive clipping is implemented) - Remove redundant `PaginatedModel` type alias, use `FinalModel` interface instead - Remove duplicate `TestPaginatedErrAccessor` test - Trim verbose MaxWidth truncation comment ## Test plan - `go build ./...` - `make checks` passes - `make lintfull` passes (0 issues) - Manual smoke test: verify curated columns for `secrets list-scopes`, `lakeview list`, `pipelines list-pipeline-events`
1 parent ed87880 commit 8d63e1a

File tree

17 files changed

+143
-24
lines changed

17 files changed

+143
-24
lines changed

cmd/workspace/alerts/overrides.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/spf13/cobra"
88
)
99

10-
func listOverride(listCmd *cobra.Command, listReq *sql.ListAlertsRequest) {
10+
func listOverride(listCmd *cobra.Command, _ *sql.ListAlertsRequest) {
1111
listCmd.Annotations["template"] = cmdio.Heredoc(`
1212
{{range .}}{{green "%s" .Id}} {{.DisplayName}} {{.State}}
1313
{{end}}`)

cmd/workspace/apps/overrides.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/spf13/cobra"
1111
)
1212

13-
func listOverride(listCmd *cobra.Command, listReq *apps.ListAppsRequest) {
13+
func listOverride(listCmd *cobra.Command, _ *apps.ListAppsRequest) {
1414
listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(`
1515
{{header "Name"}} {{header "Url"}} {{header "ComputeStatus"}} {{header "DeploymentStatus"}}`)
1616
listCmd.Annotations["template"] = cmdio.Heredoc(`
@@ -45,7 +45,7 @@ func listOverride(listCmd *cobra.Command, listReq *apps.ListAppsRequest) {
4545
tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
4646
}
4747

48-
func listDeploymentsOverride(listDeploymentsCmd *cobra.Command, listDeploymentsReq *apps.ListAppDeploymentsRequest) {
48+
func listDeploymentsOverride(listDeploymentsCmd *cobra.Command, _ *apps.ListAppDeploymentsRequest) {
4949
listDeploymentsCmd.Annotations["headerTemplate"] = cmdio.Heredoc(`
5050
{{header "DeploymentId"}} {{header "State"}} {{header "CreatedAt"}}`)
5151
listDeploymentsCmd.Annotations["template"] = cmdio.Heredoc(`

cmd/workspace/catalogs/overrides.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/spf13/cobra"
88
)
99

10-
func listOverride(listCmd *cobra.Command, listReq *catalog.ListCatalogsRequest) {
10+
func listOverride(listCmd *cobra.Command, _ *catalog.ListCatalogsRequest) {
1111
listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(`
1212
{{header "Name"}} {{header "Type"}} {{header "Comment"}}`)
1313
listCmd.Annotations["template"] = cmdio.Heredoc(`

cmd/workspace/cluster-policies/overrides.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cluster_policies
22

33
import (
44
"github.com/databricks/cli/libs/cmdio"
5+
"github.com/databricks/cli/libs/tableview"
56
"github.com/databricks/databricks-sdk-go/service/compute"
67
"github.com/spf13/cobra"
78
)
@@ -10,6 +11,23 @@ func listOverride(listCmd *cobra.Command, _ *compute.ListClusterPoliciesRequest)
1011
listCmd.Annotations["template"] = cmdio.Heredoc(`
1112
{{range .}}{{.PolicyId | green}} {{.Name}}
1213
{{end}}`)
14+
15+
columns := []tableview.ColumnDef{
16+
{Header: "Policy ID", Extract: func(v any) string {
17+
return v.(compute.Policy).PolicyId
18+
}},
19+
{Header: "Name", Extract: func(v any) string {
20+
return v.(compute.Policy).Name
21+
}},
22+
{Header: "Default", Extract: func(v any) string {
23+
if v.(compute.Policy).IsDefault {
24+
return "yes"
25+
}
26+
return ""
27+
}},
28+
}
29+
30+
tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
1331
}
1432

1533
func getOverride(getCmd *cobra.Command, _ *compute.GetClusterPolicyRequest) {

cmd/workspace/external-locations/overrides.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/spf13/cobra"
88
)
99

10-
func listOverride(listCmd *cobra.Command, listReq *catalog.ListExternalLocationsRequest) {
10+
func listOverride(listCmd *cobra.Command, _ *catalog.ListExternalLocationsRequest) {
1111
listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(`
1212
{{header "Name"}} {{header "Credential"}} {{header "URL"}}`)
1313
listCmd.Annotations["template"] = cmdio.Heredoc(`

cmd/workspace/jobs/overrides.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func listOverride(listCmd *cobra.Command, listReq *jobs.ListJobsRequest) {
4444
})
4545
}
4646

47-
func listRunsOverride(listRunsCmd *cobra.Command, listRunsReq *jobs.ListRunsRequest) {
47+
func listRunsOverride(listRunsCmd *cobra.Command, _ *jobs.ListRunsRequest) {
4848
listRunsCmd.Annotations["headerTemplate"] = cmdio.Heredoc(`
4949
{{header "Job ID"}} {{header "Run ID"}} {{header "Result State"}} URL`)
5050
listRunsCmd.Annotations["template"] = cmdio.Heredoc(`

cmd/workspace/lakeview/overrides.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
package lakeview
22

33
import (
4+
"github.com/databricks/cli/libs/cmdio"
5+
"github.com/databricks/cli/libs/tableview"
46
"github.com/databricks/databricks-sdk-go/service/dashboards"
57
"github.com/spf13/cobra"
68
)
79

10+
func listOverride(listCmd *cobra.Command, _ *dashboards.ListDashboardsRequest) {
11+
listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(`
12+
{{header "Dashboard ID"}} {{header "Name"}} {{header "State"}}`)
13+
listCmd.Annotations["template"] = cmdio.Heredoc(`
14+
{{range .}}{{green "%s" .DashboardId}} {{.DisplayName}} {{blue "%s" .LifecycleState}}
15+
{{end}}`)
16+
17+
columns := []tableview.ColumnDef{
18+
{Header: "Dashboard ID", Extract: func(v any) string {
19+
return v.(dashboards.Dashboard).DashboardId
20+
}},
21+
{Header: "Name", Extract: func(v any) string {
22+
return v.(dashboards.Dashboard).DisplayName
23+
}},
24+
{Header: "State", Extract: func(v any) string {
25+
return string(v.(dashboards.Dashboard).LifecycleState)
26+
}},
27+
}
28+
29+
tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
30+
}
31+
832
func publishOverride(cmd *cobra.Command, req *dashboards.PublishRequest) {
933
originalRunE := cmd.RunE
1034
cmd.RunE = func(cmd *cobra.Command, args []string) error {
@@ -15,5 +39,6 @@ func publishOverride(cmd *cobra.Command, req *dashboards.PublishRequest) {
1539
}
1640

1741
func init() {
42+
listOverrides = append(listOverrides, listOverride)
1843
publishOverrides = append(publishOverrides, publishOverride)
1944
}

cmd/workspace/pipelines/overrides.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,34 @@ func listPipelinesOverride(listCmd *cobra.Command, listReq *pipelines.ListPipeli
6262
}
6363
}
6464

65+
func listPipelineEventsOverride(listCmd *cobra.Command, _ *pipelines.ListPipelineEventsRequest) {
66+
listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(`
67+
{{header "Timestamp"}} {{header "Level"}} {{header "Event Type"}} {{header "Message"}}`)
68+
listCmd.Annotations["template"] = cmdio.Heredoc(`
69+
{{range .}}{{.Timestamp}} {{.Level}} {{.EventType}} {{.Message | sanitize}}
70+
{{end}}`)
71+
72+
columns := []tableview.ColumnDef{
73+
{Header: "Timestamp", Extract: func(v any) string {
74+
return v.(pipelines.PipelineEvent).Timestamp
75+
}},
76+
{Header: "Level", Extract: func(v any) string {
77+
return string(v.(pipelines.PipelineEvent).Level)
78+
}},
79+
{Header: "Event Type", Extract: func(v any) string {
80+
return v.(pipelines.PipelineEvent).EventType
81+
}},
82+
{Header: "Message", MaxWidth: 200, Extract: func(v any) string {
83+
return sanitizeWhitespace(v.(pipelines.PipelineEvent).Message)
84+
}},
85+
}
86+
87+
tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
88+
}
89+
6590
func init() {
6691
listPipelinesOverrides = append(listPipelinesOverrides, listPipelinesOverride)
92+
listPipelineEventsOverrides = append(listPipelineEventsOverrides, listPipelineEventsOverride)
6793

6894
cmdOverrides = append(cmdOverrides, func(cli *cobra.Command) {
6995
// all auto-generated commands apart from nonManagementCommands go into 'management' group
@@ -135,6 +161,14 @@ func disableSearchIfFilterSet(cmd *cobra.Command) {
135161
}
136162
}
137163

164+
var controlWhitespaceReplacer = strings.NewReplacer("\n", " ", "\r", " ", "\t", " ")
165+
166+
// sanitizeWhitespace replaces control whitespace (newlines, tabs) with spaces
167+
// to prevent corrupting tab-delimited or TUI table output.
168+
func sanitizeWhitespace(s string) string {
169+
return controlWhitespaceReplacer.Replace(s)
170+
}
171+
138172
var uuidRegex = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)
139173

140174
// looksLikeUUID checks if a string matches the UUID format with lowercase hex digits

cmd/workspace/repos/overrides.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/spf13/cobra"
1818
)
1919

20-
func listOverride(listCmd *cobra.Command, listReq *workspace.ListReposRequest) {
20+
func listOverride(listCmd *cobra.Command, _ *workspace.ListReposRequest) {
2121
listCmd.Annotations["template"] = cmdio.Heredoc(`
2222
{{range .}}{{green "%d" .Id}} {{.Path}} {{.Branch|blue}} {{.Url|cyan}}
2323
{{end}}`)

cmd/workspace/schemas/overrides.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/spf13/cobra"
88
)
99

10-
func listOverride(listCmd *cobra.Command, listReq *catalog.ListSchemasRequest) {
10+
func listOverride(listCmd *cobra.Command, _ *catalog.ListSchemasRequest) {
1111
listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(`
1212
{{header "Full Name"}} {{header "Owner"}} {{header "Comment"}}`)
1313
listCmd.Annotations["template"] = cmdio.Heredoc(`

0 commit comments

Comments
 (0)