Skip to content

Commit

Permalink
feat: support Java (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrx93 authored Jan 18, 2022
1 parent f318eb1 commit 6f44c33
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $ leetcode-tool help

```js
{
"lang": "go", // 项目全局语言, 配置后 new 命令 --lang 参数可省略, 目前支持 go ts js py3
"lang": "go", // 项目全局语言, 配置后 new 命令 --lang 参数可省略, 目前支持 go ts js py3 java
"cookie": "xxx"
}
```
Expand All @@ -41,6 +41,7 @@ $ leetcode-tool help
- Typescript ts
- Javascript js
- Python3 py3
- Java java

## 主要功能

Expand Down
30 changes: 30 additions & 0 deletions cmd/new/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ var (
LeetcodeLang: "Python3",
TplFiles: []TplFile{{"code", "solve_%s.py", codeStrPy3}, {"test", "test_%s.py", testCodeStrPy3}, {"__init__", "__init__.py", ""}},
},
"java": {
LeetcodeLang: "Java",
TplFiles: []TplFile{{"code", "solve_%s.java", codeStrJava}, {"test", "test_%s.java", testCodeStrJava}},
},
}
)

Expand Down Expand Up @@ -212,3 +216,29 @@ var (
pass
`
)

var (
codeStrJava = `package {{ .Folder }};
/**
* @index {{ .Index }}
* @title {{ .Title }}
* @difficulty {{ .Difficulty }}
* @tags {{ .TagStr }}
* @draft false
* @link {{ .Link }}
* @frontendId {{ .FrontendId }}
*/
{{ .Code }}
`

testCodeStrJava = `package {{ .Folder }};
public class test_{{ printf "%04s" .Index }} {
public static void main(String[] args) {
Solution solution = new Solution();
// do some test
}
}
`
)

0 comments on commit 6f44c33

Please sign in to comment.