Skip to content

Commit 621cd11

Browse files
committed
feat: add spinner for git message generation
1 parent b114171 commit 621cd11

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cmds/fastcommit/cmd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package fastcommit
33
import (
44
"context"
55
"fmt"
6+
"github.com/briandowns/spinner"
67
"log/slog"
78
"os"
89
"sort"
910
"strings"
11+
"time"
1012

1113
tea "github.com/charmbracelet/bubbletea"
1214
"github.com/charmbracelet/x/term"
@@ -83,6 +85,10 @@ func New(params Params) *Command {
8385

8486
slog.Info(utils.GetDetectedMessage(diff.Files))
8587

88+
s := spinner.New(spinner.CharSets[35], 100*time.Millisecond, func(s *spinner.Spinner) {
89+
s.Prefix = "generate git message: "
90+
})
91+
s.Start()
8692
resp, err := params.OpenaiClient.Client.CreateChatCompletion(
8793
context.Background(),
8894
openai.ChatCompletionRequest{
@@ -99,6 +105,7 @@ func New(params Params) *Command {
99105
},
100106
},
101107
)
108+
s.Stop()
102109

103110
if err != nil {
104111
slog.Error("failed to call openai", "err", err)

utils/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func GetDetectedMessage(files []string) string {
7272
if fileCount > 1 {
7373
pluralSuffix = "s"
7474
}
75-
return fmt.Sprintf("Detected %d staged file%s\n%s", fileCount, pluralSuffix, strings.Join(files, "\n"))
75+
return fmt.Sprintf("detected %d staged file%s\n%s", fileCount, pluralSuffix, strings.Join(files, "\n"))
7676
}
7777

7878
func GitPushTag(ver string) {

0 commit comments

Comments
 (0)