Skip to content

Commit 53cd10d

Browse files
authored
Merge pull request #41 from cocoide/feature/34-create-style-pkg
Colorの変更
2 parents ee720e3 + 294138d commit 53cd10d

File tree

3 files changed

+17
-33
lines changed

3 files changed

+17
-33
lines changed

cmd/config.go

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,14 @@ func (cm configModel) View() string {
120120
switch cm.configKeySelected {
121121
// 設定項目を選んでいない時
122122
case false:
123-
white := color.New(color.FgWhite).SprintFunc()
124-
b.WriteString(white("設定項目を選んでください:\n"))
125-
b.WriteString(white(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
123+
b.WriteString(color.WhiteString("設定項目を選んでください:\n"))
124+
b.WriteString(color.WhiteString(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
126125

127126
for i, choice := range configKey {
128-
cyan := color.New(color.FgCyan).SprintFunc()
129-
hiCyan := color.New(color.FgHiCyan).SprintFunc()
130127
if i == cm.configKeyIndex {
131-
b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), choice))
128+
b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), choice))
132129
} else {
133-
b.WriteString(fmt.Sprintf(cyan(" %s\n"), choice))
130+
b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), choice))
134131
}
135132
}
136133

@@ -139,26 +136,22 @@ func (cm configModel) View() string {
139136
// 選択肢のない項目はテキストエリアを表示
140137
switch len(configOption[cm.configKeyIndex]) {
141138
case 0:
142-
white := color.New(color.FgWhite).SprintFunc()
143-
b.WriteString(white(fmt.Sprintf(
139+
b.WriteString(color.WhiteString(fmt.Sprintf(
144140
"ここに%sを入力: %s\n",
145141
configKey[cm.configKeyIndex],
146142
cm.textInput.View(),
147143
)))
148-
b.WriteString(white(" Enterキーで確定"))
144+
b.WriteString(color.WhiteString(" Enterキーで確定"))
149145

150146
default:
151-
white := color.New(color.FgWhite).SprintFunc()
152-
b.WriteString(white("設定内容を選んでください:\n"))
153-
b.WriteString(white(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
147+
b.WriteString(color.WhiteString("設定内容を選んでください:\n"))
148+
b.WriteString(color.WhiteString(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
154149

155150
for i, option := range configOption[cm.configKeyIndex] {
156-
cyan := color.New(color.FgCyan).SprintFunc()
157-
hiCyan := color.New(color.FgHiCyan).SprintFunc()
158151
if i == cm.configOptionIndex {
159-
b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), option))
152+
b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), option))
160153
} else {
161-
b.WriteString(fmt.Sprintf(cyan(" %s\n"), option))
154+
b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), option))
162155
}
163156
}
164157
}

cmd/docs.go

Lines changed: 1 addition & 5 deletions
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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,23 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
7676

7777
func (m model) View() string {
7878
if m.errorMsg != "" {
79-
red := color.New(color.FgRed).SprintFunc()
80-
return fmt.Sprintf(red(m.errorMsg))
79+
return color.RedString(m.errorMsg)
8180
}
8281
if m.isLoading {
8382
return "🌎 Generating commit messages ..."
8483
}
8584
var b strings.Builder
8685
if m.errorMsg != "" {
87-
red := color.New(color.FgRed).SprintFunc()
88-
b.WriteString(red(m.errorMsg) + "\n\n")
86+
b.WriteString(color.RedString(m.errorMsg) + "\n\n")
8987
}
90-
white := color.New(color.FgWhite).SprintFunc()
91-
b.WriteString(white("🍕Please select an option:"))
92-
b.WriteString(white("\n Use arrow ↑↓ to navigate and press Enter to select.\n\n"))
88+
b.WriteString(color.WhiteString("🍕Please select an option:"))
89+
b.WriteString(color.WhiteString("\n Use arrow ↑↓ to navigate and press Enter to select.\n\n"))
9390

9491
for i, choice := range m.choices {
95-
cyan := color.New(color.FgCyan).SprintFunc()
96-
hiCyan := color.New(color.FgHiCyan).SprintFunc()
9792
if i == m.currentIdx {
98-
b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), choice))
93+
b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), choice))
9994
} else {
100-
b.WriteString(fmt.Sprintf(cyan(" %s\n"), choice))
95+
b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), choice))
10196
}
10297
}
10398
return b.String()

0 commit comments

Comments
 (0)