Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/auth/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ var profilesCmd = &cobra.Command{
Short: "Lists profiles from ~/.databrickscfg",
Annotations: map[string]string{
"template": cmdio.Heredoc(`
{{white "Name"}} {{white "Host"}} {{white "Valid"}}
{{range .Profiles}}{{.Name | green}} {{.Host|white}} {{bool .Valid}}
{{header "Name"}} {{header "Host"}} {{header "Valid"}}
{{range .Profiles}}{{.Name | green}} {{.Host|cyan}} {{bool .Valid}}
{{end}}`),
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/workspace/catalogs/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "Name"}} {{white "Type"}} {{white "Comment"}}
{{header "Name"}} {{header "Type"}} {{header "Comment"}}
{{range .}}{{.Name|green}} {{blue "%s" .CatalogType}} {{.Comment}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/clusters/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "ID"}} {{white "Name"}} {{white "State"}}
{{range .}}{{.ClusterId | green}} {{.ClusterName|white}} {{if eq .State "RUNNING"}}{{green "%s" .State}}{{else if eq .State "TERMINATED"}}{{red "%s" .State}}{{else}}{{blue "%s" .State}}{{end}}
{{header "ID"}} {{header "Name"}} {{header "State"}}
{{range .}}{{.ClusterId | green}} {{.ClusterName | cyan}} {{if eq .State "RUNNING"}}{{green "%s" .State}}{{else if eq .State "TERMINATED"}}{{red "%s" .State}}{{else}}{{blue "%s" .State}}{{end}}
{{end}}`)

listNodeTypesCmd.Annotations["template"] = cmdio.Heredoc(`
Expand Down
2 changes: 1 addition & 1 deletion cmd/workspace/dashboards/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "ID"}} {{white "Name"}}
{{header "ID"}} {{header "Name"}}
{{range .}}{{.Id|green}} {{.Name}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/external-locations/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "Name"}} {{white "Credential"}} {{white "URL"}}
{{range .}}{{.Name|green}} {{.CredentialName|blue}} {{.Url}}
{{header "Name"}} {{header "Credential"}} {{header "URL"}}
{{range .}}{{.Name|green}} {{.CredentialName|cyan}} {{.Url}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/jobs/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func init() {
{{end}}`)

listRunsCmd.Annotations["template"] = cmdio.Heredoc(`
{{"Job ID"|white}} {{"Run ID"|white}} {{"Result State"|white}} URL
{{range .}}{{green "%d" .JobId}} {{blue "%d" .RunId}} {{if eq .State.ResultState "SUCCESS"}}{{"SUCCESS"|green}}{{else}}{{red "%s" .State.ResultState}}{{end}} {{.RunPageUrl}}
{{header "Job ID"}} {{header "Run ID"}} {{header "Result State"}} URL
{{range .}}{{green "%d" .JobId}} {{cyan "%d" .RunId}} {{if eq .State.ResultState "SUCCESS"}}{{"SUCCESS"|green}}{{else}}{{red "%s" .State.ResultState}}{{end}} {{.RunPageUrl}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/metastores/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "ID"}} {{white "Name"}} {{white "Region"}}
{{range .}}{{.MetastoreId|green}} {{.Name|white}} {{.Region}}
{{header "ID"}} {{header "Name"}} {{"Region"}}
{{range .}}{{.MetastoreId|green}} {{.Name|cyan}} {{.Region}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/queries/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/databricks/cli/libs/cmdio"
func init() {
// TODO: figure out colored/non-colored headers and colspan shifts
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "ID"}} {{white "Name"}} {{white "Author"}}
{{range .}}{{.Id|green}} {{.Name|white}} {{.User.Email|white}}
{{header "ID"}} {{header "Name"}} {{header "Author"}}
{{range .}}{{.Id|green}} {{.Name|cyan}} {{.User.Email|cyan}}
{{end}}`)
}
2 changes: 1 addition & 1 deletion cmd/workspace/query-history/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import "github.com/databricks/cli/libs/cmdio"
func init() {
// TODO: figure out the right format
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{.UserName}} {{white "%s" .Status}} {{.QueryText}}
{{range .}}{{.UserName}} {{cyan "%s" .Status}} {{.QueryText}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/schemas/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "Full Name"}} {{white "Owner"}} {{white "Comment"}}
{{range .}}{{.FullName|green}} {{.Owner|white}} {{.Comment}}
{{header "Full Name"}} {{header "Owner"}} {{header "Comment"}}
{{range .}}{{.FullName|green}} {{.Owner|cyan}} {{.Comment}}
{{end}}`)
}
2 changes: 1 addition & 1 deletion cmd/workspace/secrets/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func init() {
listScopesCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "Scope"}} {{white "Backend Type"}}
{{header "Scope"}} {{header "Backend Type"}}
{{range .}}{{.Name|green}} {{.BackendType}}
{{end}}`)

Expand Down
4 changes: 2 additions & 2 deletions cmd/workspace/storage-credentials/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "ID"}} {{white "Name"}} {{white "Credentials"}}
{{range .}}{{.Id|green}} {{.Name|white}} {{if .AwsIamRole}}{{.AwsIamRole.RoleArn}}{{end}}{{if .AzureServicePrincipal}}{{.AzureServicePrincipal.ApplicationId}}{{end}}{{if .GcpServiceAccountKey}}{{.Email}}{{end}}
{{header "ID"}} {{header "Name"}} {{header "Credentials"}}
{{range .}}{{.Id|green}} {{.Name|cyan}} {{if .AwsIamRole}}{{.AwsIamRole.RoleArn}}{{end}}{{if .AzureServicePrincipal}}{{.AzureServicePrincipal.ApplicationId}}{{end}}{{if .GcpServiceAccountKey}}{{.Email}}{{end}}
{{end}}`)
}
2 changes: 1 addition & 1 deletion cmd/workspace/tables/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "Full Name"}} {{white "Table Type"}}
{{header "Full Name"}} {{header "Table Type"}}
{{range .}}{{.FullName|green}} {{blue "%s" .TableType}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/token-management/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "ID"}} {{white "Created By"}} {{white "Comment"}}
{{range .}}{{.TokenId|green}} {{.CreatedByUsername|white}} {{.Comment|white}}
{{header "ID"}} {{header "Created By"}} {{header "Comment"}}
{{range .}}{{.TokenId|green}} {{.CreatedByUsername|cyan}} {{.Comment|cyan}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/tokens/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "ID"}} {{white "Expiry time"}} {{white "Comment"}}
{{range .}}{{.TokenId|green}} {{white "%d" .ExpiryTime}} {{.Comment|white}}
{{header "ID"}} {{header "Expiry time"}} {{header "Comment"}}
{{range .}}{{.TokenId|green}} {{cyan "%d" .ExpiryTime}} {{.Comment|cyan}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/warehouses/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio"

func init() {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "ID"}} {{white "Name"}} {{white "Size"}} {{white "State"}}
{{range .}}{{.Id|green}} {{.Name|white}} {{.ClusterSize|white}} {{if eq .State "RUNNING"}}{{"RUNNING"|green}}{{else if eq .State "STOPPED"}}{{"STOPPED"|red}}{{else}}{{blue "%s" .State}}{{end}}
{{header "ID"}} {{header "Name"}} {{header "Size"}} {{header "State"}}
{{range .}}{{.Id|green}} {{.Name|cyan}} {{.ClusterSize|cyan}} {{if eq .State "RUNNING"}}{{"RUNNING"|green}}{{else if eq .State "STOPPED"}}{{"STOPPED"|red}}{{else}}{{blue "%s" .State}}{{end}}
{{end}}`)
}
4 changes: 2 additions & 2 deletions cmd/workspace/workspace/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/databricks/cli/libs/cmdio"
func init() {
listReq.Path = "/"
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{white "ID"}} {{white "Type"}} {{white "Language"}} {{white "Path"}}
{{range .}}{{green "%d" .ObjectId}} {{blue "%s" .ObjectType}} {{cyan "%s" .Language}} {{.Path|white}}
{{header "ID"}} {{header "Type"}} {{header "Language"}} {{header "Path"}}
{{range .}}{{green "%d" .ObjectId}} {{blue "%s" .ObjectType}} {{cyan "%s" .Language}} {{.Path|cyan}}
{{end}}`)
}
8 changes: 4 additions & 4 deletions libs/cmdio/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ func renderTemplate(w io.Writer, tmpl string, v any) error {
// we render colored output if stdout is TTY, otherwise we render text.
// in the future we'll check if we can explicitly check for stderr being
// a TTY
"black": color.BlackString,
"white": color.WhiteString,
"header": color.BlueString,
"red": color.RedString,
"green": color.GreenString,
"blue": color.BlueString,
Expand Down Expand Up @@ -107,8 +106,9 @@ func fancyJSON(v any) ([]byte, error) {
f.FalseColor = color.New(color.FgRed)
f.NumberColor = color.New(color.FgCyan)
f.NullColor = color.New(color.FgMagenta)
f.FieldColor = color.New(color.FgWhite, color.Bold)
f.FieldQuoteColor = color.New(color.FgWhite)
f.ObjectColor = color.New(color.Reset)
f.CommaColor = color.New(color.Reset)
f.ColonColor = color.New(color.Reset)

return jsoncolor.MarshalIndentWithFormatter(v, "", " ", f)
}