Skip to content

Commit 5f336b8

Browse files
AnnatarHeclaude
andcommitted
refactor(commands): replace briandowns/spinner with stloader
Replace all usages of github.com/briandowns/spinner with the new stloader package. All commands now have consistent visual feedback with the shining text effect. Changes: - grep.go: Use stloader with "Searching commands..." text - auth.go: Use stloader with "Waiting for authentication..." text - query.go: Use stloader with "Querying AI..." text - Remove unused briandowns/spinner dependency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 736dc83 commit 5f336b8

5 files changed

Lines changed: 28 additions & 20 deletions

File tree

commands/auth.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"os"
99
"time"
1010

11-
"github.com/briandowns/spinner"
11+
"github.com/malamtime/cli/stloader"
1212
"github.com/gookit/color"
1313
"github.com/invopop/jsonschema"
1414
"github.com/malamtime/cli/model"
@@ -118,22 +118,27 @@ func ApplyTokenByHandshake(_ctx context.Context, config model.ShellTimeConfig) (
118118

119119
color.Green.Println(fmt.Sprintf("Open %s to continue", feLink))
120120

121-
s := spinner.New(spinner.CharSets[35], 200*time.Millisecond)
122-
s.Start()
121+
l := stloader.NewLoader(stloader.LoaderConfig{
122+
Text: "Waiting for authentication...",
123+
EnableShining: true,
124+
BaseColor: stloader.RGB{R: 100, G: 180, B: 255},
125+
})
126+
l.Start()
123127
for {
124128
if time.Since(startedAt) > 10*time.Minute {
129+
l.Stop()
125130
color.Red.Println(" ❌ Failed to authenticate. Please retry with `shelltime init` or contact shelltime team (annatar.he+shelltime.xyz@gmail.com)")
126-
s.Stop()
127131
return "", fmt.Errorf("authentication timeout")
128132
}
129133

130134
token, err := hs.Check(ctx, hid)
131135
if err != nil {
136+
l.Stop()
132137
return "", err
133138
}
134139
if token != "" {
140+
l.Stop()
135141
color.Green.Println(" ✅ You are ready to go!")
136-
s.Stop()
137142
return token, nil
138143
}
139144

commands/grep.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strconv"
99
"time"
1010

11-
"github.com/briandowns/spinner"
11+
"github.com/malamtime/cli/stloader"
1212
"github.com/gookit/color"
1313
"github.com/malamtime/cli/model"
1414
"github.com/olekukonko/tablewriter"
@@ -136,13 +136,16 @@ func commandGrep(c *cli.Context) error {
136136
slog.Int("lastId", pagination.LastID))
137137

138138
// Show loading spinner
139-
s := spinner.New(spinner.CharSets[35], 200*time.Millisecond)
140-
s.Suffix = " Searching commands..."
141-
s.Start()
139+
l := stloader.NewLoader(stloader.LoaderConfig{
140+
Text: "Searching commands...",
141+
EnableShining: true,
142+
BaseColor: stloader.RGB{R: 100, G: 180, B: 255},
143+
})
144+
l.Start()
142145

143146
// Fetch commands from server
144147
result, err := model.FetchCommandsFromServer(ctx, endpoint, filter, pagination)
145-
s.Stop()
148+
l.Stop()
146149
if err != nil {
147150
if format == "json" {
148151
errOutput := struct {

commands/query.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import (
88
"os/exec"
99
"runtime"
1010
"strings"
11-
"time"
1211

13-
"github.com/briandowns/spinner"
12+
"github.com/malamtime/cli/stloader"
1413
"github.com/gookit/color"
1514
"github.com/malamtime/cli/model"
1615
"github.com/urfave/cli/v2"
@@ -54,22 +53,26 @@ func commandQuery(c *cli.Context) error {
5453
slog.Warn("Failed to get system context", slog.Any("err", err))
5554
}
5655

57-
s := spinner.New(spinner.CharSets[35], 200*time.Millisecond)
58-
s.Start()
59-
defer s.Stop()
56+
l := stloader.NewLoader(stloader.LoaderConfig{
57+
Text: "Querying AI...",
58+
EnableShining: true,
59+
BaseColor: stloader.RGB{R: 100, G: 180, B: 255},
60+
})
61+
l.Start()
62+
defer l.Stop()
6063

6164
// skip userId for now
6265
userId := ""
6366

6467
// Query the AI
6568
newCommand, err := aiService.QueryCommand(ctx, systemContext, userId)
6669
if err != nil {
67-
s.Stop()
70+
l.Stop()
6871
color.Red.Printf("❌ Failed to query AI: %v\n", err)
6972
return err
7073
}
7174

72-
s.Stop()
75+
l.Stop()
7376

7477
// Trim the command
7578
newCommand = strings.TrimSpace(newCommand)

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.25
55
require (
66
github.com/PromptPal/go-sdk v0.4.2
77
github.com/ThreeDotsLabs/watermill v1.5.1
8-
github.com/briandowns/spinner v1.23.2
98
github.com/go-git/go-git/v5 v5.16.4
109
github.com/google/uuid v1.6.0
1110
github.com/gookit/color v1.6.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ github.com/ThreeDotsLabs/watermill v1.5.1/go.mod h1:Uop10dA3VeJWsSvis9qO3vbVY892
2828
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
2929
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
3030
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
31-
github.com/briandowns/spinner v1.23.2 h1:Zc6ecUnI+YzLmJniCfDNaMbW0Wid1d5+qcTq4L2FW8w=
32-
github.com/briandowns/spinner v1.23.2/go.mod h1:LaZeM4wm2Ywy6vO571mvhQNRcWfRUnXOs0RcKV0wYKM=
3331
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
3432
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
3533
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=

0 commit comments

Comments
 (0)