Skip to content

Commit e2ce1f4

Browse files
committed
Update: CmdQuestion
1 parent 6366e9f commit e2ce1f4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

internal/question/question.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ import (
99

1010
var CmdQuestion = &base.Command{
1111
Run: runQuestion,
12-
UsageLine: "question (QuestionFrontendId)",
13-
Short: "build problem description file",
14-
Long: "build problem's go,README.md file.",
12+
UsageLine: "question (QuestionId)",
13+
Short: "build problem solution file",
14+
Long: "build problem's description,solution file.",
1515
}
1616

1717
func runQuestion(cmd *base.Command, args []string) {
1818
if len(args) != 1 {
1919
cmd.Usage()
2020
}
21-
questionId, err := strconv.Atoi(args[0])
22-
base.CheckErr(err)
23-
problems := leetcode.ProblemsAll()
24-
for _, problem := range problems.StatStatusPairs {
25-
if problem.Stat.FrontendQuestionId == questionId {
26-
titleSlug := problem.Stat.QuestionTitleSlug
27-
question := leetcode.QuestionData(titleSlug).Data.Question
28-
question.SaveContent()
29-
question.SaveCodeSnippet()
30-
break
21+
if questionId, err := strconv.Atoi(args[0]); err == nil {
22+
problems := leetcode.ProblemsAll()
23+
for _, problem := range problems.StatStatusPairs {
24+
if problem.Stat.FrontendQuestionId == questionId {
25+
titleSlug := problem.Stat.QuestionTitleSlug
26+
question := leetcode.QuestionData(titleSlug).Data.Question
27+
question.SaveContent()
28+
question.SaveCodeSnippet()
29+
break
30+
}
3131
}
3232
}
3333
}

0 commit comments

Comments
 (0)