Skip to content

gRPCのサーバを接続 / 設定情報をenumで定義 #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 10, 2023
Prev Previous commit
fix: configの設定を修正
jsonのkeyとしてアンダースコアを用いていると、うまくデコードできないもよう。
  • Loading branch information
mochi-yu committed Sep 10, 2023
commit 3bb264d894eeb68693f489708e8127eb6b9cf24e
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
@@ -15,13 +15,13 @@ var (
configKey = [...]string{"api-key", "language", "format", "ai-source"}
configOption = [][]int{
{},
{int(entity.JP), int(entity.EN)},
{int(entity.EN), int(entity.JP)},
{int(entity.NormalFormat), int(entity.EmojiFormat), int(entity.PrefixFormat)},
{int(entity.WrapServer), int(entity.OpenAiAPI)},
}
configOptionLabel = [][]string{
{},
{"Japanese", "English"},
{"English", "Japanese"},
{"Normal Format", "Emoji Format", "PrefixFormat"},
{"Wrap Server", "OpenAI API"},
}
16 changes: 8 additions & 8 deletions internal/entity/config.go
Original file line number Diff line number Diff line change
@@ -11,16 +11,16 @@ import (
type Language int

const (
JP Language = iota
EN
EN Language = iota
JP
)

type CodeFormat int

const (
EmojiFormat CodeFormat = iota
NormalFormat CodeFormat = iota
EmojiFormat
PrefixFormat
NormalFormat
)

type AISource int
@@ -31,10 +31,10 @@ const (
)

type Config struct {
ChatGptApiKey string `json:"chatGpt_ApiKey"`
UseLanguage int `json:"Use_Language"`
CommitFormat int `json:"Commit_Format"`
AISource int `json:"AI_Source"`
ChatGptApiKey string `json:"chatGptApiKey"`
UseLanguage int `json:"UseLanguage"`
CommitFormat int `json:"CommitFormat"`
AISource int `json:"AISource"`
}

func (c *Config) Config2PbVars() (pb.CodeFormatType, pb.LanguageType) {