auth: styled table with headers for `entire auth contexts` · Entire
Auth: Styled Table with Headers for Entire Auth Contexts
Replace the tab-separated, headerless context listing with an aligned, styled table (CONTEXT / HANDLE / CORE URL columns, "*" marks the active context), matching the auth status active-sessions table.
Extract the column-sizing/writing loop into a shared renderAlignedTable helper and rename the shared style set authTableStyles, since both auth tables now use it.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Sessions
52bdb2ae5d4eView transcript
Refactor Auth Commands for Session Management
- Author: Claude Code · Opus 4.8 · 1 step
Changes
3
cmd/entire/cli
Mauth.go +23/-15
- Mauth_context.go +31/-3
- Mauth_context_test.go +10/-2
214 unmodified lines
// --- active-sessions table ---------------------------------------------------
// --- auth tables -------------------------------------------------------------
type sessionsTableStyles struct {
// authTableStyles holds the lipgloss styles shared by the `entire auth status`
// active-sessions table and the `entire auth contexts` table.
}
func renderAlignedTable(w io.Writer, header []string, rows [][]string) {
widths := make([]int, len(header))
for i, h := range header {
widths[i] = lipgloss.Width(h)
}
fmt.Fprintln(w)
}
Render Contexts Table
func renderContextsTable(w io.Writer, all []*contexts.Context, current string) {
sty := newAuthTableStyles(w)
header := []string{
"", // active marker
sty.render(sty.header, "CONTEXT"),
sty.render(sty.header, "HANDLE"),
sty.render(sty.header, "CORE URL"),
}
rows := make([][]string, 0, len(all))
for _, c := range all {
marker := " "
name := sty.render(sty.value, c.Name)
if c.Name == current {
marker = "*"
marker = sty.render(sty.id, "*")
name = sty.render(sty.name, c.Name)
}
fmt.Fprintf(w, "%s %s\t%s\t%s\n", marker, c.Name, c.Handle, c.CoreURL)
rows = append(rows, []string{
marker,
name,
sty.render(sty.value, fallback(c.Handle, placeholderDash)),
sty.render(sty.value, fallback(c.CoreURL, placeholderDash)),
})
}
return nil
}
Mcmd/entire/cli/auth_context.go +31/-3
// Test cases
if !strings.Contains(got, "* core.example.com") {
t.Fatalf("listing = %q, want current-marked core.example.com", got)
}
Mcmd/entire/cli/auth_context_test.go +10/-2