Skip to content

Commit

Permalink
fix: abort if interrupte the question prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Dec 2, 2023
1 parent 5e8ee84 commit b613106
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lang/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
"github.com/charmbracelet/log"
"github.com/spf13/viper"

Expand Down Expand Up @@ -108,6 +109,9 @@ func generate(q *leetcode.QuestionData) (Lang, *GenerateResult, error) {
// Write files
for i, file := range result.Files {
written, err := tryWrite(file.GetPath(), file.Content)
if errors.Is(err, terminal.InterruptErr) {
return nil, nil, err
}
if err != nil {
log.Error("failed to write file", "path", utils.RelToCwd(file.GetPath()), "err", err)
continue
Expand Down

0 comments on commit b613106

Please sign in to comment.