Skip to content

Commit 1496802

Browse files
authored
Merge branch 'develop' into feature/edit-commit-message
2 parents 1624e0f + dd1dbd3 commit 1496802

File tree

5 files changed

+18
-35
lines changed

5 files changed

+18
-35
lines changed

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.PHONY: test
22

33
test:
4-
go generate ./...
54
go test -v ./internal/service

cmd/config.go

+10-17
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,14 @@ func (cm configModel) View() string {
127127
switch cm.configKeySelected {
128128
// 設定項目を選んでいない時
129129
case false:
130-
white := color.New(color.FgWhite).SprintFunc()
131-
b.WriteString(white("設定項目を選んでください:\n"))
132-
b.WriteString(white(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
130+
b.WriteString(color.WhiteString("設定項目を選んでください:\n"))
131+
b.WriteString(color.WhiteString(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
133132

134133
for i, choice := range configKey {
135-
cyan := color.New(color.FgCyan).SprintFunc()
136-
hiCyan := color.New(color.FgHiCyan).SprintFunc()
137134
if i == cm.configKeyIndex {
138-
b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), choice))
135+
b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), choice))
139136
} else {
140-
b.WriteString(fmt.Sprintf(cyan(" %s\n"), choice))
137+
b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), choice))
141138
}
142139
}
143140

@@ -146,26 +143,22 @@ func (cm configModel) View() string {
146143
// 選択肢のない項目はテキストエリアを表示
147144
switch len(configOption[cm.configKeyIndex]) {
148145
case 0:
149-
white := color.New(color.FgWhite).SprintFunc()
150-
b.WriteString(white(fmt.Sprintf(
146+
b.WriteString(color.WhiteString(fmt.Sprintf(
151147
"ここに%sを入力: %s\n",
152148
configKey[cm.configKeyIndex],
153149
cm.textInput.View(),
154150
)))
155-
b.WriteString(white(" Enterキーで確定"))
151+
b.WriteString(color.WhiteString(" Enterキーで確定"))
156152

157153
default:
158-
white := color.New(color.FgWhite).SprintFunc()
159-
b.WriteString(white("設定内容を選んでください:\n"))
160-
b.WriteString(white(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
154+
b.WriteString(color.WhiteString("設定内容を選んでください:\n"))
155+
b.WriteString(color.WhiteString(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
161156

162157
for i, option := range configOptionLabel[cm.configKeyIndex] {
163-
cyan := color.New(color.FgCyan).SprintFunc()
164-
hiCyan := color.New(color.FgHiCyan).SprintFunc()
165158
if i == cm.configOptionIndex {
166-
b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), option))
159+
b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), option))
167160
} else {
168-
b.WriteString(fmt.Sprintf(cyan(" %s\n"), option))
161+
b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), option))
169162
}
170163
}
171164
}

cmd/docs.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
44
package cmd
55

66
import (
7-
"fmt"
8-
97
"github.com/cocoide/commitify/static"
108
"github.com/fatih/color"
119
"github.com/spf13/cobra"
@@ -17,9 +15,7 @@ var docsCmd = &cobra.Command{
1715
Short: "Document of commitify",
1816
Run: func(cmd *cobra.Command, args []string) {
1917
b, _ := static.Logo.ReadFile("logo.txt")
20-
cyan := color.New(color.FgCyan).SprintFunc()
21-
logo := cyan(string(b))
22-
fmt.Println(logo)
18+
color.Cyan(string(b))
2319
},
2420
}
2521

cmd/suggest.go

+7-11
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,28 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
8484

8585
func (m *model) View() string {
8686
if m.errorMsg != "" {
87-
red := color.New(color.FgRed).SprintFunc()
88-
return fmt.Sprintf(red(m.errorMsg))
87+
return color.RedString(m.errorMsg)
8988
}
9089
if m.isLoading {
9190
return "🌎 Generating commit messages ..."
9291
}
9392
var b strings.Builder
9493
if m.errorMsg != "" {
95-
red := color.New(color.FgRed).SprintFunc()
96-
b.WriteString(red(m.errorMsg) + "\n\n")
94+
b.WriteString(color.RedString(m.errorMsg) + "\n\n")
9795
}
9896
if m.isEditing{
9997
return m.textInput.View()
10098
}
10199

102-
white := color.New(color.FgWhite).SprintFunc()
103-
b.WriteString(white("🍕Please select an option:"))
104-
b.WriteString(white("\n Use arrow ↑↓ to navigate and press Enter to select.\n\n"))
100+
b.WriteString(color.WhiteString("🍕Please select an option:"))
101+
b.WriteString(color.WhiteString("\n Use arrow ↑↓ to navigate and press Enter to select.\n\n"))
102+
105103

106104
for i, choice := range m.choices {
107-
cyan := color.New(color.FgCyan).SprintFunc()
108-
hiCyan := color.New(color.FgHiCyan).SprintFunc()
109105
if i == m.currentIdx {
110-
b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), choice))
106+
b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), choice))
111107
} else {
112-
b.WriteString(fmt.Sprintf(cyan(" %s\n"), choice))
108+
b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), choice))
113109
}
114110
}
115111
return b.String()

internal/gateway/openai.go

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/sashabaranov/go-openai"
99
)
1010

11-
//go:generate mockgen -source=openai.go -destination=../../mock/openai.go
1211
type OpenAIGateway interface {
1312
GetAnswerFromPrompt(prompt string, variability float32) (string, error)
1413
AsyncGetAnswerFromPrompt(prompt string, variability float32) <-chan string

0 commit comments

Comments
 (0)