Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2d6b6cf

Browse files
author
Sandy
authored
Merge pull request #204 from openset/develop
Update: AuthInfo
2 parents 9d29e12 + d798f4f commit 2d6b6cf

File tree

6 files changed

+14
-19
lines changed

6 files changed

+14
-19
lines changed

‎internal/base/base.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ func Exit() {
8080
os.Exit(0)
8181
}
8282

83-
const AuthInfo = `
84-
<!--+----------------------------------------------------------------------+-->
85-
<!--|@author Openset <openset.wang@gmail.com> |-->
86-
<!--|@link https://github.com/openset |-->
87-
<!--|@home https://github.com/openset/leetcode |-->
88-
<!--+----------------------------------------------------------------------+-->
89-
`
83+
func AuthInfo(cmd string) string {
84+
format := "<!--|This file generated by command(leetcode %s); DO NOT EDIT.%s|-->\n"
85+
format += "<!--+----------------------------------------------------------------------+-->\n"
86+
format += "<!--|@author Openset <openset.wang@gmail.com> |-->\n"
87+
format += "<!--|@link https://github.com/openset |-->\n"
88+
format += "<!--|@home https://github.com/openset/leetcode |-->\n"
89+
format += "<!--+----------------------------------------------------------------------+-->\n"
90+
return fmt.Sprintf(format, cmd, strings.Repeat(" ", 15-len(cmd)))
91+
}

‎internal/helper/helper.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ func runHelper(cmd *base.Command, args []string) {
1919
cmd.Usage()
2020
}
2121
var buf bytes.Buffer
22-
buf.WriteString("<!--|This file generated by command(leetcode helper); DO NOT EDIT. |-->")
23-
buf.WriteString(base.AuthInfo)
22+
buf.WriteString(base.AuthInfo("helper"))
2423
buf.WriteString("\n# Helper\n\n")
2524
buf.WriteString("```text\n")
2625
out, err := exec.Command(base.CmdName).Output()

‎internal/leetcode/question_data.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ func (question questionType) SaveContent() {
8686

8787
func (question questionType) getDescContent() []byte {
8888
var buf bytes.Buffer
89-
buf.WriteString("<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->")
90-
buf.WriteString(authInfo)
89+
buf.WriteString(authInfo("description"))
9190
buf.WriteString(fmt.Sprintf("\n## %s. %s%s\n\n", question.QuestionFrontendId, question.Title, question.Difficulty.Str()))
9291
content := strings.Replace(question.Content, "\r", "", -1)
9392
// remove style

‎internal/leetcode/tag.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ func (question ttQuestionType) TagsStr() string {
118118
func (tag tagType) SaveContents() {
119119
questions := GetTopicTag(tag.Slug).Data.TopicTag.Questions
120120
var buf bytes.Buffer
121-
buf.WriteString("<!--|This file generated by command(leetcode tag); DO NOT EDIT. |-->")
122-
buf.WriteString(authInfo)
121+
buf.WriteString(authInfo("tag"))
123122
buf.WriteString(fmt.Sprintf("\n## %s\n\n", tag.ShowName()))
124123
buf.WriteString("| # | 题名 | 标签 | 难度 |\n")
125124
buf.WriteString("| :-: | - | - | :-: |\n")

‎internal/readme/readme.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ func runReadme(cmd *base.Command, args []string) {
2626
cmd.Usage()
2727
}
2828
var buf bytes.Buffer
29-
buf.WriteString(fmt.Sprintf(format, buildCmd, strings.Repeat(" ", 15-len(buildCmd))))
30-
buf.WriteString(base.AuthInfo)
29+
buf.WriteString(base.AuthInfo(buildCmd))
3130
buf.WriteString(defaultStr)
3231
writeProblems(&buf)
3332
base.FilePutContents(fileName, buf.Bytes())
@@ -75,8 +74,6 @@ var (
7574
fileName = "README.md"
7675
)
7776

78-
var format = "<!--|This file generated by command(leetcode %s); DO NOT EDIT.%s|-->"
79-
8077
var defaultStr = `
8178
# [LeetCode](https://openset.github.io/leetcode)
8279
LeetCode Problems' Solutions

‎internal/tag/tag.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ func runTag(cmd *base.Command, args []string) {
2121
cmd.Usage()
2222
}
2323
var buf bytes.Buffer
24-
buf.WriteString("<!--|This file generated by command(leetcode tag); DO NOT EDIT. |-->")
25-
buf.WriteString(base.AuthInfo)
24+
buf.WriteString(base.AuthInfo("tag"))
2625
buf.WriteString("\n## 话题分类\n\n")
2726
buf.WriteString("| # | Title | 标题 | | # | Title | 标题 |\n")
2827
buf.WriteString("| :-: | - | :-: | - | :-: | - | :-: |\n")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /