fizzy-cli 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/bin/fizzy +0 -0
  3. package/cmd/board.go +1 -1
  4. package/cmd/board_create.go +1 -1
  5. package/cmd/board_delete.go +40 -0
  6. package/cmd/board_delete_test.go +121 -0
  7. package/cmd/board_show.go +40 -0
  8. package/cmd/board_show_test.go +113 -0
  9. package/cmd/board_update.go +72 -0
  10. package/cmd/board_update_test.go +233 -0
  11. package/cmd/card_assign.go +1 -1
  12. package/cmd/card_close.go +1 -1
  13. package/cmd/card_create.go +1 -1
  14. package/cmd/card_delete.go +1 -1
  15. package/cmd/card_golden.go +1 -1
  16. package/cmd/card_list.go +62 -1
  17. package/cmd/card_list_test.go +225 -0
  18. package/cmd/card_not_now.go +1 -1
  19. package/cmd/card_reaction.go +13 -0
  20. package/cmd/card_reaction_create.go +46 -0
  21. package/cmd/card_reaction_create_test.go +148 -0
  22. package/cmd/card_reaction_delete.go +46 -0
  23. package/cmd/card_reaction_delete_test.go +112 -0
  24. package/cmd/card_reaction_list.go +51 -0
  25. package/cmd/card_reaction_list_test.go +127 -0
  26. package/cmd/card_reopen.go +1 -1
  27. package/cmd/card_tag.go +1 -1
  28. package/cmd/card_triage.go +1 -1
  29. package/cmd/card_ungolden.go +1 -1
  30. package/cmd/card_untriage.go +1 -1
  31. package/cmd/card_unwatch.go +1 -1
  32. package/cmd/card_update.go +1 -1
  33. package/cmd/card_watch.go +1 -1
  34. package/cmd/column_create.go +1 -1
  35. package/cmd/column_delete.go +40 -0
  36. package/cmd/column_delete_test.go +121 -0
  37. package/cmd/column_show.go +40 -0
  38. package/cmd/column_show_test.go +111 -0
  39. package/cmd/column_update.go +67 -0
  40. package/cmd/column_update_test.go +198 -0
  41. package/cmd/comment_create.go +1 -1
  42. package/cmd/comment_delete.go +1 -1
  43. package/cmd/comment_update.go +1 -1
  44. package/cmd/login.go +12 -12
  45. package/cmd/notification_unread.go +1 -1
  46. package/cmd/reaction.go +2 -2
  47. package/cmd/reaction_create.go +1 -1
  48. package/cmd/reaction_delete.go +1 -1
  49. package/cmd/step_create.go +1 -1
  50. package/cmd/step_delete.go +1 -1
  51. package/cmd/step_update.go +1 -1
  52. package/cmd/user.go +22 -0
  53. package/cmd/user_deactivate.go +40 -0
  54. package/cmd/user_deactivate_test.go +121 -0
  55. package/cmd/user_list.go +44 -0
  56. package/cmd/user_list_test.go +126 -0
  57. package/cmd/user_show.go +40 -0
  58. package/cmd/user_show_test.go +110 -0
  59. package/cmd/user_update.go +71 -0
  60. package/cmd/user_update_test.go +177 -0
  61. package/docs/API.md +63 -2
  62. package/internal/api/boards.go +34 -0
  63. package/internal/api/cards.go +40 -6
  64. package/internal/api/columns.go +63 -0
  65. package/internal/api/reactions.go +61 -0
  66. package/internal/api/types.go +17 -0
  67. package/internal/api/users.go +75 -0
  68. package/internal/ui/board_show.go +17 -0
  69. package/internal/ui/column_show.go +16 -0
  70. package/internal/ui/format.go +14 -1
  71. package/internal/ui/user_list.go +19 -0
  72. package/internal/ui/user_show.go +23 -0
  73. package/package.json +1 -1
@@ -0,0 +1,111 @@
1
+ package cmd
2
+
3
+ import (
4
+ "context"
5
+ "encoding/json"
6
+ "net/http"
7
+ "net/http/httptest"
8
+ "testing"
9
+
10
+ "github.com/rogeriopvl/fizzy/internal/api"
11
+ "github.com/rogeriopvl/fizzy/internal/app"
12
+ "github.com/rogeriopvl/fizzy/internal/testutil"
13
+ )
14
+
15
+ func TestColumnShowCommandSuccess(t *testing.T) {
16
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
17
+ if r.URL.Path != "/boards/board-123/columns/col-456" {
18
+ t.Errorf("expected /boards/board-123/columns/col-456, got %s", r.URL.Path)
19
+ }
20
+ if r.Method != http.MethodGet {
21
+ t.Errorf("expected GET, got %s", r.Method)
22
+ }
23
+
24
+ auth := r.Header.Get("Authorization")
25
+ if auth != "Bearer test-token" {
26
+ t.Errorf("expected Bearer test-token, got %s", auth)
27
+ }
28
+
29
+ w.Header().Set("Content-Type", "application/json")
30
+ response := api.Column{
31
+ ID: "col-456",
32
+ Name: "In Progress",
33
+ CreatedAt: "2025-01-01T00:00:00Z",
34
+ Color: api.ColorObject{
35
+ Name: "Lime",
36
+ Value: api.Lime,
37
+ },
38
+ }
39
+ json.NewEncoder(w).Encode(response)
40
+ }))
41
+ defer server.Close()
42
+
43
+ client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
44
+ testApp := &app.App{Client: client}
45
+
46
+ cmd := columnShowCmd
47
+ cmd.SetContext(testApp.ToContext(context.Background()))
48
+
49
+ if err := handleShowColumnDetails(cmd, "col-456"); err != nil {
50
+ t.Fatalf("handleShowColumnDetails failed: %v", err)
51
+ }
52
+ }
53
+
54
+ func TestColumnShowCommandNotFound(t *testing.T) {
55
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
56
+ w.WriteHeader(http.StatusNotFound)
57
+ w.Write([]byte("Column not found"))
58
+ }))
59
+ defer server.Close()
60
+
61
+ client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
62
+ testApp := &app.App{Client: client}
63
+
64
+ cmd := columnShowCmd
65
+ cmd.SetContext(testApp.ToContext(context.Background()))
66
+
67
+ err := handleShowColumnDetails(cmd, "nonexistent-col")
68
+ if err == nil {
69
+ t.Errorf("expected error for column not found")
70
+ }
71
+ if err.Error() != "fetching column: unexpected status code 404: Column not found" {
72
+ t.Errorf("expected column not found error, got %v", err)
73
+ }
74
+ }
75
+
76
+ func TestColumnShowCommandAPIError(t *testing.T) {
77
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
78
+ w.WriteHeader(http.StatusInternalServerError)
79
+ w.Write([]byte("Internal Server Error"))
80
+ }))
81
+ defer server.Close()
82
+
83
+ client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
84
+ testApp := &app.App{Client: client}
85
+
86
+ cmd := columnShowCmd
87
+ cmd.SetContext(testApp.ToContext(context.Background()))
88
+
89
+ err := handleShowColumnDetails(cmd, "col-456")
90
+ if err == nil {
91
+ t.Errorf("expected error for API failure")
92
+ }
93
+ if err.Error() != "fetching column: unexpected status code 500: Internal Server Error" {
94
+ t.Errorf("expected API error, got %v", err)
95
+ }
96
+ }
97
+
98
+ func TestColumnShowCommandNoClient(t *testing.T) {
99
+ testApp := &app.App{}
100
+
101
+ cmd := columnShowCmd
102
+ cmd.SetContext(testApp.ToContext(context.Background()))
103
+
104
+ err := handleShowColumnDetails(cmd, "col-456")
105
+ if err == nil {
106
+ t.Errorf("expected error when client not available")
107
+ }
108
+ if err.Error() != "API client not available" {
109
+ t.Errorf("expected 'client not available' error, got %v", err)
110
+ }
111
+ }
@@ -0,0 +1,67 @@
1
+ package cmd
2
+
3
+ import (
4
+ "context"
5
+ "fmt"
6
+
7
+ "github.com/rogeriopvl/fizzy/internal/api"
8
+ "github.com/rogeriopvl/fizzy/internal/app"
9
+ "github.com/spf13/cobra"
10
+ )
11
+
12
+ var columnUpdateCmd = &cobra.Command{
13
+ Use: "update <column_id>",
14
+ Short: "Update a column",
15
+ Long: `Update column settings such as name and color`,
16
+ Args: cobra.ExactArgs(1),
17
+ Run: func(cmd *cobra.Command, args []string) {
18
+ if err := handleUpdateColumn(cmd, args[0]); err != nil {
19
+ fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
20
+ }
21
+ },
22
+ }
23
+
24
+ func handleUpdateColumn(cmd *cobra.Command, columnID string) error {
25
+ // Check that at least one flag was explicitly set
26
+ if !cmd.Flags().Changed("name") && !cmd.Flags().Changed("color") {
27
+ return fmt.Errorf("at least one flag must be provided (--name or --color)")
28
+ }
29
+
30
+ a := app.FromContext(cmd.Context())
31
+ if a == nil || a.Client == nil {
32
+ return fmt.Errorf("API client not available")
33
+ }
34
+
35
+ // Build payload only with flags that were explicitly set
36
+ payload := api.UpdateColumnPayload{}
37
+
38
+ if cmd.Flags().Changed("name") {
39
+ name, _ := cmd.Flags().GetString("name")
40
+ payload.Name = name
41
+ }
42
+
43
+ if cmd.Flags().Changed("color") {
44
+ colorStr, _ := cmd.Flags().GetString("color")
45
+ colorAliases := buildColorAliases()
46
+ color, ok := colorAliases[colorStr]
47
+ if !ok {
48
+ return fmt.Errorf("invalid color '%s'. Available colors: %s", colorStr, getAvailableColors())
49
+ }
50
+ payload.Color = &color
51
+ }
52
+
53
+ err := a.Client.PutColumn(context.Background(), columnID, payload)
54
+ if err != nil {
55
+ return fmt.Errorf("updating column: %w", err)
56
+ }
57
+
58
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Column '%s' updated successfully\n", columnID)
59
+ return nil
60
+ }
61
+
62
+ func init() {
63
+ columnUpdateCmd.Flags().StringP("name", "n", "", "Column name")
64
+ columnUpdateCmd.Flags().String("color", "", fmt.Sprintf("Column color (optional). Available: %s", getAvailableColors()))
65
+
66
+ columnCmd.AddCommand(columnUpdateCmd)
67
+ }
@@ -0,0 +1,198 @@
1
+ package cmd
2
+
3
+ import (
4
+ "context"
5
+ "encoding/json"
6
+ "io"
7
+ "net/http"
8
+ "net/http/httptest"
9
+ "testing"
10
+
11
+ "github.com/rogeriopvl/fizzy/internal/api"
12
+ "github.com/rogeriopvl/fizzy/internal/app"
13
+ "github.com/rogeriopvl/fizzy/internal/testutil"
14
+ "github.com/spf13/cobra"
15
+ )
16
+
17
+ func newTestUpdateColumnCmd() *cobra.Command {
18
+ cmd := &cobra.Command{
19
+ Use: "update <column_id>",
20
+ Args: cobra.ExactArgs(1),
21
+ }
22
+ cmd.Flags().StringP("name", "n", "", "Column name")
23
+ cmd.Flags().String("color", "", "Column color")
24
+ return cmd
25
+ }
26
+
27
+ func TestColumnUpdateCommandSuccess(t *testing.T) {
28
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
29
+ if r.URL.Path != "/boards/board-123/columns/col-456" {
30
+ t.Errorf("expected /boards/board-123/columns/col-456, got %s", r.URL.Path)
31
+ }
32
+ if r.Method != http.MethodPut {
33
+ t.Errorf("expected PUT, got %s", r.Method)
34
+ }
35
+
36
+ auth := r.Header.Get("Authorization")
37
+ if auth != "Bearer test-token" {
38
+ t.Errorf("expected Bearer test-token, got %s", auth)
39
+ }
40
+
41
+ body, _ := io.ReadAll(r.Body)
42
+ var payload map[string]api.UpdateColumnPayload
43
+ if err := json.Unmarshal(body, &payload); err != nil {
44
+ t.Fatalf("failed to unmarshal request body: %v", err)
45
+ }
46
+
47
+ columnPayload := payload["column"]
48
+ if columnPayload.Name != "Updated Column" {
49
+ t.Errorf("expected name 'Updated Column', got %s", columnPayload.Name)
50
+ }
51
+
52
+ w.WriteHeader(http.StatusNoContent)
53
+ }))
54
+ defer server.Close()
55
+
56
+ client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
57
+ testApp := &app.App{Client: client}
58
+
59
+ cmd := newTestUpdateColumnCmd()
60
+ cmd.SetContext(testApp.ToContext(context.Background()))
61
+ cmd.ParseFlags([]string{"--name", "Updated Column"})
62
+
63
+ if err := handleUpdateColumn(cmd, "col-456"); err != nil {
64
+ t.Fatalf("handleUpdateColumn failed: %v", err)
65
+ }
66
+ }
67
+
68
+ func TestColumnUpdateCommandWithColor(t *testing.T) {
69
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
70
+ if r.Method != http.MethodPut {
71
+ t.Errorf("expected PUT, got %s", r.Method)
72
+ }
73
+
74
+ body, _ := io.ReadAll(r.Body)
75
+ var payload map[string]api.UpdateColumnPayload
76
+ json.Unmarshal(body, &payload)
77
+
78
+ columnPayload := payload["column"]
79
+ if columnPayload.Name != "Progress" {
80
+ t.Errorf("expected name 'Progress', got %s", columnPayload.Name)
81
+ }
82
+ if columnPayload.Color == nil {
83
+ t.Error("expected Color to be set")
84
+ } else if *columnPayload.Color != api.Lime {
85
+ t.Errorf("expected color Lime, got %s", *columnPayload.Color)
86
+ }
87
+
88
+ w.WriteHeader(http.StatusNoContent)
89
+ }))
90
+ defer server.Close()
91
+
92
+ client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
93
+ testApp := &app.App{Client: client}
94
+
95
+ cmd := newTestUpdateColumnCmd()
96
+ cmd.SetContext(testApp.ToContext(context.Background()))
97
+ cmd.ParseFlags([]string{"--name", "Progress", "--color", "lime"})
98
+
99
+ if err := handleUpdateColumn(cmd, "col-456"); err != nil {
100
+ t.Fatalf("handleUpdateColumn failed: %v", err)
101
+ }
102
+ }
103
+
104
+ func TestColumnUpdateCommandInvalidColor(t *testing.T) {
105
+ client := testutil.NewTestClient("http://localhost", "", "board-123", "test-token")
106
+ testApp := &app.App{Client: client}
107
+
108
+ cmd := newTestUpdateColumnCmd()
109
+ cmd.SetContext(testApp.ToContext(context.Background()))
110
+ cmd.ParseFlags([]string{"--color", "invalid-color"})
111
+
112
+ err := handleUpdateColumn(cmd, "col-456")
113
+ if err == nil {
114
+ t.Errorf("expected error for invalid color")
115
+ }
116
+ errMsg := err.Error()
117
+ if errMsg != "invalid color 'invalid-color'. Available colors: blue, gray, tan, yellow, lime, aqua, violet, purple, pink" {
118
+ t.Errorf("expected invalid color error, got %v", err)
119
+ }
120
+ }
121
+
122
+ func TestColumnUpdateCommandNoFlags(t *testing.T) {
123
+ client := testutil.NewTestClient("http://localhost", "", "board-123", "test-token")
124
+ testApp := &app.App{Client: client}
125
+
126
+ cmd := newTestUpdateColumnCmd()
127
+ cmd.SetContext(testApp.ToContext(context.Background()))
128
+
129
+ err := handleUpdateColumn(cmd, "col-456")
130
+ if err == nil {
131
+ t.Errorf("expected error when no flags provided")
132
+ }
133
+ if err.Error() != "at least one flag must be provided (--name or --color)" {
134
+ t.Errorf("expected flag requirement error, got %v", err)
135
+ }
136
+ }
137
+
138
+ func TestColumnUpdateCommandNotFound(t *testing.T) {
139
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
140
+ w.WriteHeader(http.StatusNotFound)
141
+ w.Write([]byte("Column not found"))
142
+ }))
143
+ defer server.Close()
144
+
145
+ client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
146
+ testApp := &app.App{Client: client}
147
+
148
+ cmd := newTestUpdateColumnCmd()
149
+ cmd.SetContext(testApp.ToContext(context.Background()))
150
+ cmd.ParseFlags([]string{"--name", "Updated Column"})
151
+
152
+ err := handleUpdateColumn(cmd, "nonexistent-col")
153
+ if err == nil {
154
+ t.Errorf("expected error for column not found")
155
+ }
156
+ if err.Error() != "updating column: unexpected status code 404: Column not found" {
157
+ t.Errorf("expected column not found error, got %v", err)
158
+ }
159
+ }
160
+
161
+ func TestColumnUpdateCommandAPIError(t *testing.T) {
162
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
163
+ w.WriteHeader(http.StatusInternalServerError)
164
+ w.Write([]byte("Internal Server Error"))
165
+ }))
166
+ defer server.Close()
167
+
168
+ client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
169
+ testApp := &app.App{Client: client}
170
+
171
+ cmd := newTestUpdateColumnCmd()
172
+ cmd.SetContext(testApp.ToContext(context.Background()))
173
+ cmd.ParseFlags([]string{"--name", "Updated Column"})
174
+
175
+ err := handleUpdateColumn(cmd, "col-456")
176
+ if err == nil {
177
+ t.Errorf("expected error for API failure")
178
+ }
179
+ if err.Error() != "updating column: unexpected status code 500: Internal Server Error" {
180
+ t.Errorf("expected API error, got %v", err)
181
+ }
182
+ }
183
+
184
+ func TestColumnUpdateCommandNoClient(t *testing.T) {
185
+ testApp := &app.App{}
186
+
187
+ cmd := newTestUpdateColumnCmd()
188
+ cmd.SetContext(testApp.ToContext(context.Background()))
189
+ cmd.ParseFlags([]string{"--name", "Updated Column"})
190
+
191
+ err := handleUpdateColumn(cmd, "col-456")
192
+ if err == nil {
193
+ t.Errorf("expected error when client not available")
194
+ }
195
+ if err.Error() != "API client not available" {
196
+ t.Errorf("expected 'client not available' error, got %v", err)
197
+ }
198
+ }
@@ -39,7 +39,7 @@ func handleCreateComment(cmd *cobra.Command, cardNumber string) error {
39
39
  return fmt.Errorf("creating comment: %w", err)
40
40
  }
41
41
 
42
- fmt.Printf("✓ Comment created successfully\n")
42
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Comment created successfully\n")
43
43
  return nil
44
44
  }
45
45
 
@@ -37,7 +37,7 @@ func handleDeleteComment(cmd *cobra.Command, cardNumber, commentID string) error
37
37
  return fmt.Errorf("deleting comment: %w", err)
38
38
  }
39
39
 
40
- fmt.Printf("✓ Comment deleted successfully\n")
40
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Comment deleted successfully\n")
41
41
  return nil
42
42
  }
43
43
 
@@ -39,7 +39,7 @@ func handleUpdateComment(cmd *cobra.Command, cardNumber, commentID string) error
39
39
  return fmt.Errorf("updating comment: %w", err)
40
40
  }
41
41
 
42
- fmt.Printf("✓ Comment updated successfully (id: %s)\n", comment.ID)
42
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Comment updated successfully (id: %s)\n", comment.ID)
43
43
  return nil
44
44
  }
45
45
 
package/cmd/login.go CHANGED
@@ -25,10 +25,10 @@ var loginCmd = &cobra.Command{
25
25
  func handleLogin(cmd *cobra.Command) error {
26
26
  token, isSet := os.LookupEnv("FIZZY_ACCESS_TOKEN")
27
27
  if !isSet || token == "" {
28
- return printAuthInstructions()
28
+ return printAuthInstructions(cmd)
29
29
  }
30
30
 
31
- fmt.Printf("✓ Authenticated with access token: %s\n", token[:6]+"...")
31
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Authenticated with access token: %s\n", token[:6]+"...")
32
32
 
33
33
  a := app.FromContext(cmd.Context())
34
34
  if a == nil || a.Client == nil {
@@ -40,12 +40,12 @@ func handleLogin(cmd *cobra.Command) error {
40
40
  return fmt.Errorf("fetching identity: %w", err)
41
41
  }
42
42
 
43
- selected, err := chooseAccount(identity.Accounts)
43
+ selected, err := chooseAccount(cmd, identity.Accounts)
44
44
  if err != nil {
45
45
  return err
46
46
  }
47
47
 
48
- fmt.Printf("\nSelected account: %s (%s)\n", selected.Name, selected.Slug)
48
+ fmt.Fprintf(cmd.OutOrStdout(), "\nSelected account: %s (%s)\n", selected.Name, selected.Slug)
49
49
 
50
50
  // Save the selected account and current user ID to config
51
51
  a.Config.SelectedAccount = selected.Slug
@@ -57,22 +57,22 @@ func handleLogin(cmd *cobra.Command) error {
57
57
  return nil
58
58
  }
59
59
 
60
- func chooseAccount(accounts []api.Account) (api.Account, error) {
60
+ func chooseAccount(cmd *cobra.Command, accounts []api.Account) (api.Account, error) {
61
61
  if len(accounts) == 1 {
62
62
  selected := accounts[0]
63
63
  return selected, nil
64
64
  }
65
65
 
66
- fmt.Println("\nAvailable accounts:")
66
+ fmt.Fprintf(cmd.OutOrStdout(), "\nAvailable accounts:\n")
67
67
  return ui.SelectAccount(accounts)
68
68
  }
69
69
 
70
- func printAuthInstructions() error {
71
- fmt.Println("To authenticate with Fizzy's API you need an access token.")
72
- fmt.Printf("\nGo to https://app.fizzy.do/<account_slug>/my/access_tokens and follow the instructions...\n")
73
- fmt.Println("(Replace <account_slug> with your account slug)")
74
- fmt.Printf("\nThen export it as an environment variable in your shell, with the name FIZZY_ACCESS_TOKEN\n")
75
- fmt.Println("And re-run this command.")
70
+ func printAuthInstructions(cmd *cobra.Command) error {
71
+ fmt.Fprintf(cmd.OutOrStdout(), "To authenticate with Fizzy's API you need an access token.\n")
72
+ fmt.Fprintf(cmd.OutOrStdout(), "\nGo to https://app.fizzy.do/<account_slug>/my/access_tokens and follow the instructions...\n")
73
+ fmt.Fprintf(cmd.OutOrStdout(), "(Replace <account_slug> with your account slug)\n")
74
+ fmt.Fprintf(cmd.OutOrStdout(), "\nThen export it as an environment variable in your shell, with the name FIZZY_ACCESS_TOKEN\n")
75
+ fmt.Fprintf(cmd.OutOrStdout(), "And re-run this command.\n")
76
76
  return nil
77
77
  }
78
78
 
@@ -35,7 +35,7 @@ func handleUnreadNotification(cmd *cobra.Command, notificationID string) error {
35
35
  return fmt.Errorf("marking notification as unread: %w", err)
36
36
  }
37
37
 
38
- fmt.Printf("✓ Notification marked as unread successfully\n")
38
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Notification marked as unread successfully\n")
39
39
  return nil
40
40
  }
41
41
 
package/cmd/reaction.go CHANGED
@@ -4,8 +4,8 @@ import "github.com/spf13/cobra"
4
4
 
5
5
  var reactionCmd = &cobra.Command{
6
6
  Use: "reaction",
7
- Short: "Manage comment reactions",
8
- Long: `Manage reactions on comments in Fizzy`,
7
+ Short: "Manage reactions",
8
+ Long: `Manage reactions on cards and comments in Fizzy`,
9
9
  }
10
10
 
11
11
  func init() {
@@ -37,7 +37,7 @@ func handleCreateReaction(cmd *cobra.Command, cardNumber, commentID, emoji strin
37
37
  return fmt.Errorf("creating reaction: %w", err)
38
38
  }
39
39
 
40
- fmt.Printf("✓ Reaction %s created successfully\n", emoji)
40
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Reaction %s created successfully\n", emoji)
41
41
  return nil
42
42
  }
43
43
 
@@ -37,7 +37,7 @@ func handleDeleteReaction(cmd *cobra.Command, cardNumber, commentID, reactionID
37
37
  return fmt.Errorf("deleting reaction: %w", err)
38
38
  }
39
39
 
40
- fmt.Printf("✓ Reaction deleted successfully\n")
40
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Reaction deleted successfully\n")
41
41
  return nil
42
42
  }
43
43
 
@@ -40,7 +40,7 @@ func handleCreateStep(cmd *cobra.Command, cardNumber string) error {
40
40
  return fmt.Errorf("creating step: %w", err)
41
41
  }
42
42
 
43
- fmt.Printf("✓ Step created successfully\n")
43
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Step created successfully\n")
44
44
  return nil
45
45
  }
46
46
 
@@ -37,7 +37,7 @@ func handleDeleteStep(cmd *cobra.Command, cardNumber, stepID string) error {
37
37
  return fmt.Errorf("deleting step: %w", err)
38
38
  }
39
39
 
40
- fmt.Printf("✓ Step deleted successfully\n")
40
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Step deleted successfully\n")
41
41
  return nil
42
42
  }
43
43
 
@@ -54,7 +54,7 @@ func handleUpdateStep(cmd *cobra.Command, cardNumber, stepID string) error {
54
54
  return fmt.Errorf("updating step: %w", err)
55
55
  }
56
56
 
57
- fmt.Printf("✓ Step updated successfully (id: %s)\n", step.ID)
57
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ Step updated successfully (id: %s)\n", step.ID)
58
58
  return nil
59
59
  }
60
60
 
package/cmd/user.go ADDED
@@ -0,0 +1,22 @@
1
+ // Package cmd
2
+ package cmd
3
+
4
+ import (
5
+ "github.com/spf13/cobra"
6
+ )
7
+
8
+ var userCmd = &cobra.Command{
9
+ Use: "user",
10
+ Short: "Manage users",
11
+ Long: `Manage users in your account.
12
+
13
+ Use subcommands to list, view, or manage users:
14
+ fizzy user list List all users
15
+ fizzy user show <id> Show user details
16
+ fizzy user update <id> Update user settings
17
+ fizzy user deactivate <id> Deactivate a user`,
18
+ }
19
+
20
+ func init() {
21
+ rootCmd.AddCommand(userCmd)
22
+ }
@@ -0,0 +1,40 @@
1
+ package cmd
2
+
3
+ import (
4
+ "context"
5
+ "fmt"
6
+
7
+ "github.com/rogeriopvl/fizzy/internal/app"
8
+ "github.com/spf13/cobra"
9
+ )
10
+
11
+ var userDeactivateCmd = &cobra.Command{
12
+ Use: "deactivate <user_id>",
13
+ Short: "Deactivate a user",
14
+ Long: `Deactivate a user. Only account administrators can deactivate users.`,
15
+ Args: cobra.ExactArgs(1),
16
+ Run: func(cmd *cobra.Command, args []string) {
17
+ if err := handleDeactivateUser(cmd, args[0]); err != nil {
18
+ fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
19
+ }
20
+ },
21
+ }
22
+
23
+ func handleDeactivateUser(cmd *cobra.Command, userID string) error {
24
+ a := app.FromContext(cmd.Context())
25
+ if a == nil || a.Client == nil {
26
+ return fmt.Errorf("API client not available")
27
+ }
28
+
29
+ err := a.Client.DeleteUser(context.Background(), userID)
30
+ if err != nil {
31
+ return fmt.Errorf("deactivating user: %w", err)
32
+ }
33
+
34
+ fmt.Fprintf(cmd.OutOrStdout(), "✓ User '%s' deactivated successfully\n", userID)
35
+ return nil
36
+ }
37
+
38
+ func init() {
39
+ userCmd.AddCommand(userDeactivateCmd)
40
+ }