Skip to content

Commit 8d56a05

Browse files
authored
chore(agents): consistent table style and formatting (#540)
1 parent 404db9d commit 8d56a05

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

cmd/lk/agent.go

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import (
2727

2828
"github.com/BurntSushi/toml"
2929
"github.com/charmbracelet/huh"
30-
"github.com/charmbracelet/lipgloss"
31-
"github.com/charmbracelet/lipgloss/table"
3230
"github.com/urfave/cli/v3"
3331

3432
"github.com/livekit/livekit-cli/v2/pkg/agentfs"
@@ -750,13 +748,13 @@ func getAgentStatus(ctx context.Context, cmd *cli.Command) error {
750748
fmt.Sprintf("%s / %s", curMem, memReq),
751749
fmt.Sprintf("%d", regionalAgent.Replicas),
752750
fmt.Sprintf("%d/%d", regionalAgent.MinReplicas, regionalAgent.MaxReplicas),
753-
agent.DeployedAt.AsTime().Local().Format("Jan 2, 2006 15:04:05"),
751+
agent.DeployedAt.AsTime().Format(time.RFC3339),
754752
})
755753
}
756754
}
757755

758-
t := CreateAgentTable().
759-
Headers("Region", "Status", "CPU", "Mem", "Replicas current", "Replicas min/max", "Deployed At").
756+
t := util.CreateTable().
757+
Headers("Region", "Status", "CPU", "Mem", "Repl.", "Repl. min/max", "Deployed").
760758
Rows(rows...)
761759

762760
fmt.Println(t)
@@ -923,7 +921,7 @@ func listAgentVersions(ctx context.Context, cmd *cli.Command) error {
923921
return err
924922
}
925923

926-
table := CreateAgentTable().
924+
table := util.CreateTable().
927925
Headers("Version", "Current", "Created At")
928926

929927
for _, version := range versions.Versions {
@@ -972,7 +970,7 @@ func listAgents(ctx context.Context, cmd *cli.Command) error {
972970
rows = append(rows, []string{agent.AgentId, agent.AgentName, strings.Join(regions, ",")})
973971
}
974972

975-
t := CreateAgentTable().
973+
t := util.CreateTable().
976974
Headers("ID", "Name", "Regions").
977975
Rows(rows...)
978976

@@ -1003,7 +1001,7 @@ func listAgentSecrets(ctx context.Context, cmd *cli.Command) error {
10031001
return err
10041002
}
10051003

1006-
table := CreateAgentTable().
1004+
table := util.CreateTable().
10071005
Headers("Name", "Created At", "Updated At")
10081006

10091007
for _, secret := range secrets.Secrets {
@@ -1088,22 +1086,6 @@ func updateAgentSecrets(ctx context.Context, cmd *cli.Command) error {
10881086
return fmt.Errorf("failed to update agent secrets: %s", resp.Message)
10891087
}
10901088

1091-
func CreateAgentTable() *table.Table {
1092-
return table.New().
1093-
Border(lipgloss.ThickBorder()).
1094-
BorderStyle(lipgloss.NewStyle().Foreground(lipgloss.Color("36"))).
1095-
StyleFunc(func(row, col int) lipgloss.Style {
1096-
switch {
1097-
case row == -1:
1098-
return lipgloss.NewStyle().
1099-
Foreground(lipgloss.Color("63")).
1100-
Bold(true)
1101-
default:
1102-
return lipgloss.NewStyle()
1103-
}
1104-
})
1105-
}
1106-
11071089
func getAgentName(cmd *cli.Command, agentDir string, tomlFileName string) (string, error) {
11081090
agentName := cmd.String("name")
11091091
if agentName == "" {

0 commit comments

Comments
 (0)