From ec268d1f10829231da188d4e78711c9f3c79e1ee Mon Sep 17 00:00:00 2001 From: YG Park Date: Mon, 10 Aug 2026 12:20:25 +0900 Subject: [PATCH] feat: separate usage accounts in tables --- internal/cli/run.go | 11 +++++++++-- internal/cli/run_test.go | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/cli/run.go b/internal/cli/run.go index 7a0a920..82ee76f 100644 --- a/internal/cli/run.go +++ b/internal/cli/run.go @@ -195,7 +195,11 @@ func printUsageAt(output io.Writer, usage api.ProviderUsage, now time.Time) { return } rows := [][]string{{"NAME", "PLAN", "LIMIT", "WINDOW", "USED", "REMAINING", "RESET", "PACE"}} + accountSeparators := map[int]bool{} for _, account := range usage.Accounts { + if len(rows) > 1 && (account.Error != nil || len(account.Limits) > 0) { + accountSeparators[len(rows)] = true + } plan := "-" if account.Plan != nil && *account.Plan != "" { plan = *account.Plan @@ -228,7 +232,7 @@ func printUsageAt(output io.Writer, usage api.ProviderUsage, now time.Time) { }) } } - printTable(output, rows, map[int]bool{4: true, 5: true}) + printTable(output, rows, map[int]bool{4: true, 5: true}, accountSeparators) } func usagePace(limit api.UsageLimit, now time.Time) string { @@ -339,7 +343,7 @@ func formatUsageTimeRemaining(remaining time.Duration) string { return "in " + value } -func printTable(output io.Writer, rows [][]string, rightAligned map[int]bool) { +func printTable(output io.Writer, rows [][]string, rightAligned map[int]bool, separatorsBefore map[int]bool) { widths := make([]int, len(rows[0])) for _, row := range rows { for column, value := range row { @@ -349,6 +353,9 @@ func printTable(output io.Writer, rows [][]string, rightAligned map[int]bool) { } printTableBorder(output, widths, "┌", "┬", "┐") for index, row := range rows { + if separatorsBefore[index] { + printTableBorder(output, widths, "├", "┼", "┤") + } fmt.Fprint(output, "│") for column, value := range row { padding := widths[column] - utf8.RuneCountInString(value) diff --git a/internal/cli/run_test.go b/internal/cli/run_test.go index fadef25..4950100 100644 --- a/internal/cli/run_test.go +++ b/internal/cli/run_test.go @@ -88,6 +88,7 @@ func TestChatGPTUsageOutputShowsEveryLimitAndPartialErrors(t *testing.T) { ├────────────────────┼──────┼─────────────────────┼─────────┼──────┼───────────┼─────────────────────────────────────┼────────────────────┤ │ person@example.com │ pro │ default │ primary │ 88% │ 12% │ 2026-08-11 09:24 KST (in 4d) │ RUNS OUT in 9h 49m │ │ │ │ GPT-5.3-Codex-Spark │ primary │ 0% │ 100% │ - │ - │ +├────────────────────┼──────┼─────────────────────┼─────────┼──────┼───────────┼─────────────────────────────────────┼────────────────────┤ │ other@example.com │ - │ - │ - │ - │ - │ ERROR: ChatGPT usage is unavailable │ - │ └────────────────────┴──────┴─────────────────────┴─────────┴──────┴───────────┴─────────────────────────────────────┴────────────────────┘ `