Skip to content

Commit 6f44c33

Browse files
authored
feat: support Java (#3)
1 parent f318eb1 commit 6f44c33

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $ leetcode-tool help
2626

2727
```js
2828
{
29-
"lang": "go", // 项目全局语言, 配置后 new 命令 --lang 参数可省略, 目前支持 go ts js py3
29+
"lang": "go", // 项目全局语言, 配置后 new 命令 --lang 参数可省略, 目前支持 go ts js py3 java
3030
"cookie": "xxx"
3131
}
3232
```
@@ -41,6 +41,7 @@ $ leetcode-tool help
4141
- Typescript ts
4242
- Javascript js
4343
- Python3 py3
44+
- Java java
4445

4546
## 主要功能
4647

cmd/new/main.go

+30
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ var (
4949
LeetcodeLang: "Python3",
5050
TplFiles: []TplFile{{"code", "solve_%s.py", codeStrPy3}, {"test", "test_%s.py", testCodeStrPy3}, {"__init__", "__init__.py", ""}},
5151
},
52+
"java": {
53+
LeetcodeLang: "Java",
54+
TplFiles: []TplFile{{"code", "solve_%s.java", codeStrJava}, {"test", "test_%s.java", testCodeStrJava}},
55+
},
5256
}
5357
)
5458

@@ -212,3 +216,29 @@ var (
212216
pass
213217
`
214218
)
219+
220+
var (
221+
codeStrJava = `package {{ .Folder }};
222+
223+
/**
224+
* @index {{ .Index }}
225+
* @title {{ .Title }}
226+
* @difficulty {{ .Difficulty }}
227+
* @tags {{ .TagStr }}
228+
* @draft false
229+
* @link {{ .Link }}
230+
* @frontendId {{ .FrontendId }}
231+
*/
232+
{{ .Code }}
233+
`
234+
235+
testCodeStrJava = `package {{ .Folder }};
236+
237+
public class test_{{ printf "%04s" .Index }} {
238+
public static void main(String[] args) {
239+
Solution solution = new Solution();
240+
// do some test
241+
}
242+
}
243+
`
244+
)

0 commit comments

Comments
 (0)