fizzy-cli 0.6.0 → 0.7.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.
- package/CHANGELOG.md +28 -0
- package/bin/fizzy +0 -0
- package/cmd/board.go +1 -1
- package/cmd/board_create.go +1 -1
- package/cmd/board_delete.go +40 -0
- package/cmd/board_delete_test.go +121 -0
- package/cmd/board_show.go +40 -0
- package/cmd/board_show_test.go +113 -0
- package/cmd/board_update.go +72 -0
- package/cmd/board_update_test.go +233 -0
- package/cmd/card_assign.go +1 -1
- package/cmd/card_close.go +1 -1
- package/cmd/card_create.go +1 -1
- package/cmd/card_delete.go +1 -1
- package/cmd/card_golden.go +1 -1
- package/cmd/card_not_now.go +1 -1
- package/cmd/card_reopen.go +1 -1
- package/cmd/card_tag.go +1 -1
- package/cmd/card_triage.go +1 -1
- package/cmd/card_ungolden.go +1 -1
- package/cmd/card_untriage.go +1 -1
- package/cmd/card_unwatch.go +1 -1
- package/cmd/card_update.go +1 -1
- package/cmd/card_watch.go +1 -1
- package/cmd/column_create.go +1 -1
- package/cmd/column_delete.go +40 -0
- package/cmd/column_delete_test.go +121 -0
- package/cmd/column_show.go +40 -0
- package/cmd/column_show_test.go +111 -0
- package/cmd/column_update.go +67 -0
- package/cmd/column_update_test.go +198 -0
- package/cmd/comment_create.go +2 -2
- package/cmd/comment_delete.go +1 -1
- package/cmd/comment_update.go +1 -1
- package/cmd/login.go +12 -12
- package/cmd/notification_unread.go +1 -1
- package/cmd/reaction_create.go +2 -2
- package/cmd/reaction_delete.go +1 -1
- package/cmd/step_create.go +2 -2
- package/cmd/step_delete.go +1 -1
- package/cmd/step_update.go +1 -1
- package/internal/api/boards.go +34 -0
- package/internal/api/columns.go +63 -0
- package/internal/api/comments.go +13 -4
- package/internal/api/reactions.go +12 -4
- package/internal/api/steps.go +12 -4
- package/internal/api/types.go +12 -0
- package/internal/ui/board_show.go +17 -0
- package/internal/ui/column_show.go +16 -0
- package/internal/ui/format.go +14 -1
- package/package.json +1 -1
- package/.env +0 -1
package/cmd/card_create.go
CHANGED
|
@@ -54,7 +54,7 @@ func handleCreateCard(cmd *cobra.Command) error {
|
|
|
54
54
|
return fmt.Errorf("creating card: %w", err)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
fmt.
|
|
57
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card '%s' created successfully\n", title)
|
|
58
58
|
return nil
|
|
59
59
|
}
|
|
60
60
|
|
package/cmd/card_delete.go
CHANGED
|
@@ -37,7 +37,7 @@ func handleDeleteCard(cmd *cobra.Command, cardNumber string) error {
|
|
|
37
37
|
return fmt.Errorf("deleting card: %w", err)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
fmt.
|
|
40
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d deleted successfully\n", cardNum)
|
|
41
41
|
return nil
|
|
42
42
|
}
|
|
43
43
|
|
package/cmd/card_golden.go
CHANGED
|
@@ -37,7 +37,7 @@ func handleGoldenCard(cmd *cobra.Command, cardNumber string) error {
|
|
|
37
37
|
return fmt.Errorf("marking card as golden: %w", err)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
fmt.
|
|
40
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d marked as golden\n", cardNum)
|
|
41
41
|
return nil
|
|
42
42
|
}
|
|
43
43
|
|
package/cmd/card_not_now.go
CHANGED
|
@@ -37,7 +37,7 @@ func handleNotNowCard(cmd *cobra.Command, cardNumber string) error {
|
|
|
37
37
|
return fmt.Errorf("moving card to not now: %w", err)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
fmt.
|
|
40
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d moved to Not Now successfully\n", cardNum)
|
|
41
41
|
return nil
|
|
42
42
|
}
|
|
43
43
|
|
package/cmd/card_reopen.go
CHANGED
|
@@ -37,7 +37,7 @@ func handleReopenCard(cmd *cobra.Command, cardNumber string) error {
|
|
|
37
37
|
return fmt.Errorf("reopening card: %w", err)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
fmt.
|
|
40
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d reopened successfully\n", cardNum)
|
|
41
41
|
return nil
|
|
42
42
|
}
|
|
43
43
|
|
package/cmd/card_tag.go
CHANGED
|
@@ -42,7 +42,7 @@ func handleTagCard(cmd *cobra.Command, cardNumber, tagTitle string) error {
|
|
|
42
42
|
return fmt.Errorf("toggling tag on card: %w", err)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
fmt.
|
|
45
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Tag '%s' toggled on card #%d\n", tagTitle, cardNum)
|
|
46
46
|
return nil
|
|
47
47
|
}
|
|
48
48
|
|
package/cmd/card_triage.go
CHANGED
|
@@ -37,7 +37,7 @@ func handleTriageCard(cmd *cobra.Command, cardNumber string, columnID string) er
|
|
|
37
37
|
return fmt.Errorf("triaging card: %w", err)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
fmt.
|
|
40
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d moved to column successfully\n", cardNum)
|
|
41
41
|
return nil
|
|
42
42
|
}
|
|
43
43
|
|
package/cmd/card_ungolden.go
CHANGED
|
@@ -37,7 +37,7 @@ func handleUngoldenCard(cmd *cobra.Command, cardNumber string) error {
|
|
|
37
37
|
return fmt.Errorf("removing golden status: %w", err)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
fmt.
|
|
40
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d golden status removed\n", cardNum)
|
|
41
41
|
return nil
|
|
42
42
|
}
|
|
43
43
|
|
package/cmd/card_untriage.go
CHANGED
|
@@ -37,7 +37,7 @@ func handleUntriagedCard(cmd *cobra.Command, cardNumber string) error {
|
|
|
37
37
|
return fmt.Errorf("sending card back to triage: %w", err)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
fmt.
|
|
40
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d sent back to triage successfully\n", cardNum)
|
|
41
41
|
return nil
|
|
42
42
|
}
|
|
43
43
|
|
package/cmd/card_unwatch.go
CHANGED
|
@@ -37,7 +37,7 @@ func handleUnwatchCard(cmd *cobra.Command, cardNumber string) error {
|
|
|
37
37
|
return fmt.Errorf("unwatching card: %w", err)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
fmt.
|
|
40
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Stopped watching card #%d\n", cardNum)
|
|
41
41
|
return nil
|
|
42
42
|
}
|
|
43
43
|
|
package/cmd/card_update.go
CHANGED
|
@@ -67,7 +67,7 @@ func handleUpdateCard(cmd *cobra.Command, cardNumber string) error {
|
|
|
67
67
|
return fmt.Errorf("updating card: %w", err)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
fmt.
|
|
70
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d updated successfully\n", card.Number)
|
|
71
71
|
return nil
|
|
72
72
|
}
|
|
73
73
|
|
package/cmd/card_watch.go
CHANGED
|
@@ -37,7 +37,7 @@ func handleWatchCard(cmd *cobra.Command, cardNumber string) error {
|
|
|
37
37
|
return fmt.Errorf("watching card: %w", err)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
fmt.
|
|
40
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Now watching card #%d\n", cardNum)
|
|
41
41
|
return nil
|
|
42
42
|
}
|
|
43
43
|
|
package/cmd/column_create.go
CHANGED
|
@@ -66,7 +66,7 @@ func handleCreateColumn(cmd *cobra.Command) error {
|
|
|
66
66
|
return fmt.Errorf("creating column: %w", err)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
fmt.
|
|
69
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Column '%s' created successfully\n", name)
|
|
70
70
|
return nil
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -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 columnDeleteCmd = &cobra.Command{
|
|
12
|
+
Use: "delete <column_id>",
|
|
13
|
+
Short: "Delete a column",
|
|
14
|
+
Long: `Delete a column. Only board administrators can delete columns.`,
|
|
15
|
+
Args: cobra.ExactArgs(1),
|
|
16
|
+
Run: func(cmd *cobra.Command, args []string) {
|
|
17
|
+
if err := handleDeleteColumn(cmd, args[0]); err != nil {
|
|
18
|
+
fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func handleDeleteColumn(cmd *cobra.Command, columnID 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.DeleteColumn(context.Background(), columnID)
|
|
30
|
+
if err != nil {
|
|
31
|
+
return fmt.Errorf("deleting column: %w", err)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fmt.Fprintf(cmd.OutOrStdout(), "✓ Column '%s' deleted successfully\n", columnID)
|
|
35
|
+
return nil
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func init() {
|
|
39
|
+
columnCmd.AddCommand(columnDeleteCmd)
|
|
40
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
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 TestColumnDeleteCommandSuccess(t *testing.T) {
|
|
14
|
+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
15
|
+
if r.URL.Path != "/boards/board-123/columns/col-456" {
|
|
16
|
+
t.Errorf("expected /boards/board-123/columns/col-456, 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, "", "board-123", "test-token")
|
|
32
|
+
testApp := &app.App{Client: client}
|
|
33
|
+
|
|
34
|
+
cmd := columnDeleteCmd
|
|
35
|
+
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
36
|
+
|
|
37
|
+
if err := handleDeleteColumn(cmd, "col-456"); err != nil {
|
|
38
|
+
t.Fatalf("handleDeleteColumn failed: %v", err)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func TestColumnDeleteCommandNotFound(t *testing.T) {
|
|
43
|
+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
44
|
+
w.WriteHeader(http.StatusNotFound)
|
|
45
|
+
w.Write([]byte("Column not found"))
|
|
46
|
+
}))
|
|
47
|
+
defer server.Close()
|
|
48
|
+
|
|
49
|
+
client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
|
|
50
|
+
testApp := &app.App{Client: client}
|
|
51
|
+
|
|
52
|
+
cmd := columnDeleteCmd
|
|
53
|
+
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
54
|
+
|
|
55
|
+
err := handleDeleteColumn(cmd, "nonexistent-col")
|
|
56
|
+
if err == nil {
|
|
57
|
+
t.Errorf("expected error for column not found")
|
|
58
|
+
}
|
|
59
|
+
if err.Error() != "deleting column: unexpected status code 404: Column not found" {
|
|
60
|
+
t.Errorf("expected column not found error, got %v", err)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
func TestColumnDeleteCommandForbidden(t *testing.T) {
|
|
65
|
+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
66
|
+
w.WriteHeader(http.StatusForbidden)
|
|
67
|
+
w.Write([]byte("You don't have permission to delete this column"))
|
|
68
|
+
}))
|
|
69
|
+
defer server.Close()
|
|
70
|
+
|
|
71
|
+
client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
|
|
72
|
+
testApp := &app.App{Client: client}
|
|
73
|
+
|
|
74
|
+
cmd := columnDeleteCmd
|
|
75
|
+
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
76
|
+
|
|
77
|
+
err := handleDeleteColumn(cmd, "col-456")
|
|
78
|
+
if err == nil {
|
|
79
|
+
t.Errorf("expected error for forbidden access")
|
|
80
|
+
}
|
|
81
|
+
if err.Error() != "deleting column: unexpected status code 403: You don't have permission to delete this column" {
|
|
82
|
+
t.Errorf("expected permission error, got %v", err)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
func TestColumnDeleteCommandAPIError(t *testing.T) {
|
|
87
|
+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
88
|
+
w.WriteHeader(http.StatusInternalServerError)
|
|
89
|
+
w.Write([]byte("Internal Server Error"))
|
|
90
|
+
}))
|
|
91
|
+
defer server.Close()
|
|
92
|
+
|
|
93
|
+
client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
|
|
94
|
+
testApp := &app.App{Client: client}
|
|
95
|
+
|
|
96
|
+
cmd := columnDeleteCmd
|
|
97
|
+
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
98
|
+
|
|
99
|
+
err := handleDeleteColumn(cmd, "col-456")
|
|
100
|
+
if err == nil {
|
|
101
|
+
t.Errorf("expected error for API failure")
|
|
102
|
+
}
|
|
103
|
+
if err.Error() != "deleting column: unexpected status code 500: Internal Server Error" {
|
|
104
|
+
t.Errorf("expected API error, got %v", err)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
func TestColumnDeleteCommandNoClient(t *testing.T) {
|
|
109
|
+
testApp := &app.App{}
|
|
110
|
+
|
|
111
|
+
cmd := columnDeleteCmd
|
|
112
|
+
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
113
|
+
|
|
114
|
+
err := handleDeleteColumn(cmd, "col-456")
|
|
115
|
+
if err == nil {
|
|
116
|
+
t.Errorf("expected error when client not available")
|
|
117
|
+
}
|
|
118
|
+
if err.Error() != "API client not available" {
|
|
119
|
+
t.Errorf("expected 'client not available' error, got %v", err)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -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/rogeriopvl/fizzy/internal/ui"
|
|
9
|
+
"github.com/spf13/cobra"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
var columnShowCmd = &cobra.Command{
|
|
13
|
+
Use: "show <column_id>",
|
|
14
|
+
Short: "Show column details",
|
|
15
|
+
Long: `Retrieve and display detailed information about a specific column`,
|
|
16
|
+
Args: cobra.ExactArgs(1),
|
|
17
|
+
Run: func(cmd *cobra.Command, args []string) {
|
|
18
|
+
if err := handleShowColumnDetails(cmd, args[0]); err != nil {
|
|
19
|
+
fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
func handleShowColumnDetails(cmd *cobra.Command, columnID string) error {
|
|
25
|
+
a := app.FromContext(cmd.Context())
|
|
26
|
+
if a == nil || a.Client == nil {
|
|
27
|
+
return fmt.Errorf("API client not available")
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
column, err := a.Client.GetColumn(context.Background(), columnID)
|
|
31
|
+
if err != nil {
|
|
32
|
+
return fmt.Errorf("fetching column: %w", err)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return ui.DisplayColumn(cmd.OutOrStdout(), column)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func init() {
|
|
39
|
+
columnCmd.AddCommand(columnShowCmd)
|
|
40
|
+
}
|
|
@@ -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
|
+
}
|