From 189f2271bcc6f841264cb960e35e78c870663645 Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 17 Jun 2024 10:59:59 +0800 Subject: feat: add `.edit session` repl command (#606) --- src/utils/command.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/utils/command.rs') diff --git a/src/utils/command.rs b/src/utils/command.rs index 873e40b..557649a 100644 --- a/src/utils/command.rs +++ b/src/utils/command.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, env, ffi::OsStr, process::Command}; +use std::{collections::HashMap, env, ffi::OsStr, path::Path, process::Command}; use anyhow::{Context, Result}; @@ -90,3 +90,9 @@ pub fn run_command_with_output>( let stderr = std::str::from_utf8(&output.stderr).context("Invalid UTF-8 in stderr")?; Ok((status.success(), stdout.to_string(), stderr.to_string())) } + +pub fn edit_file(editor: &str, path: &Path) -> Result<()> { + let mut child = Command::new(editor).arg(path).spawn()?; + child.wait()?; + Ok(()) +} -- cgit v1.2.3