diff --git a/cmd/config.go b/cmd/config.go index 6da51ad..1f949d3 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -120,17 +120,14 @@ func (cm configModel) View() string { switch cm.configKeySelected { // 設定項目を選んでいない時 case false: - white := color.New(color.FgWhite).SprintFunc() - b.WriteString(white("設定項目を選んでください:\n")) - b.WriteString(white(" ↑↓の矢印キーで項目を移動、Enterで選択\n")) + b.WriteString(color.WhiteString("設定項目を選んでください:\n")) + b.WriteString(color.WhiteString(" ↑↓の矢印キーで項目を移動、Enterで選択\n")) for i, choice := range configKey { - cyan := color.New(color.FgCyan).SprintFunc() - hiCyan := color.New(color.FgHiCyan).SprintFunc() if i == cm.configKeyIndex { - b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), choice)) + b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), choice)) } else { - b.WriteString(fmt.Sprintf(cyan(" %s\n"), choice)) + b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), choice)) } } @@ -139,26 +136,22 @@ func (cm configModel) View() string { // 選択肢のない項目はテキストエリアを表示 switch len(configOption[cm.configKeyIndex]) { case 0: - white := color.New(color.FgWhite).SprintFunc() - b.WriteString(white(fmt.Sprintf( + b.WriteString(color.WhiteString(fmt.Sprintf( "ここに%sを入力: %s\n", configKey[cm.configKeyIndex], cm.textInput.View(), ))) - b.WriteString(white(" Enterキーで確定")) + b.WriteString(color.WhiteString(" Enterキーで確定")) default: - white := color.New(color.FgWhite).SprintFunc() - b.WriteString(white("設定内容を選んでください:\n")) - b.WriteString(white(" ↑↓の矢印キーで項目を移動、Enterで選択\n")) + b.WriteString(color.WhiteString("設定内容を選んでください:\n")) + b.WriteString(color.WhiteString(" ↑↓の矢印キーで項目を移動、Enterで選択\n")) for i, option := range configOption[cm.configKeyIndex] { - cyan := color.New(color.FgCyan).SprintFunc() - hiCyan := color.New(color.FgHiCyan).SprintFunc() if i == cm.configOptionIndex { - b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), option)) + b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), option)) } else { - b.WriteString(fmt.Sprintf(cyan(" %s\n"), option)) + b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), option)) } } } diff --git a/cmd/docs.go b/cmd/docs.go index d7e40f9..4fe1125 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -4,8 +4,6 @@ Copyright © 2023 NAME HERE package cmd import ( - "fmt" - "github.com/cocoide/commitify/static" "github.com/fatih/color" "github.com/spf13/cobra" @@ -17,9 +15,7 @@ var docsCmd = &cobra.Command{ Short: "Document of commitify", Run: func(cmd *cobra.Command, args []string) { b, _ := static.Logo.ReadFile("logo.txt") - cyan := color.New(color.FgCyan).SprintFunc() - logo := cyan(string(b)) - fmt.Println(logo) + color.Cyan(string(b)) }, } diff --git a/cmd/suggest.go b/cmd/suggest.go index b1dac8c..a471aa7 100644 --- a/cmd/suggest.go +++ b/cmd/suggest.go @@ -76,28 +76,23 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m model) View() string { if m.errorMsg != "" { - red := color.New(color.FgRed).SprintFunc() - return fmt.Sprintf(red(m.errorMsg)) + return color.RedString(m.errorMsg) } if m.isLoading { return "🌎 Generating commit messages ..." } var b strings.Builder if m.errorMsg != "" { - red := color.New(color.FgRed).SprintFunc() - b.WriteString(red(m.errorMsg) + "\n\n") + b.WriteString(color.RedString(m.errorMsg) + "\n\n") } - white := color.New(color.FgWhite).SprintFunc() - b.WriteString(white("🍕Please select an option:")) - b.WriteString(white("\n Use arrow ↑↓ to navigate and press Enter to select.\n\n")) + b.WriteString(color.WhiteString("🍕Please select an option:")) + b.WriteString(color.WhiteString("\n Use arrow ↑↓ to navigate and press Enter to select.\n\n")) for i, choice := range m.choices { - cyan := color.New(color.FgCyan).SprintFunc() - hiCyan := color.New(color.FgHiCyan).SprintFunc() if i == m.currentIdx { - b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), choice)) + b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), choice)) } else { - b.WriteString(fmt.Sprintf(cyan(" %s\n"), choice)) + b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), choice)) } } return b.String()