fizzy-cli 0.8.0 → 0.9.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 (156) hide show
  1. package/package.json +2 -1
  2. package/.env +0 -1
  3. package/.github/workflows/release.yml +0 -29
  4. package/.github/workflows/tests.yml +0 -24
  5. package/AGENTS.md +0 -33
  6. package/CHANGELOG.md +0 -194
  7. package/Makefile +0 -43
  8. package/bin/fizzy +0 -0
  9. package/cmd/account.go +0 -14
  10. package/cmd/account_list.go +0 -44
  11. package/cmd/account_list_test.go +0 -118
  12. package/cmd/board.go +0 -49
  13. package/cmd/board_create.go +0 -59
  14. package/cmd/board_create_test.go +0 -141
  15. package/cmd/board_delete.go +0 -40
  16. package/cmd/board_delete_test.go +0 -121
  17. package/cmd/board_list.go +0 -44
  18. package/cmd/board_list_test.go +0 -115
  19. package/cmd/board_show.go +0 -40
  20. package/cmd/board_show_test.go +0 -113
  21. package/cmd/board_test.go +0 -92
  22. package/cmd/board_update.go +0 -72
  23. package/cmd/board_update_test.go +0 -233
  24. package/cmd/card.go +0 -24
  25. package/cmd/card_assign.go +0 -55
  26. package/cmd/card_assign_test.go +0 -130
  27. package/cmd/card_close.go +0 -46
  28. package/cmd/card_close_test.go +0 -92
  29. package/cmd/card_create.go +0 -72
  30. package/cmd/card_create_test.go +0 -186
  31. package/cmd/card_delete.go +0 -46
  32. package/cmd/card_delete_test.go +0 -92
  33. package/cmd/card_golden.go +0 -46
  34. package/cmd/card_golden_test.go +0 -92
  35. package/cmd/card_list.go +0 -114
  36. package/cmd/card_list_test.go +0 -373
  37. package/cmd/card_not_now.go +0 -46
  38. package/cmd/card_not_now_test.go +0 -92
  39. package/cmd/card_reaction.go +0 -13
  40. package/cmd/card_reaction_create.go +0 -46
  41. package/cmd/card_reaction_create_test.go +0 -148
  42. package/cmd/card_reaction_delete.go +0 -46
  43. package/cmd/card_reaction_delete_test.go +0 -112
  44. package/cmd/card_reaction_list.go +0 -51
  45. package/cmd/card_reaction_list_test.go +0 -127
  46. package/cmd/card_reopen.go +0 -46
  47. package/cmd/card_reopen_test.go +0 -92
  48. package/cmd/card_show.go +0 -46
  49. package/cmd/card_show_test.go +0 -92
  50. package/cmd/card_tag.go +0 -51
  51. package/cmd/card_tag_test.go +0 -112
  52. package/cmd/card_triage.go +0 -46
  53. package/cmd/card_ungolden.go +0 -46
  54. package/cmd/card_ungolden_test.go +0 -92
  55. package/cmd/card_untriage.go +0 -46
  56. package/cmd/card_untriage_test.go +0 -92
  57. package/cmd/card_unwatch.go +0 -46
  58. package/cmd/card_unwatch_test.go +0 -92
  59. package/cmd/card_update.go +0 -82
  60. package/cmd/card_update_test.go +0 -149
  61. package/cmd/card_watch.go +0 -46
  62. package/cmd/card_watch_test.go +0 -92
  63. package/cmd/column.go +0 -14
  64. package/cmd/column_create.go +0 -79
  65. package/cmd/column_create_test.go +0 -178
  66. package/cmd/column_delete.go +0 -40
  67. package/cmd/column_delete_test.go +0 -121
  68. package/cmd/column_list.go +0 -44
  69. package/cmd/column_list_test.go +0 -138
  70. package/cmd/column_show.go +0 -40
  71. package/cmd/column_show_test.go +0 -111
  72. package/cmd/column_update.go +0 -67
  73. package/cmd/column_update_test.go +0 -198
  74. package/cmd/comment.go +0 -14
  75. package/cmd/comment_create.go +0 -51
  76. package/cmd/comment_create_test.go +0 -129
  77. package/cmd/comment_delete.go +0 -46
  78. package/cmd/comment_delete_test.go +0 -92
  79. package/cmd/comment_list.go +0 -51
  80. package/cmd/comment_list_test.go +0 -132
  81. package/cmd/comment_show.go +0 -46
  82. package/cmd/comment_show_test.go +0 -104
  83. package/cmd/comment_update.go +0 -51
  84. package/cmd/comment_update_test.go +0 -130
  85. package/cmd/login.go +0 -81
  86. package/cmd/login_test.go +0 -98
  87. package/cmd/notification.go +0 -14
  88. package/cmd/notification_list.go +0 -69
  89. package/cmd/notification_list_test.go +0 -288
  90. package/cmd/notification_read.go +0 -51
  91. package/cmd/notification_read_all.go +0 -38
  92. package/cmd/notification_read_all_test.go +0 -75
  93. package/cmd/notification_read_test.go +0 -138
  94. package/cmd/notification_unread.go +0 -44
  95. package/cmd/notification_unread_test.go +0 -99
  96. package/cmd/reaction.go +0 -13
  97. package/cmd/reaction_create.go +0 -46
  98. package/cmd/reaction_create_test.go +0 -113
  99. package/cmd/reaction_delete.go +0 -46
  100. package/cmd/reaction_delete_test.go +0 -92
  101. package/cmd/reaction_list.go +0 -51
  102. package/cmd/reaction_list_test.go +0 -125
  103. package/cmd/root.go +0 -38
  104. package/cmd/step.go +0 -14
  105. package/cmd/step_create.go +0 -53
  106. package/cmd/step_create_test.go +0 -171
  107. package/cmd/step_delete.go +0 -46
  108. package/cmd/step_delete_test.go +0 -92
  109. package/cmd/step_update.go +0 -66
  110. package/cmd/step_update_test.go +0 -190
  111. package/cmd/tag.go +0 -15
  112. package/cmd/tag_list.go +0 -47
  113. package/cmd/tag_list_test.go +0 -109
  114. package/cmd/use.go +0 -85
  115. package/cmd/use_test.go +0 -186
  116. package/cmd/user.go +0 -22
  117. package/cmd/user_deactivate.go +0 -40
  118. package/cmd/user_deactivate_test.go +0 -121
  119. package/cmd/user_list.go +0 -44
  120. package/cmd/user_list_test.go +0 -126
  121. package/cmd/user_show.go +0 -40
  122. package/cmd/user_show_test.go +0 -110
  123. package/cmd/user_update.go +0 -71
  124. package/cmd/user_update_test.go +0 -177
  125. package/go.mod +0 -31
  126. package/go.sum +0 -53
  127. package/internal/api/boards.go +0 -93
  128. package/internal/api/cards.go +0 -322
  129. package/internal/api/client.go +0 -99
  130. package/internal/api/columns.go +0 -113
  131. package/internal/api/comments.go +0 -108
  132. package/internal/api/identity.go +0 -24
  133. package/internal/api/notifications.go +0 -89
  134. package/internal/api/reactions.go +0 -130
  135. package/internal/api/steps.go +0 -101
  136. package/internal/api/tags.go +0 -24
  137. package/internal/api/types.go +0 -195
  138. package/internal/api/users.go +0 -75
  139. package/internal/app/app.go +0 -49
  140. package/internal/colors/colors.go +0 -32
  141. package/internal/config/config.go +0 -70
  142. package/internal/testutil/client.go +0 -26
  143. package/internal/ui/account_list.go +0 -14
  144. package/internal/ui/account_selector.go +0 -63
  145. package/internal/ui/board_list.go +0 -14
  146. package/internal/ui/board_show.go +0 -17
  147. package/internal/ui/card_list.go +0 -14
  148. package/internal/ui/card_show.go +0 -23
  149. package/internal/ui/column_list.go +0 -28
  150. package/internal/ui/column_show.go +0 -16
  151. package/internal/ui/comment_list.go +0 -25
  152. package/internal/ui/format.go +0 -27
  153. package/internal/ui/notification_list.go +0 -27
  154. package/internal/ui/reaction_list.go +0 -14
  155. package/internal/ui/user_list.go +0 -19
  156. package/internal/ui/user_show.go +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fizzy-cli",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "CLI for https://fizzy.do",
5
5
  "main": "bin/fizzy",
6
6
  "type": "module",
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "postinstall": "node scripts/postinstall.js",
12
+ "prepack": "rm -f bin/fizzy bin/fizzy.exe",
12
13
  "build": "make build-all"
13
14
  },
14
15
  "repository": {
package/.env DELETED
@@ -1 +0,0 @@
1
- FIZZY_ACCESS_TOKEN=S7FiVcT1K3WgwXc7uzBdQRim
@@ -1,29 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- release:
5
- types: [created]
6
-
7
- permissions:
8
- contents: write
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
-
14
- steps:
15
- - uses: actions/checkout@v4
16
-
17
- - name: Set up Go
18
- uses: actions/setup-go@v4
19
- with:
20
- go-version: "1.25"
21
-
22
- - name: Build binaries
23
- run: make build-all
24
-
25
- - name: Upload Release Assets
26
- env:
27
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28
- run: |
29
- gh release upload ${{ github.event.release.tag_name }} bin/fizzy-* --clobber
@@ -1,24 +0,0 @@
1
- name: Tests
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- branches: [main]
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
-
13
- steps:
14
- - uses: actions/checkout@v4
15
-
16
- - uses: actions/setup-go@v4
17
- with:
18
- go-version: "1.25"
19
-
20
- - name: Install gotestsum
21
- run: go install gotest.tools/gotestsum@latest
22
-
23
- - name: Run tests
24
- run: make test
package/AGENTS.md DELETED
@@ -1,33 +0,0 @@
1
- # AGENTS.md
2
-
3
- ## About
4
-
5
- fizzy-cli is a CLI application built in Go that provides an interface to the
6
- [Fizzy](https://fizzy.do) API. Fizzy is a kanban-style project management SaaS.
7
-
8
- ## Dev instructions
9
-
10
- All the commands for development are available through Makefile, just read that
11
- file whenever you need to run something because chances are that you will find
12
- you answer there.
13
-
14
- You can find the Fizzy API specification at @docs/API.md
15
-
16
- ## Testing
17
-
18
- Automated testing is done via `make test`.
19
-
20
- For manual testing/debugging, you should run `make install` first to install the
21
- binary and then run the `fizzy` command normally.
22
-
23
- ## Code quality, standards and style
24
-
25
- This project is being built in Go because it's supposed to have a strong focus
26
- on performance. Always prefer performant code and solutions and low memory
27
- footprint.
28
-
29
- Don't write obvious code comments. Only use code comments when the code itself
30
- requires some clarification to be understood.
31
-
32
- When in doubt, always check similar files or features and reuse the patterns and
33
- style applied.
package/CHANGELOG.md DELETED
@@ -1,194 +0,0 @@
1
- # Changelog
2
-
3
- ## 0.8.0 - 2026-02-11
4
-
5
- ### Features
6
-
7
- #### Card Management
8
-
9
- - `fizzy card list` now supports filtering by board, tags, assignees, creators, and closure status
10
- - Enhanced card listing with additional query parameters for better filtering capabilities
11
-
12
- #### Reaction Management
13
-
14
- - `fizzy reaction list <card_number>` - List all reactions on a card
15
- - `fizzy reaction create <card_number> <emoji>` - Add a reaction to a card
16
- - `fizzy reaction delete <card_number> <reaction_id>` - Remove a reaction from a card
17
-
18
- #### User Management
19
-
20
- - `fizzy user list` - List all users in the account
21
- - `fizzy user show <user_id>` - Display details for a specific user
22
- - `fizzy user update <user_id>` - Update user properties (name, avatar)
23
- - `fizzy user deactivate <user_id>` - Deactivate a user account
24
-
25
- ### Improvements
26
-
27
- - Updated API specification to latest version
28
-
29
- ## 0.7.0 - 2026-01-26
30
-
31
- ### Features
32
-
33
- #### Board Management
34
-
35
- - `fizzy board show <board_id>` - Display details for a specific board
36
- - `fizzy board update <board_id>` - Update board properties (name, access, auto-postpone period)
37
- - `fizzy board delete <board_id>` - Delete a board
38
-
39
- #### Column Management
40
-
41
- - `fizzy column show <column_id>` - Display details for a specific column
42
- - `fizzy column update <column_id>` - Update column properties (name, color)
43
- - `fizzy column delete <column_id>` - Delete a column
44
-
45
- ### Improvements
46
-
47
- - Improved command output testability by using consistent output writers
48
-
49
- ## 0.6.1 - 2026-01-26
50
-
51
- ### Fixes
52
-
53
- - Fixed API client to not parse empty responses from POST endpoints, this was
54
- causing the create sub-command of comment, reaction and step to show an error
55
- message, even though the resource was actually created on the API.
56
-
57
- ## 0.6.0 - 2026-01-25
58
-
59
- ### Features
60
-
61
- #### Reaction Management
62
-
63
- - `fizzy reaction list <card_number> <comment_id>` - List all reactions on a comment
64
- - `fizzy reaction add <card_number> <comment_id> <emoji>` - Add a reaction to a comment
65
- - `fizzy reaction remove <card_number> <comment_id> <reaction_id>` - Remove a reaction from a comment
66
-
67
- #### Step Management
68
-
69
- - `fizzy step create <card_number> --content <text> [--completed]` - Create a new step on a card
70
- - `fizzy step update <card_number> <step_id> [--content <text>] [--completed]` - Update a step
71
- - `fizzy step delete <card_number> <step_id>` - Delete a step from a card
72
-
73
- #### Comment Management
74
-
75
- - `fizzy comment delete <card_number> <comment_id>` - Delete a comment from a card
76
- - `fizzy comment update <card_number> <comment_id> --body <text>` - Update a comment on a card
77
-
78
- ### Improvements
79
-
80
- - Refactored API client logic into separate files for better organization
81
- - Enhanced card update command to use `Flags().Changed()` for better flag handling
82
- - Comprehensive test coverage for all new commands (168 tests total)
83
-
84
- ## 0.5.0 - 2026-01-25
85
-
86
- ### Features
87
-
88
- #### Comment Management
89
-
90
- - `fizzy comment list <card_number>` - List all comments on a card
91
- - `fizzy comment show <card_number> <comment_id>` - Display a specific comment
92
- - `fizzy comment add <card_number> <body>` - Create a new comment on a card
93
-
94
- ### Fixes
95
-
96
- - Fixed error handling in notification read-all command
97
- - Removed global flag usage in some commands
98
-
99
- ## 0.4.0 - 2026-01-19
100
-
101
- ### Features
102
-
103
- #### Card Management
104
-
105
- - `fizzy card not-now <card_number>` - Move a card to "Not Now" status
106
- - `fizzy card untriage <card_number>` - Send a card back to triage
107
- - `fizzy card watch <card_number>` - Subscribe to card notifications
108
- - `fizzy card unwatch <card_number>` - Unsubscribe from card notifications
109
- - `fizzy card golden <card_number>` - Mark a card as golden
110
- - `fizzy card ungolden <card_number>` - Remove golden status from a card
111
-
112
- ## 0.3.0 - 2026-01-11
113
-
114
- ### Features
115
-
116
- #### Notification Management
117
-
118
- - `fizzy notification list` - List all notifications with optional filtering
119
- - `fizzy notification read <notification_id>` - Mark a notification as read and display it
120
- - `fizzy notification unread <notification_id>` - Mark a notification as unread
121
- - `fizzy notification read-all` - Mark all unread notifications as read
122
-
123
- #### Card Management
124
-
125
- - `fizzy card assign <card_number> <user_id>` - Assign or unassign a user to/from a card
126
- - `fizzy card triage <card_number> <column_id>` - Move a card from triage into a column
127
-
128
- ## [0.2.1] - 2025-12-20
129
-
130
- ### Fixes
131
-
132
- - NPM package publishing script
133
-
134
- ## [0.2.0] - 2025-12-20
135
-
136
- ### Features
137
-
138
- #### Card Management
139
-
140
- - `fizzy card update <card_number>` - Update card properties (title, description, status, tags)
141
- - `fizzy card delete <card_number>` - Delete a card permanently
142
- - `fizzy card close <card_number>` - Close an existing card (already existed, now documented)
143
- - `fizzy card reopen <card_number>` - Reopen a closed card (already existed, now documented)
144
-
145
- #### Account Management
146
-
147
- - `fizzy account list` - List all accounts you have access to
148
-
149
- #### Improvements
150
-
151
- - `fizzy board` without arguments now displays the currently selected board
152
- - Added `--version` flag to display CLI version
153
- - Fixed HTTP client leak in API requests
154
- - Updated API specification to latest version
155
-
156
- ## [0.1.0] - 2025-12-16
157
-
158
- ### Initial Release
159
-
160
- The first stable release of Fizzy CLI with core functionality for managing
161
- boards, cards, and columns.
162
-
163
- ### Features
164
-
165
- #### Authentication
166
-
167
- - `fizzy login` - Authenticate with Fizzy API using access tokens
168
-
169
- #### Board Management
170
-
171
- - `fizzy board list` - List all boards
172
- - `fizzy board create` - Create a new board
173
-
174
- #### Card Management
175
-
176
- - `fizzy card list` - List all cards in the selected board
177
- - `fizzy card create` - Create a new card
178
- - `fizzy card show <card_id>` - Display details for a specific card
179
-
180
- #### Column Management
181
-
182
- - `fizzy column list` - List all columns in the selected board
183
- - `fizzy column create` - Create a new column
184
-
185
- #### Configuration
186
-
187
- - `fizzy use --board <name>` - Set the active board for subsequent commands
188
- - `fizzy use --account <slug>` - Set the active account for subsequent commands
189
-
190
- ### Distribution
191
-
192
- - Multi-platform support (macOS, Linux, Windows)
193
- - Multi-architecture binaries (x64, arm64)
194
- - Distributed via NPM with automatic binary download on install
package/Makefile DELETED
@@ -1,43 +0,0 @@
1
- .PHONY: help dev-tools run build build-all clean test install sync-api-spec
2
-
3
- VERSION := $(shell grep '"version"' package.json | sed 's/.*"version": "\([^"]*\)".*/\1/')
4
- LDFLAGS := -ldflags="-X 'github.com/rogeriopvl/fizzy/cmd.Version=$(VERSION)'"
5
-
6
- help:
7
- @echo 'Usage: make [target]'
8
- @echo ''
9
- @echo 'Available targets:'
10
- @grep -E '^[a-zA-Z_-]+:' Makefile | sed 's/:.*//g' | sed 's/^/ /'
11
-
12
- dev-tools:
13
- @echo "Installing development tools..."
14
- go install gotest.tools/gotestsum@latest
15
-
16
- run:
17
- go run .
18
-
19
- install:
20
- go install $(LDFLAGS) .
21
-
22
- build:
23
- go build $(LDFLAGS) -o bin/fizzy .
24
-
25
- build-all: clean
26
- mkdir -p bin
27
- GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o bin/fizzy-darwin-amd64 .
28
- GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o bin/fizzy-darwin-arm64 .
29
- GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o bin/fizzy-linux-amd64 .
30
- GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o bin/fizzy-linux-arm64 .
31
- GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o bin/fizzy-windows-amd64.exe .
32
- @echo "Binaries built successfully in bin/"
33
-
34
- clean:
35
- rm -rf bin/
36
-
37
- test:
38
- gotestsum -- -v ./...
39
-
40
- sync-api-spec:
41
- @mkdir -p docs
42
- @curl -s https://raw.githubusercontent.com/basecamp/fizzy/main/docs/API.md -o docs/API.md
43
- @echo "API spec synced to docs/API.md"
package/bin/fizzy DELETED
Binary file
package/cmd/account.go DELETED
@@ -1,14 +0,0 @@
1
- // Package cmd
2
- package cmd
3
-
4
- import "github.com/spf13/cobra"
5
-
6
- var accountCmd = &cobra.Command{
7
- Use: "account",
8
- Short: "Manage accounts",
9
- Long: `Manage accounts in Fizzy`,
10
- }
11
-
12
- func init() {
13
- rootCmd.AddCommand(accountCmd)
14
- }
@@ -1,44 +0,0 @@
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 accountListCmd = &cobra.Command{
13
- Use: "list",
14
- Short: "List all accounts",
15
- Long: `Retrieve and display all accounts from Fizzy`,
16
- Run: func(cmd *cobra.Command, args []string) {
17
- if err := handleListAccounts(cmd); err != nil {
18
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
19
- }
20
- },
21
- }
22
-
23
- func handleListAccounts(cmd *cobra.Command) 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
- identity, err := a.Client.GetMyIdentity(context.Background())
30
- if err != nil {
31
- return fmt.Errorf("fetching accounts: %w", err)
32
- }
33
-
34
- if len(identity.Accounts) == 0 {
35
- fmt.Println("No accounts found")
36
- return nil
37
- }
38
-
39
- return ui.DisplayAccounts(identity.Accounts)
40
- }
41
-
42
- func init() {
43
- accountCmd.AddCommand(accountListCmd)
44
- }
@@ -1,118 +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
- )
14
-
15
- func TestAccountListCommand(t *testing.T) {
16
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
17
- if r.URL.Path != "/my/identity" {
18
- t.Errorf("expected /my/identity, 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 == "" {
26
- t.Error("missing Authorization header")
27
- }
28
- if auth != "Bearer test-token" {
29
- t.Errorf("expected Bearer test-token, got %s", auth)
30
- }
31
-
32
- w.Header().Set("Content-Type", "application/json")
33
- response := api.GetMyIdentityResponse{
34
- Accounts: []api.Account{
35
- {
36
- ID: "account-123",
37
- Name: "Personal",
38
- Slug: "personal",
39
- CreatedAt: "2025-01-01T00:00:00Z",
40
- },
41
- {
42
- ID: "account-456",
43
- Name: "Work",
44
- Slug: "work",
45
- CreatedAt: "2025-01-02T00:00:00Z",
46
- },
47
- },
48
- }
49
- json.NewEncoder(w).Encode(response)
50
- }))
51
- defer server.Close()
52
-
53
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
54
- testApp := &app.App{Client: client}
55
-
56
- cmd := accountListCmd
57
- cmd.SetContext(testApp.ToContext(context.Background()))
58
-
59
- if err := handleListAccounts(cmd); err != nil {
60
- t.Fatalf("handleListAccounts failed: %v", err)
61
- }
62
- }
63
-
64
- func TestAccountListCommandNoAccounts(t *testing.T) {
65
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
66
- w.Header().Set("Content-Type", "application/json")
67
- response := api.GetMyIdentityResponse{Accounts: []api.Account{}}
68
- json.NewEncoder(w).Encode(response)
69
- }))
70
- defer server.Close()
71
-
72
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
73
- testApp := &app.App{Client: client}
74
-
75
- cmd := accountListCmd
76
- cmd.SetContext(testApp.ToContext(context.Background()))
77
-
78
- if err := handleListAccounts(cmd); err != nil {
79
- t.Fatalf("handleListAccounts failed: %v", err)
80
- }
81
- }
82
-
83
- func TestAccountListCommandAPIError(t *testing.T) {
84
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
85
- w.WriteHeader(http.StatusInternalServerError)
86
- w.Write([]byte("Internal Server Error"))
87
- }))
88
- defer server.Close()
89
-
90
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
91
- testApp := &app.App{Client: client}
92
-
93
- cmd := accountListCmd
94
- cmd.SetContext(testApp.ToContext(context.Background()))
95
-
96
- err := handleListAccounts(cmd)
97
- if err == nil {
98
- t.Errorf("expected error for API failure")
99
- }
100
- if err.Error() != "fetching accounts: unexpected status code 500: Internal Server Error" {
101
- t.Errorf("expected API error, got %v", err)
102
- }
103
- }
104
-
105
- func TestAccountListCommandNoClient(t *testing.T) {
106
- testApp := &app.App{}
107
-
108
- cmd := accountListCmd
109
- cmd.SetContext(testApp.ToContext(context.Background()))
110
-
111
- err := handleListAccounts(cmd)
112
- if err == nil {
113
- t.Errorf("expected error when client not available")
114
- }
115
- if err.Error() != "API client not available" {
116
- t.Errorf("expected 'client not available' error, got %v", err)
117
- }
118
- }
package/cmd/board.go DELETED
@@ -1,49 +0,0 @@
1
- // Package cmd
2
- package cmd
3
-
4
- import (
5
- "context"
6
- "fmt"
7
-
8
- "github.com/rogeriopvl/fizzy/internal/app"
9
- "github.com/rogeriopvl/fizzy/internal/ui"
10
- "github.com/spf13/cobra"
11
- )
12
-
13
- var boardCmd = &cobra.Command{
14
- Use: "board",
15
- Short: "Show the currently selected board",
16
- Long: `Display the name and ID of the currently selected board.
17
-
18
- Use subcommands to list, create, or manage boards:
19
- fizzy board list List all boards
20
- fizzy board create Create a new board`,
21
- Run: func(cmd *cobra.Command, args []string) {
22
- if err := handleShowBoard(cmd); err != nil {
23
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
24
- }
25
- },
26
- }
27
-
28
- func handleShowBoard(cmd *cobra.Command) error {
29
- a := app.FromContext(cmd.Context())
30
- if a == nil || a.Client == nil {
31
- return fmt.Errorf("API client not available")
32
- }
33
-
34
- if a.Config.SelectedBoard == "" {
35
- return fmt.Errorf("no board selected")
36
- }
37
-
38
- board, err := a.Client.GetBoard(context.Background(), a.Config.SelectedBoard)
39
- if err != nil {
40
- return fmt.Errorf("fetching board: %w", err)
41
- }
42
-
43
- fmt.Fprintf(cmd.OutOrStdout(), "%s (%s)\n", board.Name, ui.DisplayID(board.ID))
44
- return nil
45
- }
46
-
47
- func init() {
48
- rootCmd.AddCommand(boardCmd)
49
- }
@@ -1,59 +0,0 @@
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 boardCreateCmd = &cobra.Command{
13
- Use: "create",
14
- Short: "Create a new board",
15
- Long: `Create a new board in Fizzy`,
16
- Run: func(cmd *cobra.Command, args []string) {
17
- if err := handleCreateBoard(cmd); err != nil {
18
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
19
- }
20
- },
21
- }
22
-
23
- func handleCreateBoard(cmd *cobra.Command) 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
- // Read flag values directly from command
30
- name, _ := cmd.Flags().GetString("name")
31
- allAccess, _ := cmd.Flags().GetBool("all-access")
32
- autoPostponePeriod, _ := cmd.Flags().GetInt("auto-postpone-period")
33
- publicDescription, _ := cmd.Flags().GetString("description")
34
-
35
- payload := api.CreateBoardPayload{
36
- Name: name,
37
- AllAccess: allAccess,
38
- AutoPostponePeriod: autoPostponePeriod,
39
- PublicDescription: publicDescription,
40
- }
41
-
42
- _, err := a.Client.PostBoards(context.Background(), payload)
43
- if err != nil {
44
- return fmt.Errorf("creating board: %w", err)
45
- }
46
-
47
- fmt.Fprintf(cmd.OutOrStdout(), "✓ Board '%s' created successfully\n", name)
48
- return nil
49
- }
50
-
51
- func init() {
52
- boardCreateCmd.Flags().StringP("name", "n", "", "Board name (required)")
53
- boardCreateCmd.MarkFlagRequired("name")
54
- boardCreateCmd.Flags().Bool("all-access", false, "Allow all access to the board")
55
- boardCreateCmd.Flags().Int("auto-postpone-period", 0, "Auto postpone period in days")
56
- boardCreateCmd.Flags().String("description", "", "Public description of the board")
57
-
58
- boardCmd.AddCommand(boardCreateCmd)
59
- }