Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions cmd/loadertest/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"fmt"
"time"

"github.com/malamtime/cli/stloader"
)

func main() {
fmt.Println("Testing stloader package...")
fmt.Println()

// Test with shining effect
l := stloader.NewLoader(stloader.LoaderConfig{
Text: "Processing your request, please wait...",
EnableShining: true,
BaseColor: stloader.RGB{R: 100, G: 180, B: 255}, // Light blue
ShineInterval: 100 * time.Millisecond,
SpinInterval: 150 * time.Millisecond,
})

l.Start()
time.Sleep(10 * time.Second)
l.Stop()

fmt.Println()
fmt.Println("Done!")
}
15 changes: 10 additions & 5 deletions commands/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"time"

"github.com/briandowns/spinner"
"github.com/malamtime/cli/stloader"
"github.com/gookit/color"
"github.com/invopop/jsonschema"
"github.com/malamtime/cli/model"
Expand Down Expand Up @@ -118,22 +118,27 @@ func ApplyTokenByHandshake(_ctx context.Context, config model.ShellTimeConfig) (

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

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

token, err := hs.Check(ctx, hid)
if err != nil {
l.Stop()
return "", err
}
if token != "" {
l.Stop()
color.Green.Println(" ✅ You are ready to go!")
s.Stop()
return token, nil
}

Expand Down
13 changes: 8 additions & 5 deletions commands/grep.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"time"

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

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

// Fetch commands from server
result, err := model.FetchCommandsFromServer(ctx, endpoint, filter, pagination)
s.Stop()
l.Stop()
if err != nil {
if format == "json" {
errOutput := struct {
Expand Down
17 changes: 10 additions & 7 deletions commands/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (
"os/exec"
"runtime"
"strings"
"time"

"github.com/briandowns/spinner"
"github.com/malamtime/cli/stloader"
"github.com/gookit/color"
"github.com/malamtime/cli/model"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -54,22 +53,26 @@ func commandQuery(c *cli.Context) error {
slog.Warn("Failed to get system context", slog.Any("err", err))
}

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

// skip userId for now
userId := ""

// Query the AI
newCommand, err := aiService.QueryCommand(ctx, systemContext, userId)
if err != nil {
s.Stop()
l.Stop()
color.Red.Printf("❌ Failed to query AI: %v\n", err)
return err
}

s.Stop()
l.Stop()

// Trim the command
newCommand = strings.TrimSpace(newCommand)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.25
require (
github.com/PromptPal/go-sdk v0.4.2
github.com/ThreeDotsLabs/watermill v1.5.1
github.com/briandowns/spinner v1.23.2
github.com/go-git/go-git/v5 v5.16.4
github.com/google/uuid v1.6.0
github.com/gookit/color v1.6.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ github.com/ThreeDotsLabs/watermill v1.5.1/go.mod h1:Uop10dA3VeJWsSvis9qO3vbVY892
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/briandowns/spinner v1.23.2 h1:Zc6ecUnI+YzLmJniCfDNaMbW0Wid1d5+qcTq4L2FW8w=
github.com/briandowns/spinner v1.23.2/go.mod h1:LaZeM4wm2Ywy6vO571mvhQNRcWfRUnXOs0RcKV0wYKM=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
Expand Down
Loading
Loading