Skip to content

Commit de3c54c

Browse files
Small code cleanup
1 parent 888ad24 commit de3c54c

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

cmd/config.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/charmbracelet/log"
87
"github.com/spf13/cobra"
98
"github.com/spf13/viper"
109
)
@@ -47,7 +46,7 @@ var getCmd = &cobra.Command{
4746
config, err := loadConfig(path)
4847

4948
if err != nil {
50-
log.Fatal("cannot load config:", err)
49+
panic(fmt.Errorf("cannot load config file: %w", err))
5150
}
5251
fmt.Println("OPENAI_API_KEY=",config.OpenAIAPIKey)
5352

cmd/root.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ func InitConfig() {
5353
} else if errors.Is(err, os.ErrNotExist) {
5454
if err := viper.SafeWriteConfig(); err != nil {
5555
if err != nil {
56-
str := fmt.Sprintf("could not write config file: %v", err)
57-
panic(str)
56+
panic(fmt.Sprintf("could not write config file: %v", err))
5857
}
5958
}
6059
}

cmd/run.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"github.com/charmbracelet/bubbles/viewport"
1414
tea "github.com/charmbracelet/bubbletea"
1515

16-
// "golang.org/x/term"
17-
1816
"github.com/charmbracelet/lipgloss"
1917
"github.com/charmbracelet/log"
2018
"github.com/enescakir/emoji"
@@ -163,7 +161,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
163161
}
164162
case "enter":
165163
switch m.currentView {
166-
// View to confirm that the detected languages are correct
164+
// Confirm that the detected languages are correct
167165
case ConfirmLanguages:
168166
if m.choice == "yes" {
169167
m.additionalProjectInfo.Blur()
@@ -173,13 +171,13 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
173171
m.additionalProjectInfo.Focus()
174172
m.currentView = CorrectLanguages
175173
}
176-
// View to correct the detected languages (when Ghost was wrong or more details are needed)
174+
// Correct the detected languages (when Ghost was wrong or more details are needed)
177175
case CorrectLanguages:
178176
if m.additionalProjectInfo.Value() != "" {
179177
m.currentView = Preload
180178
m.choice = "yes"
181179
}
182-
// View to allow the user to specify what tasks they'd like to do in their pipeline
180+
// Allow the user to specify what tasks they'd like to do in their pipeline
183181
case InputTasks, CorrectGHA:
184182
if m.desiredTasks.Value() != "" {
185183
m.currentView = LoadingGHA
@@ -280,7 +278,7 @@ func (m model) View() string {
280278
log.Error("Error: detected languages is empty")
281279
return ""
282280
}
283-
return textInputView(m, fmt.Sprintf("%v What tasks should Ghost include in your GitHub Action workflow?", emoji.Ghost), m.desiredTasks)
281+
return textInputView(m, fmt.Sprintf("%v What tasks should Ghost include in your GitHub Actions workflow?", emoji.Ghost), m.desiredTasks)
284282
case GenerateGHA:
285283
if len(m.GHAWorkflow) == 0 {
286284
log.Error("Error: detected languages or desired tasks is empty")
@@ -289,7 +287,7 @@ func (m model) View() string {
289287
return confirmationView(m,
290288
"",
291289
"Great! Output to .github/workflows/ghost.yml",
292-
"I want Ghost to refine to generated GHA workflow",
290+
"I want Ghost to refine to generated GitHub Actions workflow",
293291
true,
294292
m.GHAWorkflow)
295293
case CorrectGHA:

0 commit comments

Comments
 (0)