Skip to content

Commit 38dd185

Browse files
author
{cocoide}
committed
chore: refactor
1 parent 6507d4c commit 38dd185

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

cmd/push.go

+12-21
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ type PushCmdStep int
3939

4040
const (
4141
SelectBaseBranch PushCmdStep = iota
42-
ConfirmPR
4342
EditPRTitle
4443
EditPRBody
4544
SubmitPR
@@ -78,11 +77,16 @@ func (m *pushModel) submitPRCmd() tea.Cmd {
7877
func (m *pushModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
7978
var cmd tea.Cmd
8079
switch msg := msg.(type) {
80+
case spinner.TickMsg:
81+
var cmd tea.Cmd
82+
m.spinner, cmd = m.spinner.Update(msg)
83+
return m, cmd
8184
case tea.KeyMsg:
8285
switch msg.Type {
8386
case tea.KeyCtrlC, tea.KeyEsc:
8487
return m, tea.Quit
85-
88+
case tea.KeyCtrlE:
89+
m.step--
8690
}
8791
switch m.step {
8892
case SelectBaseBranch:
@@ -99,17 +103,6 @@ func (m *pushModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
99103
m.loadMsg = "PRを生成中..."
100104
return m, m.generatePRCmd()
101105
}
102-
case ConfirmPR:
103-
switch msg.Type {
104-
case tea.KeyTab:
105-
m.step = EditPRTitle
106-
m.focusInPRTitle()
107-
return m, cmd
108-
case tea.KeyEnter:
109-
m.step = SubmitPR
110-
m.loadMsg = "PRを提出中..."
111-
return m, m.submitPRCmd()
112-
}
113106
case EditPRTitle:
114107
cmd = m.updateTitleInput(msg)
115108
switch msg.Type {
@@ -134,7 +127,8 @@ func (m *pushModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
134127
m.errMsg = fmt.Sprintf("🚨PR生成中にエラーが発生: %v", msg.err)
135128
} else {
136129
m.pr = msg.pr
137-
m.step = ConfirmPR
130+
m.step = EditPRTitle
131+
m.focusInPRTitle()
138132
}
139133
m.finishLoading()
140134
case submitPRMsg:
@@ -158,12 +152,10 @@ func (m *pushModel) View() string {
158152
switch m.step {
159153
case SelectBaseBranch:
160154
return m.buildSelectBaseBranchText()
161-
case ConfirmPR:
162-
return color.HiWhiteString("<生成されたPRの確認: TabKeyで編集, EnterでPush>") + fmt.Sprintf("\n\nTitle:\n%s\n\nBody:\n%s", m.pr.Title, m.pr.Body)
163155
case EditPRTitle:
164-
return color.HiWhiteString("<Titleの編集: Enterで確定>") + fmt.Sprintf("\n\nTitle:\n%s\n\nBody:\n%s", m.prInput.titleInput.View(), m.pr.Body)
156+
return color.HiWhiteString("<Titleの編集: Enterで確定>\n\n") + fmt.Sprintf("Title:\n%s", m.prInput.titleInput.View())
165157
case EditPRBody:
166-
return color.HiWhiteString("<Bodyの編集: EnterでPush>") + fmt.Sprintf("\n\nTitle:\n%s\n\nBody:\n%s", m.pr.Title, m.prInput.bodyInput.View())
158+
return color.HiWhiteString("<Bodyの編集: EnterでPush&PR提出, Ctrl+Eで戻る>\n\n") + fmt.Sprintf("Body:\n%s", m.prInput.bodyInput.View())
167159
case SubmitPR:
168160
return fmt.Sprintf("**🎉PRの作成に成功**")
169161
}
@@ -255,9 +247,8 @@ func (m *pushModel) focusInPRBody() {
255247
input := m.prInput.bodyInput
256248
input.Focus()
257249
input.SetValue(m.pr.Body)
258-
input.CharLimit = 1000
259-
input.SetWidth(100)
260-
input.SetHeight(len(m.pr.Body) / 100)
250+
input.CharLimit = 5000
251+
input.SetWidth(200)
261252
m.prInput.bodyInput = input
262253
}
263254

internal/usecase/push_cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type PushCmdUsecase struct {
1414
}
1515

1616
const (
17-
GeneratePRFromCommitsPrompt = "generate pull request content from commit messages [%s] in Japanese"
17+
GeneratePRFromCommitsPrompt = "generate pull request body from commit messages [%s] in Japanese"
1818
GeneratePRTitleFromPRBody = "generate pull request title from pr body [%s] in Japanese as one sentence like 〇〇の機能追加"
1919
)
2020

0 commit comments

Comments
 (0)