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 c6873f0

Browse files
feat(cfg): support editor-args in config (clearloop#78)
* feat(cfg): supports editor-args in config * chore(cmd): fix typo Co-authored-by: clearloop <clearloop@users.noreply.github.com>
1 parent 5566870 commit c6873f0

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

‎Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ path = "src/bin/lc.rs"
44

55
[package]
66
name = "leetcode-cli"
7-
version = "0.3.11"
7+
version = "0.3.12"
88
authors = ["clearloop <cdr.today@foxmail.com>"]
99
edition = "2021"
1010
description = "Leet your code in command-line."

‎src/cfg.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ pub struct Urls {
132132
#[derive(Clone, Debug, Deserialize, Serialize)]
133133
pub struct Code {
134134
pub editor: String,
135+
#[serde(rename(serialize = "editor-args", deserialize = "editor-args"))]
136+
pub editor_args: Option<Vec<String>>,
135137
pub lang: String,
136138
pub pick: String,
137139
pub submission: String,

‎src/cmds/edit.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,27 @@ impl Command for EditCommand {
121121
}
122122
}
123123

124+
// Get arguments of the editor
125+
//
126+
// for example:
127+
//
128+
// ```toml
129+
// [code]
130+
// editor = "emacsclient"
131+
// editor-args = [ "-n", "-s", "doom" ]
132+
// ```
133+
//
134+
// ```rust
135+
// Command::new("emacsclient").args(&[ "-n", "-s", "doom", "<problem>" ])
136+
// ```
137+
let mut args: Vec<String> = Default::default();
138+
if let Some(editor_args) = conf.code.editor_args {
139+
args.extend_from_slice(&editor_args);
140+
}
141+
142+
args.push(path);
124143
std::process::Command::new(conf.code.editor)
125-
.arg(path)
144+
.args(args)
126145
.status()?;
127146
Ok(())
128147
}

0 commit comments

Comments
(0)

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