Skip to content
Merged
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,17 @@


## Settings
| Setting Name | Description | Default Value |
|---|---|---|
| `leetcode.hideSolved` | Specify to hide the solved problems or not | `false` |
| `leetcode.showLocked` | Specify to show the locked problems or not. Only Premium users could open the locked problems | `false` |
| `leetcode.defaultLanguage` | Specify the default language used to solve the problem. Supported languages are: `bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `python`,`python3`,`ruby`,`scala`,`swift` | `N/A` |
| `leetcode.useWsl` | Specify whether to use WSL or not | `false` |
| `leetcode.endpoint` | Specify the active endpoint. Supported endpoints are: `leetcode`, `leetcode-cn` | `leetcode` |
| Setting Name | Description | Default Value |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| `leetcode.hideSolved` | Specify to hide the solved problems or not | `false` |
| `leetcode.showLocked` | Specify to show the locked problems or not. Only Premium users could open the locked problems | `false` |
| `leetcode.defaultLanguage` | Specify the default language used to solve the problem. Supported languages are: `bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `python`,`python3`,`ruby`,`scala`,`swift` | `N/A` |
| `leetcode.useWsl` | Specify whether to use WSL or not | `false` |
| `leetcode.endpoint` | Specify the active endpoint. Supported endpoints are: `leetcode`, `leetcode-cn` | `leetcode` |
| `leetcode.outputPath` | * `${tag}` - a directory based on the problem's tag. For example, if the problem belongs to: `Binary Indexed Tree`, then a folder named `binary_indexed_tree` will be used here. |
* `${language}` - a directory based on the language used. For example, `java` for Java language
* `${difficulty}` - a directory based on the problem's difficulty. For example, `easy`
* If this setting is not set, the files will be generated to the base path of the workspace folder | `root` |

## Release Notes

Expand Down
14 changes: 7 additions & 7 deletions docs/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@


## 插件配置项
| 配置项名称 | 描述 | 默认值 |
|---|---|---|
| `leetcode.hideSolved` | 指定是否要隐藏已解决的问题 | `false` |
| `leetcode.showLocked` | 指定是否显示付费题目,只有付费账户才可以打开付费题目 | `false` |
| `leetcode.defaultLanguage` | 指定答题时使用的默认语言,可选语言有:`bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `python`,`python3`,`ruby`,`scala`,`swift` | `N/A` |
| `leetcode.useWsl` | 指定是否启用 WSL | `false` |
| `leetcode.endpoint` | 指定使用的终端,可用终端有:`leetcode`, `leetcode-cn` | `leetcode` |
| 配置项名称 | 描述 | 默认值 |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `leetcode.hideSolved` | 指定是否要隐藏已解决的问题 | `false` |
| `leetcode.showLocked` | 指定是否显示付费题目,只有付费账户才可以打开付费题目 | `false` |
| `leetcode.defaultLanguage` | 指定答题时使用的默认语言,可选语言有:`bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `python`,`python3`,`ruby`,`scala`,`swift` | `N/A` |
| `leetcode.useWsl` | 指定是否启用 WSL | `false` |
| `leetcode.endpoint` | 指定使用的终端,可用终端有:`leetcode`, `leetcode-cn` | `leetcode` |

## 更新日志

Expand Down
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@
"leetcode-cn"
],
"description": "Endpoint of the user account."
},
"leetcode.outputPath": {
"type": "string",
"default": "root",
"scope": "application",
"enum": [
"root",
"tag",
"language",
"difficulty"
],
"description": "Specifies the relative path to save the problem files."
}
}
}
Expand Down
20 changes: 19 additions & 1 deletion src/commands/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,25 @@ async function showProblemInternal(id: string): Promise<void> {
return;
}

const outDir: string = await selectWorkspaceFolder();
let outDir: string = await selectWorkspaceFolder();
const outputPath: string = leetCodeConfig.get<string>("outputPath") || "root";
switch (outputPath) {
case "root": {
break;
}
case "tag": {
const { tags } = await leetCodeExecutor.getCompaniesAndTags();
outDir = `${outDir}/${tags[id][0].split("-").map((c: string) => c[0].toUpperCase() + c.slice(1)).join("")}`;
break;
}
case "language": {
outDir = `${outDir}/${language}`;
break;
}
case "difficulty": {
break;
}
}
await fse.ensureDir(outDir);
const result: string = await leetCodeExecutor.showProblem(id, language, outDir);
const reg: RegExp = /\* Source Code:\s*(.*)/;
Expand Down