fizzy-cli 0.8.0 → 1.0.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 (159) hide show
  1. package/.golangci.yml +56 -0
  2. package/IMPLEMENTATION_PLAN.md +58 -0
  3. package/docs/API.md +89 -0
  4. package/package.json +2 -1
  5. package/.env +0 -1
  6. package/.github/workflows/release.yml +0 -29
  7. package/.github/workflows/tests.yml +0 -24
  8. package/AGENTS.md +0 -33
  9. package/CHANGELOG.md +0 -194
  10. package/Makefile +0 -43
  11. package/bin/fizzy +0 -0
  12. package/cmd/account.go +0 -14
  13. package/cmd/account_list.go +0 -44
  14. package/cmd/account_list_test.go +0 -118
  15. package/cmd/board.go +0 -49
  16. package/cmd/board_create.go +0 -59
  17. package/cmd/board_create_test.go +0 -141
  18. package/cmd/board_delete.go +0 -40
  19. package/cmd/board_delete_test.go +0 -121
  20. package/cmd/board_list.go +0 -44
  21. package/cmd/board_list_test.go +0 -115
  22. package/cmd/board_show.go +0 -40
  23. package/cmd/board_show_test.go +0 -113
  24. package/cmd/board_test.go +0 -92
  25. package/cmd/board_update.go +0 -72
  26. package/cmd/board_update_test.go +0 -233
  27. package/cmd/card.go +0 -24
  28. package/cmd/card_assign.go +0 -55
  29. package/cmd/card_assign_test.go +0 -130
  30. package/cmd/card_close.go +0 -46
  31. package/cmd/card_close_test.go +0 -92
  32. package/cmd/card_create.go +0 -72
  33. package/cmd/card_create_test.go +0 -186
  34. package/cmd/card_delete.go +0 -46
  35. package/cmd/card_delete_test.go +0 -92
  36. package/cmd/card_golden.go +0 -46
  37. package/cmd/card_golden_test.go +0 -92
  38. package/cmd/card_list.go +0 -114
  39. package/cmd/card_list_test.go +0 -373
  40. package/cmd/card_not_now.go +0 -46
  41. package/cmd/card_not_now_test.go +0 -92
  42. package/cmd/card_reaction.go +0 -13
  43. package/cmd/card_reaction_create.go +0 -46
  44. package/cmd/card_reaction_create_test.go +0 -148
  45. package/cmd/card_reaction_delete.go +0 -46
  46. package/cmd/card_reaction_delete_test.go +0 -112
  47. package/cmd/card_reaction_list.go +0 -51
  48. package/cmd/card_reaction_list_test.go +0 -127
  49. package/cmd/card_reopen.go +0 -46
  50. package/cmd/card_reopen_test.go +0 -92
  51. package/cmd/card_show.go +0 -46
  52. package/cmd/card_show_test.go +0 -92
  53. package/cmd/card_tag.go +0 -51
  54. package/cmd/card_tag_test.go +0 -112
  55. package/cmd/card_triage.go +0 -46
  56. package/cmd/card_ungolden.go +0 -46
  57. package/cmd/card_ungolden_test.go +0 -92
  58. package/cmd/card_untriage.go +0 -46
  59. package/cmd/card_untriage_test.go +0 -92
  60. package/cmd/card_unwatch.go +0 -46
  61. package/cmd/card_unwatch_test.go +0 -92
  62. package/cmd/card_update.go +0 -82
  63. package/cmd/card_update_test.go +0 -149
  64. package/cmd/card_watch.go +0 -46
  65. package/cmd/card_watch_test.go +0 -92
  66. package/cmd/column.go +0 -14
  67. package/cmd/column_create.go +0 -79
  68. package/cmd/column_create_test.go +0 -178
  69. package/cmd/column_delete.go +0 -40
  70. package/cmd/column_delete_test.go +0 -121
  71. package/cmd/column_list.go +0 -44
  72. package/cmd/column_list_test.go +0 -138
  73. package/cmd/column_show.go +0 -40
  74. package/cmd/column_show_test.go +0 -111
  75. package/cmd/column_update.go +0 -67
  76. package/cmd/column_update_test.go +0 -198
  77. package/cmd/comment.go +0 -14
  78. package/cmd/comment_create.go +0 -51
  79. package/cmd/comment_create_test.go +0 -129
  80. package/cmd/comment_delete.go +0 -46
  81. package/cmd/comment_delete_test.go +0 -92
  82. package/cmd/comment_list.go +0 -51
  83. package/cmd/comment_list_test.go +0 -132
  84. package/cmd/comment_show.go +0 -46
  85. package/cmd/comment_show_test.go +0 -104
  86. package/cmd/comment_update.go +0 -51
  87. package/cmd/comment_update_test.go +0 -130
  88. package/cmd/login.go +0 -81
  89. package/cmd/login_test.go +0 -98
  90. package/cmd/notification.go +0 -14
  91. package/cmd/notification_list.go +0 -69
  92. package/cmd/notification_list_test.go +0 -288
  93. package/cmd/notification_read.go +0 -51
  94. package/cmd/notification_read_all.go +0 -38
  95. package/cmd/notification_read_all_test.go +0 -75
  96. package/cmd/notification_read_test.go +0 -138
  97. package/cmd/notification_unread.go +0 -44
  98. package/cmd/notification_unread_test.go +0 -99
  99. package/cmd/reaction.go +0 -13
  100. package/cmd/reaction_create.go +0 -46
  101. package/cmd/reaction_create_test.go +0 -113
  102. package/cmd/reaction_delete.go +0 -46
  103. package/cmd/reaction_delete_test.go +0 -92
  104. package/cmd/reaction_list.go +0 -51
  105. package/cmd/reaction_list_test.go +0 -125
  106. package/cmd/root.go +0 -38
  107. package/cmd/step.go +0 -14
  108. package/cmd/step_create.go +0 -53
  109. package/cmd/step_create_test.go +0 -171
  110. package/cmd/step_delete.go +0 -46
  111. package/cmd/step_delete_test.go +0 -92
  112. package/cmd/step_update.go +0 -66
  113. package/cmd/step_update_test.go +0 -190
  114. package/cmd/tag.go +0 -15
  115. package/cmd/tag_list.go +0 -47
  116. package/cmd/tag_list_test.go +0 -109
  117. package/cmd/use.go +0 -85
  118. package/cmd/use_test.go +0 -186
  119. package/cmd/user.go +0 -22
  120. package/cmd/user_deactivate.go +0 -40
  121. package/cmd/user_deactivate_test.go +0 -121
  122. package/cmd/user_list.go +0 -44
  123. package/cmd/user_list_test.go +0 -126
  124. package/cmd/user_show.go +0 -40
  125. package/cmd/user_show_test.go +0 -110
  126. package/cmd/user_update.go +0 -71
  127. package/cmd/user_update_test.go +0 -177
  128. package/go.mod +0 -31
  129. package/go.sum +0 -53
  130. package/internal/api/boards.go +0 -93
  131. package/internal/api/cards.go +0 -322
  132. package/internal/api/client.go +0 -99
  133. package/internal/api/columns.go +0 -113
  134. package/internal/api/comments.go +0 -108
  135. package/internal/api/identity.go +0 -24
  136. package/internal/api/notifications.go +0 -89
  137. package/internal/api/reactions.go +0 -130
  138. package/internal/api/steps.go +0 -101
  139. package/internal/api/tags.go +0 -24
  140. package/internal/api/types.go +0 -195
  141. package/internal/api/users.go +0 -75
  142. package/internal/app/app.go +0 -49
  143. package/internal/colors/colors.go +0 -32
  144. package/internal/config/config.go +0 -70
  145. package/internal/testutil/client.go +0 -26
  146. package/internal/ui/account_list.go +0 -14
  147. package/internal/ui/account_selector.go +0 -63
  148. package/internal/ui/board_list.go +0 -14
  149. package/internal/ui/board_show.go +0 -17
  150. package/internal/ui/card_list.go +0 -14
  151. package/internal/ui/card_show.go +0 -23
  152. package/internal/ui/column_list.go +0 -28
  153. package/internal/ui/column_show.go +0 -16
  154. package/internal/ui/comment_list.go +0 -25
  155. package/internal/ui/format.go +0 -27
  156. package/internal/ui/notification_list.go +0 -27
  157. package/internal/ui/reaction_list.go +0 -14
  158. package/internal/ui/user_list.go +0 -19
  159. package/internal/ui/user_show.go +0 -23
@@ -1,92 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "net/http"
6
- "net/http/httptest"
7
- "testing"
8
-
9
- "github.com/rogeriopvl/fizzy/internal/app"
10
- "github.com/rogeriopvl/fizzy/internal/testutil"
11
- )
12
-
13
- func TestCardUntriagedCommandSuccess(t *testing.T) {
14
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
15
- if r.URL.Path != "/cards/123/triage" {
16
- t.Errorf("expected /cards/123/triage, got %s", r.URL.Path)
17
- }
18
- if r.Method != http.MethodDelete {
19
- t.Errorf("expected DELETE, got %s", r.Method)
20
- }
21
-
22
- auth := r.Header.Get("Authorization")
23
- if auth != "Bearer test-token" {
24
- t.Errorf("expected Bearer test-token, got %s", auth)
25
- }
26
-
27
- w.WriteHeader(http.StatusNoContent)
28
- }))
29
- defer server.Close()
30
-
31
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
32
- testApp := &app.App{Client: client}
33
-
34
- cmd := cardUntriagedCmd
35
- cmd.SetContext(testApp.ToContext(context.Background()))
36
-
37
- if err := handleUntriagedCard(cmd, "123"); err != nil {
38
- t.Fatalf("handleUntriagedCard failed: %v", err)
39
- }
40
- }
41
-
42
- func TestCardUntriagedCommandInvalidCardNumber(t *testing.T) {
43
- testApp := &app.App{}
44
-
45
- cmd := cardUntriagedCmd
46
- cmd.SetContext(testApp.ToContext(context.Background()))
47
-
48
- err := handleUntriagedCard(cmd, "not-a-number")
49
- if err == nil {
50
- t.Errorf("expected error for invalid card number")
51
- }
52
- if err.Error() != "invalid card number: strconv.Atoi: parsing \"not-a-number\": invalid syntax" {
53
- t.Errorf("expected invalid card number error, got %v", err)
54
- }
55
- }
56
-
57
- func TestCardUntriagedCommandNoClient(t *testing.T) {
58
- testApp := &app.App{}
59
-
60
- cmd := cardUntriagedCmd
61
- cmd.SetContext(testApp.ToContext(context.Background()))
62
-
63
- err := handleUntriagedCard(cmd, "123")
64
- if err == nil {
65
- t.Errorf("expected error when client not available")
66
- }
67
- if err.Error() != "API client not available" {
68
- t.Errorf("expected 'client not available' error, got %v", err)
69
- }
70
- }
71
-
72
- func TestCardUntriagedCommandAPIError(t *testing.T) {
73
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
74
- w.WriteHeader(http.StatusInternalServerError)
75
- w.Write([]byte("Internal Server Error"))
76
- }))
77
- defer server.Close()
78
-
79
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
80
- testApp := &app.App{Client: client}
81
-
82
- cmd := cardUntriagedCmd
83
- cmd.SetContext(testApp.ToContext(context.Background()))
84
-
85
- err := handleUntriagedCard(cmd, "123")
86
- if err == nil {
87
- t.Errorf("expected error for API failure")
88
- }
89
- if err.Error() != "sending card back to triage: unexpected status code 500: Internal Server Error" {
90
- t.Errorf("expected API error, got %v", err)
91
- }
92
- }
@@ -1,46 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "fmt"
6
- "strconv"
7
-
8
- "github.com/rogeriopvl/fizzy/internal/app"
9
- "github.com/spf13/cobra"
10
- )
11
-
12
- var cardUnwatchCmd = &cobra.Command{
13
- Use: "unwatch <card_number>",
14
- Short: "Unsubscribe from card notifications",
15
- Long: `Unsubscribe from notifications for an existing card`,
16
- Args: cobra.ExactArgs(1),
17
- Run: func(cmd *cobra.Command, args []string) {
18
- if err := handleUnwatchCard(cmd, args[0]); err != nil {
19
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
20
- }
21
- },
22
- }
23
-
24
- func handleUnwatchCard(cmd *cobra.Command, cardNumber string) error {
25
- cardNum, err := strconv.Atoi(cardNumber)
26
- if err != nil {
27
- return fmt.Errorf("invalid card number: %w", err)
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
- _, err = a.Client.DeleteCardWatch(context.Background(), cardNum)
36
- if err != nil {
37
- return fmt.Errorf("unwatching card: %w", err)
38
- }
39
-
40
- fmt.Fprintf(cmd.OutOrStdout(), "✓ Stopped watching card #%d\n", cardNum)
41
- return nil
42
- }
43
-
44
- func init() {
45
- cardCmd.AddCommand(cardUnwatchCmd)
46
- }
@@ -1,92 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "net/http"
6
- "net/http/httptest"
7
- "testing"
8
-
9
- "github.com/rogeriopvl/fizzy/internal/app"
10
- "github.com/rogeriopvl/fizzy/internal/testutil"
11
- )
12
-
13
- func TestCardUnwatchCommandSuccess(t *testing.T) {
14
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
15
- if r.URL.Path != "/cards/123/watch" {
16
- t.Errorf("expected /cards/123/watch, got %s", r.URL.Path)
17
- }
18
- if r.Method != http.MethodDelete {
19
- t.Errorf("expected DELETE, got %s", r.Method)
20
- }
21
-
22
- auth := r.Header.Get("Authorization")
23
- if auth != "Bearer test-token" {
24
- t.Errorf("expected Bearer test-token, got %s", auth)
25
- }
26
-
27
- w.WriteHeader(http.StatusNoContent)
28
- }))
29
- defer server.Close()
30
-
31
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
32
- testApp := &app.App{Client: client}
33
-
34
- cmd := cardUnwatchCmd
35
- cmd.SetContext(testApp.ToContext(context.Background()))
36
-
37
- if err := handleUnwatchCard(cmd, "123"); err != nil {
38
- t.Fatalf("handleUnwatchCard failed: %v", err)
39
- }
40
- }
41
-
42
- func TestCardUnwatchCommandInvalidCardNumber(t *testing.T) {
43
- testApp := &app.App{}
44
-
45
- cmd := cardUnwatchCmd
46
- cmd.SetContext(testApp.ToContext(context.Background()))
47
-
48
- err := handleUnwatchCard(cmd, "not-a-number")
49
- if err == nil {
50
- t.Errorf("expected error for invalid card number")
51
- }
52
- if err.Error() != "invalid card number: strconv.Atoi: parsing \"not-a-number\": invalid syntax" {
53
- t.Errorf("expected invalid card number error, got %v", err)
54
- }
55
- }
56
-
57
- func TestCardUnwatchCommandNoClient(t *testing.T) {
58
- testApp := &app.App{}
59
-
60
- cmd := cardUnwatchCmd
61
- cmd.SetContext(testApp.ToContext(context.Background()))
62
-
63
- err := handleUnwatchCard(cmd, "123")
64
- if err == nil {
65
- t.Errorf("expected error when client not available")
66
- }
67
- if err.Error() != "API client not available" {
68
- t.Errorf("expected 'client not available' error, got %v", err)
69
- }
70
- }
71
-
72
- func TestCardUnwatchCommandAPIError(t *testing.T) {
73
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
74
- w.WriteHeader(http.StatusInternalServerError)
75
- w.Write([]byte("Internal Server Error"))
76
- }))
77
- defer server.Close()
78
-
79
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
80
- testApp := &app.App{Client: client}
81
-
82
- cmd := cardUnwatchCmd
83
- cmd.SetContext(testApp.ToContext(context.Background()))
84
-
85
- err := handleUnwatchCard(cmd, "123")
86
- if err == nil {
87
- t.Errorf("expected error for API failure")
88
- }
89
- if err.Error() != "unwatching card: unexpected status code 500: Internal Server Error" {
90
- t.Errorf("expected API error, got %v", err)
91
- }
92
- }
@@ -1,82 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "fmt"
6
- "strconv"
7
-
8
- "github.com/rogeriopvl/fizzy/internal/api"
9
- "github.com/rogeriopvl/fizzy/internal/app"
10
- "github.com/spf13/cobra"
11
- )
12
-
13
- var cardUpdateCmd = &cobra.Command{
14
- Use: "update <card_number>",
15
- Short: "Update a card",
16
- Long: `Update an existing card's details`,
17
- Args: cobra.ExactArgs(1),
18
- Run: func(cmd *cobra.Command, args []string) {
19
- if err := handleUpdateCard(cmd, args[0]); err != nil {
20
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
21
- }
22
- },
23
- }
24
-
25
- func handleUpdateCard(cmd *cobra.Command, cardNumber string) error {
26
- cardNum, err := strconv.Atoi(cardNumber)
27
- if err != nil {
28
- return fmt.Errorf("invalid card number: %w", err)
29
- }
30
-
31
- a := app.FromContext(cmd.Context())
32
- if a == nil || a.Client == nil {
33
- return fmt.Errorf("API client not available")
34
- }
35
-
36
- // Build payload only with flags that were explicitly set
37
- var payload api.UpdateCardPayload
38
- hasChanges := false
39
-
40
- if cmd.Flags().Changed("title") {
41
- payload.Title, _ = cmd.Flags().GetString("title")
42
- hasChanges = true
43
- }
44
- if cmd.Flags().Changed("description") {
45
- payload.Description, _ = cmd.Flags().GetString("description")
46
- hasChanges = true
47
- }
48
- if cmd.Flags().Changed("status") {
49
- payload.Status, _ = cmd.Flags().GetString("status")
50
- hasChanges = true
51
- }
52
- if cmd.Flags().Changed("tag-id") {
53
- payload.TagIDS, _ = cmd.Flags().GetStringSlice("tag-id")
54
- hasChanges = true
55
- }
56
- if cmd.Flags().Changed("last-active-at") {
57
- payload.LastActiveAt, _ = cmd.Flags().GetString("last-active-at")
58
- hasChanges = true
59
- }
60
-
61
- if !hasChanges {
62
- return fmt.Errorf("must provide at least one flag to update (--title, --description, --status, --tag-id, or --last-active-at)")
63
- }
64
-
65
- card, err := a.Client.PutCard(context.Background(), cardNum, payload)
66
- if err != nil {
67
- return fmt.Errorf("updating card: %w", err)
68
- }
69
-
70
- fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d updated successfully\n", card.Number)
71
- return nil
72
- }
73
-
74
- func init() {
75
- cardUpdateCmd.Flags().StringP("title", "t", "", "Card title")
76
- cardUpdateCmd.Flags().StringP("description", "d", "", "Card description")
77
- cardUpdateCmd.Flags().String("status", "", "Card status")
78
- cardUpdateCmd.Flags().StringSlice("tag-id", []string{}, "Tag ID (can be used multiple times)")
79
- cardUpdateCmd.Flags().String("last-active-at", "", "Last active timestamp")
80
-
81
- cardCmd.AddCommand(cardUpdateCmd)
82
- }
@@ -1,149 +0,0 @@
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
- "github.com/spf13/cobra"
14
- )
15
-
16
- func TestCardUpdateCommand(t *testing.T) {
17
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
18
- if r.URL.Path != "/cards/1" {
19
- t.Errorf("expected /cards/1, got %s", r.URL.Path)
20
- }
21
- if r.Method != http.MethodPut {
22
- t.Errorf("expected PUT, got %s", r.Method)
23
- }
24
-
25
- auth := r.Header.Get("Authorization")
26
- if auth != "Bearer test-token" {
27
- t.Errorf("expected Bearer test-token, got %s", auth)
28
- }
29
-
30
- w.Header().Set("Content-Type", "application/json")
31
- response := api.Card{
32
- ID: "card-123",
33
- Number: 1,
34
- Title: "Updated card title",
35
- Status: "published",
36
- Description: "Updated description",
37
- Tags: []string{"updated-tag"},
38
- Golden: false,
39
- CreatedAt: "2025-01-01T00:00:00Z",
40
- LastActiveAt: "2025-01-15T10:30:00Z",
41
- URL: "https://example.com/card/1",
42
- }
43
- json.NewEncoder(w).Encode(response)
44
- }))
45
- defer server.Close()
46
-
47
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
48
- testApp := &app.App{Client: client}
49
-
50
- cmd := cardUpdateCmd
51
- cmd.SetContext(testApp.ToContext(context.Background()))
52
- cmd.ParseFlags([]string{
53
- "--title", "Updated card title",
54
- "--description", "Updated description",
55
- "--status", "published",
56
- "--tag-id", "updated-tag",
57
- })
58
-
59
- if err := handleUpdateCard(cmd, "1"); err != nil {
60
- t.Fatalf("handleUpdateCard failed: %v", err)
61
- }
62
- }
63
-
64
- func TestCardUpdateCommandAPIError(t *testing.T) {
65
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
66
- w.WriteHeader(http.StatusNotFound)
67
- w.Write([]byte("Card not found"))
68
- }))
69
- defer server.Close()
70
-
71
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
72
- testApp := &app.App{Client: client}
73
-
74
- cmd := cardUpdateCmd
75
- cmd.SetContext(testApp.ToContext(context.Background()))
76
- cmd.ParseFlags([]string{
77
- "--title", "Updated card",
78
- })
79
-
80
- err := handleUpdateCard(cmd, "999")
81
- if err == nil {
82
- t.Errorf("expected error for API failure")
83
- }
84
- if err.Error() != "updating card: unexpected status code 404: Card not found" {
85
- t.Errorf("expected API error, got %v", err)
86
- }
87
- }
88
-
89
- func TestCardUpdateCommandNoClient(t *testing.T) {
90
- testApp := &app.App{}
91
-
92
- cmd := cardUpdateCmd
93
- cmd.SetContext(testApp.ToContext(context.Background()))
94
- cmd.ParseFlags([]string{
95
- "--title", "Updated card",
96
- })
97
-
98
- err := handleUpdateCard(cmd, "1")
99
- if err == nil {
100
- t.Errorf("expected error when client not available")
101
- }
102
- if err.Error() != "API client not available" {
103
- t.Errorf("expected 'client not available' error, got %v", err)
104
- }
105
- }
106
-
107
- func TestCardUpdateCommandInvalidCardNumber(t *testing.T) {
108
- testApp := &app.App{}
109
-
110
- cmd := cardUpdateCmd
111
- cmd.SetContext(testApp.ToContext(context.Background()))
112
- cmd.ParseFlags([]string{
113
- "--title", "Updated card",
114
- })
115
-
116
- err := handleUpdateCard(cmd, "not-a-number")
117
- if err == nil {
118
- t.Errorf("expected error for invalid card number")
119
- }
120
- if err.Error() != "invalid card number: strconv.Atoi: parsing \"not-a-number\": invalid syntax" {
121
- t.Errorf("expected invalid card number error, got %v", err)
122
- }
123
- }
124
-
125
- func TestCardUpdateCommandNoFlags(t *testing.T) {
126
- client := testutil.NewTestClient("http://localhost", "", "", "test-token")
127
- testApp := &app.App{Client: client}
128
-
129
- // Create a fresh command to avoid flag pollution from other tests
130
- cmd := &cobra.Command{
131
- Use: "update <card_number>",
132
- Args: cobra.ExactArgs(1),
133
- }
134
- cmd.Flags().String("title", "", "Card title")
135
- cmd.Flags().String("description", "", "Card description")
136
- cmd.Flags().String("status", "", "Card status")
137
- cmd.Flags().StringSlice("tag-id", []string{}, "Tag ID")
138
- cmd.Flags().String("last-active-at", "", "Last active timestamp")
139
-
140
- cmd.SetContext(testApp.ToContext(context.Background()))
141
-
142
- err := handleUpdateCard(cmd, "1")
143
- if err == nil {
144
- t.Errorf("expected error when no flags are provided")
145
- }
146
- if err.Error() != "must provide at least one flag to update (--title, --description, --status, --tag-id, or --last-active-at)" {
147
- t.Errorf("expected 'no flags' error, got %v", err)
148
- }
149
- }
package/cmd/card_watch.go DELETED
@@ -1,46 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "fmt"
6
- "strconv"
7
-
8
- "github.com/rogeriopvl/fizzy/internal/app"
9
- "github.com/spf13/cobra"
10
- )
11
-
12
- var cardWatchCmd = &cobra.Command{
13
- Use: "watch <card_number>",
14
- Short: "Subscribe to card notifications",
15
- Long: `Subscribe to notifications for an existing card`,
16
- Args: cobra.ExactArgs(1),
17
- Run: func(cmd *cobra.Command, args []string) {
18
- if err := handleWatchCard(cmd, args[0]); err != nil {
19
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
20
- }
21
- },
22
- }
23
-
24
- func handleWatchCard(cmd *cobra.Command, cardNumber string) error {
25
- cardNum, err := strconv.Atoi(cardNumber)
26
- if err != nil {
27
- return fmt.Errorf("invalid card number: %w", err)
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
- _, err = a.Client.PostCardWatch(context.Background(), cardNum)
36
- if err != nil {
37
- return fmt.Errorf("watching card: %w", err)
38
- }
39
-
40
- fmt.Fprintf(cmd.OutOrStdout(), "✓ Now watching card #%d\n", cardNum)
41
- return nil
42
- }
43
-
44
- func init() {
45
- cardCmd.AddCommand(cardWatchCmd)
46
- }
@@ -1,92 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "net/http"
6
- "net/http/httptest"
7
- "testing"
8
-
9
- "github.com/rogeriopvl/fizzy/internal/app"
10
- "github.com/rogeriopvl/fizzy/internal/testutil"
11
- )
12
-
13
- func TestCardWatchCommandSuccess(t *testing.T) {
14
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
15
- if r.URL.Path != "/cards/123/watch" {
16
- t.Errorf("expected /cards/123/watch, got %s", r.URL.Path)
17
- }
18
- if r.Method != http.MethodPost {
19
- t.Errorf("expected POST, got %s", r.Method)
20
- }
21
-
22
- auth := r.Header.Get("Authorization")
23
- if auth != "Bearer test-token" {
24
- t.Errorf("expected Bearer test-token, got %s", auth)
25
- }
26
-
27
- w.WriteHeader(http.StatusNoContent)
28
- }))
29
- defer server.Close()
30
-
31
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
32
- testApp := &app.App{Client: client}
33
-
34
- cmd := cardWatchCmd
35
- cmd.SetContext(testApp.ToContext(context.Background()))
36
-
37
- if err := handleWatchCard(cmd, "123"); err != nil {
38
- t.Fatalf("handleWatchCard failed: %v", err)
39
- }
40
- }
41
-
42
- func TestCardWatchCommandInvalidCardNumber(t *testing.T) {
43
- testApp := &app.App{}
44
-
45
- cmd := cardWatchCmd
46
- cmd.SetContext(testApp.ToContext(context.Background()))
47
-
48
- err := handleWatchCard(cmd, "not-a-number")
49
- if err == nil {
50
- t.Errorf("expected error for invalid card number")
51
- }
52
- if err.Error() != "invalid card number: strconv.Atoi: parsing \"not-a-number\": invalid syntax" {
53
- t.Errorf("expected invalid card number error, got %v", err)
54
- }
55
- }
56
-
57
- func TestCardWatchCommandNoClient(t *testing.T) {
58
- testApp := &app.App{}
59
-
60
- cmd := cardWatchCmd
61
- cmd.SetContext(testApp.ToContext(context.Background()))
62
-
63
- err := handleWatchCard(cmd, "123")
64
- if err == nil {
65
- t.Errorf("expected error when client not available")
66
- }
67
- if err.Error() != "API client not available" {
68
- t.Errorf("expected 'client not available' error, got %v", err)
69
- }
70
- }
71
-
72
- func TestCardWatchCommandAPIError(t *testing.T) {
73
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
74
- w.WriteHeader(http.StatusInternalServerError)
75
- w.Write([]byte("Internal Server Error"))
76
- }))
77
- defer server.Close()
78
-
79
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
80
- testApp := &app.App{Client: client}
81
-
82
- cmd := cardWatchCmd
83
- cmd.SetContext(testApp.ToContext(context.Background()))
84
-
85
- err := handleWatchCard(cmd, "123")
86
- if err == nil {
87
- t.Errorf("expected error for API failure")
88
- }
89
- if err.Error() != "watching card: unexpected status code 500: Internal Server Error" {
90
- t.Errorf("expected API error, got %v", err)
91
- }
92
- }
package/cmd/column.go DELETED
@@ -1,14 +0,0 @@
1
- // Package cmd
2
- package cmd
3
-
4
- import "github.com/spf13/cobra"
5
-
6
- var columnCmd = &cobra.Command{
7
- Use: "column",
8
- Short: "Manage columns",
9
- Long: `Manage columns in Fizzy`,
10
- }
11
-
12
- func init() {
13
- rootCmd.AddCommand(columnCmd)
14
- }
@@ -1,79 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "fmt"
6
- "strings"
7
-
8
- "github.com/rogeriopvl/fizzy/internal/api"
9
- "github.com/rogeriopvl/fizzy/internal/app"
10
- "github.com/rogeriopvl/fizzy/internal/colors"
11
- "github.com/spf13/cobra"
12
- )
13
-
14
- func buildColorAliases() map[string]api.Color {
15
- aliases := make(map[string]api.Color)
16
- for _, colorDef := range colors.All {
17
- aliases[strings.ToLower(colorDef.Name)] = api.Color(colorDef.CSSValue)
18
- }
19
- return aliases
20
- }
21
-
22
- func getAvailableColors() string {
23
- var names []string
24
- for _, colorDef := range colors.All {
25
- names = append(names, strings.ToLower(colorDef.Name))
26
- }
27
- return strings.Join(names, ", ")
28
- }
29
-
30
- var columnCreateCmd = &cobra.Command{
31
- Use: "create",
32
- Short: "Create a new column",
33
- Long: `Create a new column in the selected board. Color is optional.`,
34
- Run: func(cmd *cobra.Command, args []string) {
35
- if err := handleCreateColumn(cmd); err != nil {
36
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
37
- }
38
- },
39
- }
40
-
41
- func handleCreateColumn(cmd *cobra.Command) error {
42
- a := app.FromContext(cmd.Context())
43
- if a == nil || a.Client == nil {
44
- return fmt.Errorf("API client not available")
45
- }
46
-
47
- // Read flag values directly from command
48
- name, _ := cmd.Flags().GetString("name")
49
- colorStr, _ := cmd.Flags().GetString("color")
50
-
51
- payload := api.CreateColumnPayload{
52
- Name: name,
53
- }
54
-
55
- if colorStr != "" {
56
- colorAliases := buildColorAliases()
57
- color, ok := colorAliases[colorStr]
58
- if !ok {
59
- return fmt.Errorf("invalid color '%s'. Available colors: %s", colorStr, getAvailableColors())
60
- }
61
- payload.Color = &color
62
- }
63
-
64
- _, err := a.Client.PostColumns(context.Background(), payload)
65
- if err != nil {
66
- return fmt.Errorf("creating column: %w", err)
67
- }
68
-
69
- fmt.Fprintf(cmd.OutOrStdout(), "✓ Column '%s' created successfully\n", name)
70
- return nil
71
- }
72
-
73
- func init() {
74
- columnCreateCmd.Flags().StringP("name", "n", "", "Column name (required)")
75
- columnCreateCmd.MarkFlagRequired("name")
76
- columnCreateCmd.Flags().String("color", "", fmt.Sprintf("Column color (optional). Available: %s", getAvailableColors()))
77
-
78
- columnCmd.AddCommand(columnCreateCmd)
79
- }