fizzy-cli 0.7.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 (137) hide show
  1. package/docs/API.md +63 -2
  2. package/package.json +2 -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 -168
  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 -53
  36. package/cmd/card_list_test.go +0 -148
  37. package/cmd/card_not_now.go +0 -46
  38. package/cmd/card_not_now_test.go +0 -92
  39. package/cmd/card_reopen.go +0 -46
  40. package/cmd/card_reopen_test.go +0 -92
  41. package/cmd/card_show.go +0 -46
  42. package/cmd/card_show_test.go +0 -92
  43. package/cmd/card_tag.go +0 -51
  44. package/cmd/card_tag_test.go +0 -112
  45. package/cmd/card_triage.go +0 -46
  46. package/cmd/card_ungolden.go +0 -46
  47. package/cmd/card_ungolden_test.go +0 -92
  48. package/cmd/card_untriage.go +0 -46
  49. package/cmd/card_untriage_test.go +0 -92
  50. package/cmd/card_unwatch.go +0 -46
  51. package/cmd/card_unwatch_test.go +0 -92
  52. package/cmd/card_update.go +0 -82
  53. package/cmd/card_update_test.go +0 -149
  54. package/cmd/card_watch.go +0 -46
  55. package/cmd/card_watch_test.go +0 -92
  56. package/cmd/column.go +0 -14
  57. package/cmd/column_create.go +0 -79
  58. package/cmd/column_create_test.go +0 -178
  59. package/cmd/column_delete.go +0 -40
  60. package/cmd/column_delete_test.go +0 -121
  61. package/cmd/column_list.go +0 -44
  62. package/cmd/column_list_test.go +0 -138
  63. package/cmd/column_show.go +0 -40
  64. package/cmd/column_show_test.go +0 -111
  65. package/cmd/column_update.go +0 -67
  66. package/cmd/column_update_test.go +0 -198
  67. package/cmd/comment.go +0 -14
  68. package/cmd/comment_create.go +0 -51
  69. package/cmd/comment_create_test.go +0 -129
  70. package/cmd/comment_delete.go +0 -46
  71. package/cmd/comment_delete_test.go +0 -92
  72. package/cmd/comment_list.go +0 -51
  73. package/cmd/comment_list_test.go +0 -132
  74. package/cmd/comment_show.go +0 -46
  75. package/cmd/comment_show_test.go +0 -104
  76. package/cmd/comment_update.go +0 -51
  77. package/cmd/comment_update_test.go +0 -130
  78. package/cmd/login.go +0 -81
  79. package/cmd/login_test.go +0 -98
  80. package/cmd/notification.go +0 -14
  81. package/cmd/notification_list.go +0 -69
  82. package/cmd/notification_list_test.go +0 -288
  83. package/cmd/notification_read.go +0 -51
  84. package/cmd/notification_read_all.go +0 -38
  85. package/cmd/notification_read_all_test.go +0 -75
  86. package/cmd/notification_read_test.go +0 -138
  87. package/cmd/notification_unread.go +0 -44
  88. package/cmd/notification_unread_test.go +0 -99
  89. package/cmd/reaction.go +0 -13
  90. package/cmd/reaction_create.go +0 -46
  91. package/cmd/reaction_create_test.go +0 -113
  92. package/cmd/reaction_delete.go +0 -46
  93. package/cmd/reaction_delete_test.go +0 -92
  94. package/cmd/reaction_list.go +0 -51
  95. package/cmd/reaction_list_test.go +0 -125
  96. package/cmd/root.go +0 -38
  97. package/cmd/step.go +0 -14
  98. package/cmd/step_create.go +0 -53
  99. package/cmd/step_create_test.go +0 -171
  100. package/cmd/step_delete.go +0 -46
  101. package/cmd/step_delete_test.go +0 -92
  102. package/cmd/step_update.go +0 -66
  103. package/cmd/step_update_test.go +0 -190
  104. package/cmd/tag.go +0 -15
  105. package/cmd/tag_list.go +0 -47
  106. package/cmd/tag_list_test.go +0 -109
  107. package/cmd/use.go +0 -85
  108. package/cmd/use_test.go +0 -186
  109. package/go.mod +0 -31
  110. package/go.sum +0 -53
  111. package/internal/api/boards.go +0 -93
  112. package/internal/api/cards.go +0 -288
  113. package/internal/api/client.go +0 -99
  114. package/internal/api/columns.go +0 -113
  115. package/internal/api/comments.go +0 -108
  116. package/internal/api/identity.go +0 -24
  117. package/internal/api/notifications.go +0 -89
  118. package/internal/api/reactions.go +0 -69
  119. package/internal/api/steps.go +0 -101
  120. package/internal/api/tags.go +0 -24
  121. package/internal/api/types.go +0 -190
  122. package/internal/app/app.go +0 -49
  123. package/internal/colors/colors.go +0 -32
  124. package/internal/config/config.go +0 -70
  125. package/internal/testutil/client.go +0 -26
  126. package/internal/ui/account_list.go +0 -14
  127. package/internal/ui/account_selector.go +0 -63
  128. package/internal/ui/board_list.go +0 -14
  129. package/internal/ui/board_show.go +0 -17
  130. package/internal/ui/card_list.go +0 -14
  131. package/internal/ui/card_show.go +0 -23
  132. package/internal/ui/column_list.go +0 -28
  133. package/internal/ui/column_show.go +0 -16
  134. package/internal/ui/comment_list.go +0 -25
  135. package/internal/ui/format.go +0 -27
  136. package/internal/ui/notification_list.go +0 -27
  137. package/internal/ui/reaction_list.go +0 -14
package/docs/API.md CHANGED
@@ -553,7 +553,8 @@ __Response:__
553
553
  "created_at": "2025-12-05T19:36:35.401Z",
554
554
  "url": "http://fizzy.localhost:3006/897362094/users/03f5v9zjw7pz8717a4no1h8a7"
555
555
  },
556
- "comments_url": "http://fizzy.localhost:3006/897362094/cards/4/comments"
556
+ "comments_url": "http://fizzy.localhost:3006/897362094/cards/4/comments",
557
+ "reactions_url": "http://fizzy.localhost:3006/897362094/cards/4/reactions"
557
558
  },
558
559
  ]
559
560
  ```
@@ -614,6 +615,7 @@ __Response:__
614
615
  "url": "http://fizzy.localhost:3006/897362094/users/03f5v9zjw7pz8717a4no1h8a7"
615
616
  },
616
617
  "comments_url": "http://fizzy.localhost:3006/897362094/cards/4/comments",
618
+ "reactions_url": "http://fizzy.localhost:3006/897362094/cards/4/reactions",
617
619
  "steps": [
618
620
  {
619
621
  "id": "03f8huu0sog76g3s975963b5e",
@@ -928,7 +930,66 @@ __Response:__
928
930
 
929
931
  Returns `204 No Content` on success.
930
932
 
931
- ## Reactions
933
+ ## Card Reactions (Boosts)
934
+
935
+ Card reactions (also called "boosts") let users add short responses directly to cards. These are limited to 16 characters.
936
+
937
+ ### `GET /:account_slug/cards/:card_number/reactions`
938
+
939
+ Returns a list of reactions on a card.
940
+
941
+ __Response:__
942
+
943
+ ```json
944
+ [
945
+ {
946
+ "id": "03f5v9zo9qlcwwpyc0ascnikz",
947
+ "content": "👍",
948
+ "reacter": {
949
+ "id": "03f5v9zjw7pz8717a4no1h8a7",
950
+ "name": "David Heinemeier Hansson",
951
+ "role": "owner",
952
+ "active": true,
953
+ "email_address": "david@example.com",
954
+ "created_at": "2025-12-05T19:36:35.401Z",
955
+ "url": "http://fizzy.localhost:3006/897362094/users/03f5v9zjw7pz8717a4no1h8a7"
956
+ },
957
+ "url": "http://fizzy.localhost:3006/897362094/cards/3/reactions/03f5v9zo9qlcwwpyc0ascnikz"
958
+ }
959
+ ]
960
+ ```
961
+
962
+ ### `POST /:account_slug/cards/:card_number/reactions`
963
+
964
+ Adds a reaction (boost) to a card.
965
+
966
+ | Parameter | Type | Required | Description |
967
+ |-----------|------|----------|-------------|
968
+ | `content` | string | Yes | The reaction text (max 16 characters) |
969
+
970
+ __Request:__
971
+
972
+ ```json
973
+ {
974
+ "reaction": {
975
+ "content": "Great 👍"
976
+ }
977
+ }
978
+ ```
979
+
980
+ __Response:__
981
+
982
+ Returns `201 Created` on success.
983
+
984
+ ### `DELETE /:account_slug/cards/:card_number/reactions/:reaction_id`
985
+
986
+ Removes your reaction from a card. Only the reaction creator can remove their own reactions.
987
+
988
+ __Response:__
989
+
990
+ Returns `204 No Content` on success.
991
+
992
+ ## Comment Reactions
932
993
 
933
994
  Reactions are short (16-character max) responses to comments.
934
995
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fizzy-cli",
3
- "version": "0.7.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": {
@@ -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,168 +0,0 @@
1
- # Changelog
2
-
3
- ## 0.7.0 - 2026-01-26
4
-
5
- ### Features
6
-
7
- #### Board Management
8
-
9
- - `fizzy board show <board_id>` - Display details for a specific board
10
- - `fizzy board update <board_id>` - Update board properties (name, access, auto-postpone period)
11
- - `fizzy board delete <board_id>` - Delete a board
12
-
13
- #### Column Management
14
-
15
- - `fizzy column show <column_id>` - Display details for a specific column
16
- - `fizzy column update <column_id>` - Update column properties (name, color)
17
- - `fizzy column delete <column_id>` - Delete a column
18
-
19
- ### Improvements
20
-
21
- - Improved command output testability by using consistent output writers
22
-
23
- ## 0.6.1 - 2026-01-26
24
-
25
- ### Fixes
26
-
27
- - Fixed API client to not parse empty responses from POST endpoints, this was
28
- causing the create sub-command of comment, reaction and step to show an error
29
- message, even though the resource was actually created on the API.
30
-
31
- ## 0.6.0 - 2026-01-25
32
-
33
- ### Features
34
-
35
- #### Reaction Management
36
-
37
- - `fizzy reaction list <card_number> <comment_id>` - List all reactions on a comment
38
- - `fizzy reaction add <card_number> <comment_id> <emoji>` - Add a reaction to a comment
39
- - `fizzy reaction remove <card_number> <comment_id> <reaction_id>` - Remove a reaction from a comment
40
-
41
- #### Step Management
42
-
43
- - `fizzy step create <card_number> --content <text> [--completed]` - Create a new step on a card
44
- - `fizzy step update <card_number> <step_id> [--content <text>] [--completed]` - Update a step
45
- - `fizzy step delete <card_number> <step_id>` - Delete a step from a card
46
-
47
- #### Comment Management
48
-
49
- - `fizzy comment delete <card_number> <comment_id>` - Delete a comment from a card
50
- - `fizzy comment update <card_number> <comment_id> --body <text>` - Update a comment on a card
51
-
52
- ### Improvements
53
-
54
- - Refactored API client logic into separate files for better organization
55
- - Enhanced card update command to use `Flags().Changed()` for better flag handling
56
- - Comprehensive test coverage for all new commands (168 tests total)
57
-
58
- ## 0.5.0 - 2026-01-25
59
-
60
- ### Features
61
-
62
- #### Comment Management
63
-
64
- - `fizzy comment list <card_number>` - List all comments on a card
65
- - `fizzy comment show <card_number> <comment_id>` - Display a specific comment
66
- - `fizzy comment add <card_number> <body>` - Create a new comment on a card
67
-
68
- ### Fixes
69
-
70
- - Fixed error handling in notification read-all command
71
- - Removed global flag usage in some commands
72
-
73
- ## 0.4.0 - 2026-01-19
74
-
75
- ### Features
76
-
77
- #### Card Management
78
-
79
- - `fizzy card not-now <card_number>` - Move a card to "Not Now" status
80
- - `fizzy card untriage <card_number>` - Send a card back to triage
81
- - `fizzy card watch <card_number>` - Subscribe to card notifications
82
- - `fizzy card unwatch <card_number>` - Unsubscribe from card notifications
83
- - `fizzy card golden <card_number>` - Mark a card as golden
84
- - `fizzy card ungolden <card_number>` - Remove golden status from a card
85
-
86
- ## 0.3.0 - 2026-01-11
87
-
88
- ### Features
89
-
90
- #### Notification Management
91
-
92
- - `fizzy notification list` - List all notifications with optional filtering
93
- - `fizzy notification read <notification_id>` - Mark a notification as read and display it
94
- - `fizzy notification unread <notification_id>` - Mark a notification as unread
95
- - `fizzy notification read-all` - Mark all unread notifications as read
96
-
97
- #### Card Management
98
-
99
- - `fizzy card assign <card_number> <user_id>` - Assign or unassign a user to/from a card
100
- - `fizzy card triage <card_number> <column_id>` - Move a card from triage into a column
101
-
102
- ## [0.2.1] - 2025-12-20
103
-
104
- ### Fixes
105
-
106
- - NPM package publishing script
107
-
108
- ## [0.2.0] - 2025-12-20
109
-
110
- ### Features
111
-
112
- #### Card Management
113
-
114
- - `fizzy card update <card_number>` - Update card properties (title, description, status, tags)
115
- - `fizzy card delete <card_number>` - Delete a card permanently
116
- - `fizzy card close <card_number>` - Close an existing card (already existed, now documented)
117
- - `fizzy card reopen <card_number>` - Reopen a closed card (already existed, now documented)
118
-
119
- #### Account Management
120
-
121
- - `fizzy account list` - List all accounts you have access to
122
-
123
- #### Improvements
124
-
125
- - `fizzy board` without arguments now displays the currently selected board
126
- - Added `--version` flag to display CLI version
127
- - Fixed HTTP client leak in API requests
128
- - Updated API specification to latest version
129
-
130
- ## [0.1.0] - 2025-12-16
131
-
132
- ### Initial Release
133
-
134
- The first stable release of Fizzy CLI with core functionality for managing
135
- boards, cards, and columns.
136
-
137
- ### Features
138
-
139
- #### Authentication
140
-
141
- - `fizzy login` - Authenticate with Fizzy API using access tokens
142
-
143
- #### Board Management
144
-
145
- - `fizzy board list` - List all boards
146
- - `fizzy board create` - Create a new board
147
-
148
- #### Card Management
149
-
150
- - `fizzy card list` - List all cards in the selected board
151
- - `fizzy card create` - Create a new card
152
- - `fizzy card show <card_id>` - Display details for a specific card
153
-
154
- #### Column Management
155
-
156
- - `fizzy column list` - List all columns in the selected board
157
- - `fizzy column create` - Create a new column
158
-
159
- #### Configuration
160
-
161
- - `fizzy use --board <name>` - Set the active board for subsequent commands
162
- - `fizzy use --account <slug>` - Set the active account for subsequent commands
163
-
164
- ### Distribution
165
-
166
- - Multi-platform support (macOS, Linux, Windows)
167
- - Multi-architecture binaries (x64, arm64)
168
- - 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
- }