Skip to content

Commit 36cac5a

Browse files
committed
feat: show account info after login
Replace member count validation with GetAccountInfo API call during login. After successful authentication, display account name, email, and timezone to confirm the user connected to the right account.
1 parent 9ebec82 commit 36cac5a

5 files changed

Lines changed: 22 additions & 8 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/flashcatcloud/flashduty-cli
33
go 1.25.1
44

55
require (
6-
github.com/flashcatcloud/flashduty-sdk v0.8.1-0.20260512032214-576d76bd987a
6+
github.com/flashcatcloud/flashduty-sdk v0.8.1-0.20260513114317-7c106c52bd36
77
github.com/spf13/cobra v1.10.2
88
golang.org/x/term v0.42.0
99
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
2-
github.com/flashcatcloud/flashduty-sdk v0.7.0 h1:yPW8ghyHB60/34fz5sBITXhMWtbsm2mxYVFORgs+jpE=
3-
github.com/flashcatcloud/flashduty-sdk v0.7.0/go.mod h1:dG4eJfdZaj4jNBMwEexbfK/3PmcIMhNeJ88L/DcZzUY=
4-
github.com/flashcatcloud/flashduty-sdk v0.8.1-0.20260512032214-576d76bd987a h1:nnMflbhcqVskLh22MaUpfXesqNegZ0uWUFd2sbenwT8=
5-
github.com/flashcatcloud/flashduty-sdk v0.8.1-0.20260512032214-576d76bd987a/go.mod h1:dG4eJfdZaj4jNBMwEexbfK/3PmcIMhNeJ88L/DcZzUY=
2+
github.com/flashcatcloud/flashduty-sdk v0.8.1-0.20260513114317-7c106c52bd36 h1:yrY7iNBkZrcj6qRZsXwCzMTXjKKzDRGlca/QRfNqiZI=
3+
github.com/flashcatcloud/flashduty-sdk v0.8.1-0.20260513114317-7c106c52bd36/go.mod h1:dG4eJfdZaj4jNBMwEexbfK/3PmcIMhNeJ88L/DcZzUY=
64
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
75
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
86
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

internal/cli/command_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import (
1515
// methods. Embed it in per-test mocks and override only the methods under test.
1616
type mockClient struct{}
1717

18+
func (m *mockClient) GetAccountInfo(context.Context) (*flashduty.AccountInfo, error) {
19+
return nil, fmt.Errorf("mockClient: GetAccountInfo not implemented")
20+
}
21+
1822
func (m *mockClient) ListIncidents(context.Context, *flashduty.ListIncidentsInput) (*flashduty.ListIncidentsOutput, error) {
1923
return nil, fmt.Errorf("mockClient: ListIncidents not implemented")
2024
}

internal/cli/login.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func newLoginCmd() *cobra.Command {
3030
return fmt.Errorf("app key cannot be empty")
3131
}
3232

33-
// Validate by making a test API call
3433
client, err := flashduty.NewClient(appKey, flashduty.WithLogger(&silentLogger{}))
3534
if err != nil {
3635
return fmt.Errorf("invalid app key: %w", err)
@@ -39,7 +38,8 @@ func newLoginCmd() *cobra.Command {
3938
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
4039
defer cancel()
4140

42-
result, err := client.ListMembers(ctx, &flashduty.ListMembersInput{})
41+
// Validate by fetching account info
42+
account, err := client.GetAccountInfo(ctx)
4343
if err != nil {
4444
return fmt.Errorf("authentication failed: %w", err)
4545
}
@@ -51,7 +51,16 @@ func newLoginCmd() *cobra.Command {
5151
return fmt.Errorf("failed to save config: %w", err)
5252
}
5353

54-
fmt.Printf("Logged in successfully. Account has %d members.\n", result.Total)
54+
w := cmd.OutOrStdout()
55+
_, _ = fmt.Fprintf(w, "Logged in successfully.\n")
56+
_, _ = fmt.Fprintf(w, " Account: %s\n", account.AccountName)
57+
if account.Email != "" {
58+
_, _ = fmt.Fprintf(w, " Email: %s\n", account.Email)
59+
}
60+
if account.TimeZone != "" {
61+
_, _ = fmt.Fprintf(w, " Timezone: %s\n", account.TimeZone)
62+
}
63+
5564
return nil
5665
},
5766
}

internal/cli/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import (
1818

1919
// flashdutyClient defines the SDK operations used by CLI commands.
2020
type flashdutyClient interface {
21+
// === Account ===
22+
GetAccountInfo(ctx context.Context) (*flashduty.AccountInfo, error)
23+
2124
// === EXISTING ===
2225
ListIncidents(ctx context.Context, input *flashduty.ListIncidentsInput) (*flashduty.ListIncidentsOutput, error)
2326
GetIncidentTimelines(ctx context.Context, incidentIDs []string) ([]flashduty.IncidentTimelineOutput, error)

0 commit comments

Comments
 (0)