Skip to content

Commit cc0983e

Browse files
committed
fixes skygragon#72: enhance editor feature.
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent 7743559 commit cc0983e

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

docs/advanced.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Create a JSON file named `.lcconfig` in your home directory, e.g.
5454

5555
{
5656
"LANG": "java",
57+
"EDITOR": "vim",
5758
"USE_COLOR": true,
5859
"COLOR_THEME": "default",
5960
"AUTO_LOGIN": false,
@@ -64,6 +65,7 @@ Here are some useful settings:
6465

6566
* `AUTO_LOGIN` to enable auto login feature, see [Auto Login](#auto-login).
6667
* `COLOR_THEME` to set color theme used in output, see [Color Theme](#color-theme).
68+
* `EDITOR` to set editor used to open generated source file.
6769
* `ICON_THEME` to set icon them used in output.
6870
* `LANG` to set your default language used in coding.
6971
* `USE_COLOR` to enable colorful output.
@@ -133,4 +135,4 @@ You can easily introduce more features by installing other plugins form third pa
133135

134136
* [leetcode-cli-plugins](https://github.com/skygragon/leetcode-cli-plugins)
135137

136-
Feel free to try out the plugins above. Or you can develope your own plugins to enrich leetcode-cli's functionalities.
138+
Feel free to try out the plugins above. Or you can develope your own plugins to enrich leetcode-cli's functionalities.

docs/commands.md

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Navigate the problems.
9494
* database
9595
* shell
9696
* `-s` to show statistic counters.
97+
* `-e` to open editor with generated source file.
9798
* `leetcode list <keyword>` to search by keyword matching.
9899

99100
*Examples*

lib/commands/show.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ var cmd = {
5050
editor: {
5151
alias: 'e',
5252
type: 'string',
53-
default: '',
5453
describe: 'Pass generated source file to editor'
5554
}
5655
}
@@ -79,8 +78,8 @@ cmd.handler = function(argv) {
7978

8079
core.exportProblem(problem, filename, !argv.extra);
8180

82-
if (argv.editor) {
83-
childProcess.spawn(argv.editor, [filename], {
81+
if (argv.editor !== undefined) {
82+
childProcess.spawn(argv.editor || config.EDITOR, [filename], {
8483
// in case your editor of choice is vim or emacs
8584
stdio: 'inherit'
8685
});

lib/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var DEFAULT_SYS_CONFIG = {
4747
var DEFAULT_USER_CONFIG = {
4848
AUTO_LOGIN: false,
4949
COLOR_THEME: 'default',
50+
EDITOR: 'vim',
5051
ICON_THEME: '',
5152
LANG: 'cpp',
5253
MAX_WORKERS: 10,

0 commit comments

Comments
 (0)