Skip to content

Commit 9404695

Browse files
authored
Merge pull request #99 from basecamp/rz/auto-postpone-period-in-days
Support auto_postpone_period_in_days and entropy endpoints
2 parents e6ecba1 + 44258b0 commit 9404695

10 files changed

Lines changed: 556 additions & 27 deletions

File tree

SURFACE.txt

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
CMD fizzy
2+
CMD fizzy account
3+
CMD fizzy account entropy
4+
CMD fizzy account help
5+
CMD fizzy account show
26
CMD fizzy auth
37
CMD fizzy auth help
48
CMD fizzy auth list
@@ -9,6 +13,7 @@ CMD fizzy auth switch
913
CMD fizzy board
1014
CMD fizzy board create
1115
CMD fizzy board delete
16+
CMD fizzy board entropy
1217
CMD fizzy board help
1318
CMD fizzy board list
1419
CMD fizzy board publish
@@ -136,6 +141,59 @@ FLAG fizzy --quiet type=bool
136141
FLAG fizzy --styled type=bool
137142
FLAG fizzy --token type=string
138143
FLAG fizzy --verbose type=bool
144+
FLAG fizzy account --agent type=bool
145+
FLAG fizzy account --api-url type=string
146+
FLAG fizzy account --count type=bool
147+
FLAG fizzy account --help type=bool
148+
FLAG fizzy account --ids-only type=bool
149+
FLAG fizzy account --json type=bool
150+
FLAG fizzy account --limit type=int
151+
FLAG fizzy account --markdown type=bool
152+
FLAG fizzy account --profile type=string
153+
FLAG fizzy account --quiet type=bool
154+
FLAG fizzy account --styled type=bool
155+
FLAG fizzy account --token type=string
156+
FLAG fizzy account --verbose type=bool
157+
FLAG fizzy account entropy --agent type=bool
158+
FLAG fizzy account entropy --api-url type=string
159+
FLAG fizzy account entropy --auto_postpone_period_in_days type=int
160+
FLAG fizzy account entropy --count type=bool
161+
FLAG fizzy account entropy --help type=bool
162+
FLAG fizzy account entropy --ids-only type=bool
163+
FLAG fizzy account entropy --json type=bool
164+
FLAG fizzy account entropy --limit type=int
165+
FLAG fizzy account entropy --markdown type=bool
166+
FLAG fizzy account entropy --profile type=string
167+
FLAG fizzy account entropy --quiet type=bool
168+
FLAG fizzy account entropy --styled type=bool
169+
FLAG fizzy account entropy --token type=string
170+
FLAG fizzy account entropy --verbose type=bool
171+
FLAG fizzy account help --agent type=bool
172+
FLAG fizzy account help --api-url type=string
173+
FLAG fizzy account help --count type=bool
174+
FLAG fizzy account help --help type=bool
175+
FLAG fizzy account help --ids-only type=bool
176+
FLAG fizzy account help --json type=bool
177+
FLAG fizzy account help --limit type=int
178+
FLAG fizzy account help --markdown type=bool
179+
FLAG fizzy account help --profile type=string
180+
FLAG fizzy account help --quiet type=bool
181+
FLAG fizzy account help --styled type=bool
182+
FLAG fizzy account help --token type=string
183+
FLAG fizzy account help --verbose type=bool
184+
FLAG fizzy account show --agent type=bool
185+
FLAG fizzy account show --api-url type=string
186+
FLAG fizzy account show --count type=bool
187+
FLAG fizzy account show --help type=bool
188+
FLAG fizzy account show --ids-only type=bool
189+
FLAG fizzy account show --json type=bool
190+
FLAG fizzy account show --limit type=int
191+
FLAG fizzy account show --markdown type=bool
192+
FLAG fizzy account show --profile type=string
193+
FLAG fizzy account show --quiet type=bool
194+
FLAG fizzy account show --styled type=bool
195+
FLAG fizzy account show --token type=string
196+
FLAG fizzy account show --verbose type=bool
139197
FLAG fizzy auth --agent type=bool
140198
FLAG fizzy auth --api-url type=string
141199
FLAG fizzy auth --count type=bool
@@ -244,7 +302,7 @@ FLAG fizzy board --verbose type=bool
244302
FLAG fizzy board create --agent type=bool
245303
FLAG fizzy board create --all_access type=string
246304
FLAG fizzy board create --api-url type=string
247-
FLAG fizzy board create --auto_postpone_period type=int
305+
FLAG fizzy board create --auto_postpone_period_in_days type=int
248306
FLAG fizzy board create --count type=bool
249307
FLAG fizzy board create --help type=bool
250308
FLAG fizzy board create --ids-only type=bool
@@ -270,6 +328,20 @@ FLAG fizzy board delete --quiet type=bool
270328
FLAG fizzy board delete --styled type=bool
271329
FLAG fizzy board delete --token type=string
272330
FLAG fizzy board delete --verbose type=bool
331+
FLAG fizzy board entropy --agent type=bool
332+
FLAG fizzy board entropy --api-url type=string
333+
FLAG fizzy board entropy --auto_postpone_period_in_days type=int
334+
FLAG fizzy board entropy --count type=bool
335+
FLAG fizzy board entropy --help type=bool
336+
FLAG fizzy board entropy --ids-only type=bool
337+
FLAG fizzy board entropy --json type=bool
338+
FLAG fizzy board entropy --limit type=int
339+
FLAG fizzy board entropy --markdown type=bool
340+
FLAG fizzy board entropy --profile type=string
341+
FLAG fizzy board entropy --quiet type=bool
342+
FLAG fizzy board entropy --styled type=bool
343+
FLAG fizzy board entropy --token type=string
344+
FLAG fizzy board entropy --verbose type=bool
273345
FLAG fizzy board help --agent type=bool
274346
FLAG fizzy board help --api-url type=string
275347
FLAG fizzy board help --count type=bool
@@ -340,7 +412,7 @@ FLAG fizzy board unpublish --verbose type=bool
340412
FLAG fizzy board update --agent type=bool
341413
FLAG fizzy board update --all_access type=string
342414
FLAG fizzy board update --api-url type=string
343-
FLAG fizzy board update --auto_postpone_period type=int
415+
FLAG fizzy board update --auto_postpone_period_in_days type=int
344416
FLAG fizzy board update --count type=bool
345417
FLAG fizzy board update --help type=bool
346418
FLAG fizzy board update --ids-only type=bool
@@ -1869,6 +1941,10 @@ FLAG fizzy webhook update --quiet type=bool
18691941
FLAG fizzy webhook update --styled type=bool
18701942
FLAG fizzy webhook update --token type=string
18711943
FLAG fizzy webhook update --verbose type=bool
1944+
SUB fizzy account
1945+
SUB fizzy account entropy
1946+
SUB fizzy account help
1947+
SUB fizzy account show
18721948
SUB fizzy auth
18731949
SUB fizzy auth help
18741950
SUB fizzy auth list
@@ -1879,6 +1955,7 @@ SUB fizzy auth switch
18791955
SUB fizzy board
18801956
SUB fizzy board create
18811957
SUB fizzy board delete
1958+
SUB fizzy board entropy
18821959
SUB fizzy board help
18831960
SUB fizzy board list
18841961
SUB fizzy board publish

e2e/tests/board_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ func TestBoardCreateWithOptions(t *testing.T) {
302302
}
303303
})
304304

305-
t.Run("create board with auto_postpone_period", func(t *testing.T) {
305+
t.Run("create board with auto_postpone_period_in_days", func(t *testing.T) {
306306
name := fmt.Sprintf("Auto Postpone Board %d", time.Now().UnixNano())
307-
result := h.Run("board", "create", "--name", name, "--auto_postpone_period", "7")
307+
result := h.Run("board", "create", "--name", name, "--auto_postpone_period_in_days", "7")
308308

309309
if result.ExitCode != harness.ExitSuccess {
310310
t.Fatalf("expected exit code %d, got %d\nstderr: %s", harness.ExitSuccess, result.ExitCode, result.Stderr)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.26
44

55
require (
66
github.com/basecamp/cli v0.1.1
7-
github.com/basecamp/fizzy-sdk/go v0.1.0
7+
github.com/basecamp/fizzy-sdk/go v0.1.2
88
github.com/charmbracelet/huh v1.0.0
99
github.com/charmbracelet/lipgloss v1.1.0
1010
github.com/charmbracelet/x/term v0.2.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3v
1010
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
1111
github.com/basecamp/cli v0.1.1 h1:FAF3M09xo1m7gJJXf38glCkT50ZUuvz+31f+c3R3zcc=
1212
github.com/basecamp/cli v0.1.1/go.mod h1:NTHe+keCTGI2qM5sMXdkUN0QgU3zGbwnBxcmg8vD5QU=
13-
github.com/basecamp/fizzy-sdk/go v0.1.0 h1:mZaFrOUnbPzaY/5NTWHahjc7p+yVLMvcNFICfa2eARw=
14-
github.com/basecamp/fizzy-sdk/go v0.1.0/go.mod h1:HpiKRY9LpWobnxISmFM0I6/Tw+Br00mnDm9vcct8IH8=
13+
github.com/basecamp/fizzy-sdk/go v0.1.2 h1:AX6ToXC2AI6iy+fvI02+W/Sk7Ar3bE9n4Clg+d5BDqM=
14+
github.com/basecamp/fizzy-sdk/go v0.1.2/go.mod h1:HpiKRY9LpWobnxISmFM0I6/Tw+Br00mnDm9vcct8IH8=
1515
github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY=
1616
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
1717
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws=

internal/commands/account.go

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package commands
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/basecamp/fizzy-sdk/go/pkg/generated"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var accountCmd = &cobra.Command{
11+
Use: "account",
12+
Short: "Manage account settings",
13+
Long: "Commands for managing account settings.",
14+
}
15+
16+
var accountShowCmd = &cobra.Command{
17+
Use: "show",
18+
Short: "Show account settings",
19+
Long: "Shows the current account settings including auto-postpone period.",
20+
RunE: func(cmd *cobra.Command, args []string) error {
21+
if err := requireAuthAndAccount(); err != nil {
22+
return err
23+
}
24+
25+
data, _, err := getSDK().Account().GetSettings(cmd.Context())
26+
if err != nil {
27+
return convertSDKError(err)
28+
}
29+
30+
items := normalizeAny(data)
31+
32+
summary := "Account"
33+
if account, ok := items.(map[string]any); ok {
34+
if name, ok := account["name"].(string); ok && name != "" {
35+
summary = fmt.Sprintf("Account: %s", name)
36+
}
37+
}
38+
39+
breadcrumbs := []Breadcrumb{
40+
breadcrumb("boards", "fizzy board list", "List boards"),
41+
breadcrumb("entropy", "fizzy account entropy --auto_postpone_period_in_days N", "Update auto-postpone period"),
42+
}
43+
44+
printDetail(items, summary, breadcrumbs)
45+
return nil
46+
},
47+
}
48+
49+
// Account entropy flags
50+
var accountEntropyAutoPostponePeriodInDays int
51+
52+
var accountEntropyCmd = &cobra.Command{
53+
Use: "entropy",
54+
Short: "Update account auto-postpone period",
55+
Long: "Updates the account-level default auto-postpone period. Requires admin role.",
56+
RunE: func(cmd *cobra.Command, args []string) error {
57+
if err := requireAuthAndAccount(); err != nil {
58+
return err
59+
}
60+
61+
if accountEntropyAutoPostponePeriodInDays == 0 {
62+
return newRequiredFlagError("auto_postpone_period_in_days")
63+
}
64+
if err := validateAutoPostponePeriodInDays(accountEntropyAutoPostponePeriodInDays); err != nil {
65+
return err
66+
}
67+
68+
req := &generated.UpdateAccountEntropyRequest{
69+
AutoPostponePeriodInDays: int32(accountEntropyAutoPostponePeriodInDays),
70+
}
71+
72+
data, _, err := getSDK().Account().UpdateEntropy(cmd.Context(), req)
73+
if err != nil {
74+
return convertSDKError(err)
75+
}
76+
77+
breadcrumbs := []Breadcrumb{
78+
breadcrumb("show", "fizzy account show", "View account settings"),
79+
breadcrumb("boards", "fizzy board list", "List boards"),
80+
}
81+
82+
printMutation(normalizeAny(data), "", breadcrumbs)
83+
return nil
84+
},
85+
}
86+
87+
func init() {
88+
rootCmd.AddCommand(accountCmd)
89+
90+
// Show
91+
accountCmd.AddCommand(accountShowCmd)
92+
93+
// Entropy
94+
accountEntropyCmd.Flags().IntVar(&accountEntropyAutoPostponePeriodInDays, "auto_postpone_period_in_days", 0, "Auto postpone period in days ("+validAutoPostponePeriodsHelp+")")
95+
accountCmd.AddCommand(accountEntropyCmd)
96+
}

0 commit comments

Comments
 (0)