mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-04-01 05:45:20 +01:00
support editor arguments
This commit is contained in:
parent
17f01e6a58
commit
20a69abfd9
1 changed files with 15 additions and 1 deletions
|
@ -83,7 +83,21 @@ impl Exercise {
|
|||
|
||||
/// Open the exercise file in the specified editor
|
||||
pub fn open_in_editor(&self, editor: &str) -> io::Result<bool> {
|
||||
let status = Command::new(editor).arg(self.path).status()?;
|
||||
let parts: Vec<&str> = editor.split_whitespace().collect();
|
||||
if parts.is_empty() {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
let mut cmd = Command::new(parts[0]);
|
||||
|
||||
// If the editor command has arguments, add them to the command
|
||||
if parts.len() > 1 {
|
||||
cmd.args(&parts[1..]);
|
||||
}
|
||||
|
||||
cmd.arg(self.path);
|
||||
|
||||
let status = cmd.status()?;
|
||||
Ok(status.success())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue