Skip to content

Commit 0a58eab

Browse files
committed
Improve CLI help and human output UX
1 parent b3a72ba commit 0a58eab

15 files changed

Lines changed: 809 additions & 53 deletions

internal/commands/auth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ var authListCmd = &cobra.Command{
237237
breadcrumb("login", "fizzy auth login <token>", "Log in"),
238238
breadcrumb("signup", "fizzy signup", "Sign up"),
239239
}
240-
printSuccessWithBreadcrumbs([]any{}, "No profiles configured", breadcrumbs)
240+
printList([]any{}, authProfileColumns, "No profiles configured", breadcrumbs)
241241
return nil
242242
}
243243

@@ -247,7 +247,7 @@ var authListCmd = &cobra.Command{
247247
breadcrumb("login", "fizzy auth login <token>", "Log in"),
248248
breadcrumb("signup", "fizzy signup", "Sign up"),
249249
}
250-
printSuccessWithBreadcrumbs([]any{}, "No profiles configured", breadcrumbs)
250+
printList([]any{}, authProfileColumns, "No profiles configured", breadcrumbs)
251251
return nil
252252
}
253253

@@ -282,7 +282,7 @@ var authListCmd = &cobra.Command{
282282
breadcrumb("switch", "fizzy auth switch <profile>", "Switch profile"),
283283
}
284284

285-
printSuccessWithBreadcrumbs(entries, fmt.Sprintf("%d profile(s)", len(entries)), breadcrumbs)
285+
printList(entries, authProfileColumns, fmt.Sprintf("%d profile(s)", len(entries)), breadcrumbs)
286286
return nil
287287
},
288288
}

internal/commands/auth_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import (
44
"encoding/json"
55
"os"
66
"path/filepath"
7+
"strings"
78
"testing"
89

910
"github.com/basecamp/cli/credstore"
11+
"github.com/basecamp/cli/output"
1012
"github.com/basecamp/cli/profile"
1113
"github.com/basecamp/fizzy-cli/internal/config"
1214
"gopkg.in/yaml.v3"
@@ -507,6 +509,41 @@ func TestAuthList(t *testing.T) {
507509
t.Errorf("expected 0 profiles, got %d", len(profiles))
508510
}
509511
})
512+
513+
t.Run("renders styled output with next steps", func(t *testing.T) {
514+
credDir := t.TempDir()
515+
profileDir := t.TempDir()
516+
517+
os.Setenv("FIZZY_LIST_STYLED_NO_KR", "1")
518+
defer os.Unsetenv("FIZZY_LIST_STYLED_NO_KR")
519+
store := credstore.NewStore(credstore.StoreOptions{
520+
ServiceName: "fizzy-list-styled-test",
521+
DisableEnvVar: "FIZZY_LIST_STYLED_NO_KR",
522+
FallbackDir: credDir,
523+
})
524+
profileStore := profile.NewStore(filepath.Join(profileDir, "config.json"))
525+
profileStore.Create(&profile.Profile{Name: "acme", BaseURL: "https://app.fizzy.do"})
526+
t1, _ := json.Marshal("token1")
527+
store.Save("profile:acme", t1)
528+
529+
mock := NewMockClient()
530+
SetTestModeWithSDK(mock)
531+
SetTestCreds(store)
532+
SetTestProfiles(profileStore)
533+
SetTestFormat(output.FormatStyled)
534+
defer resetTest()
535+
536+
err := authListCmd.RunE(authListCmd, []string{})
537+
assertExitCode(t, err, 0)
538+
539+
raw := TestOutput()
540+
if !strings.Contains(raw, "Profile") {
541+
t.Fatalf("expected styled table output, got:\n%s", raw)
542+
}
543+
if !strings.Contains(raw, "Next steps:") {
544+
t.Fatalf("expected next steps section, got:\n%s", raw)
545+
}
546+
})
510547
}
511548

512549
func TestAuthSwitch(t *testing.T) {

internal/commands/column.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var columnListCmd = &cobra.Command{
4141

4242
dataSlice := toSliceAny(items)
4343
if dataSlice == nil {
44-
printSuccess(items)
44+
printDetail(items, "", nil)
4545
return nil
4646
}
4747

internal/commands/columns.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ var (
3939
{Header: "Name", Field: "name"},
4040
}
4141

42+
authProfileColumns = render.Columns{
43+
{Header: "Profile", Field: "profile"},
44+
{Header: "Active", Field: "active"},
45+
{Header: "Board", Field: "board"},
46+
{Header: "Base URL", Field: "base_url"},
47+
}
48+
4249
notificationColumns = render.Columns{
4350
{Header: "ID", Field: "id"},
4451
{Header: "Message", Field: "message"},

0 commit comments

Comments
 (0)