diff --git a/crates/pacdef_core/src/cmd.rs b/crates/pacdef_core/src/cmd.rs index 61bb8f9..f0a4bae 100644 --- a/crates/pacdef_core/src/cmd.rs +++ b/crates/pacdef_core/src/cmd.rs @@ -1,17 +1,17 @@ use std::path::Path; -use std::process::{Command, ExitStatus}; +use std::process::Command; -use anyhow::{anyhow, ensure, Context, Result}; +use anyhow::{ensure, Context, Result}; use crate::env::{get_editor, should_print_debug_info}; /// Run the editor and pass the provided files as arguments. The workdir is set /// to the parent of the first file. -pub fn run_edit_command

(files: &[P]) -> Result +pub fn run_edit_command

(files: &[P]) -> Result<()> where P: AsRef, { - fn inner(files: &[&Path]) -> Result { + fn inner(files: &[&Path]) -> Result<()> { let mut cmd = Command::new(get_editor().context("getting suitable editor")?); cmd.current_dir( files[0] @@ -21,8 +21,7 @@ where for f in files { cmd.arg(f.to_string_lossy().to_string()); } - // TODO this could also use the run_external_command function - cmd.status().map_err(|e| anyhow!(e)) + run_external_command(cmd) } let files: Vec<_> = files.iter().map(|p| p.as_ref()).collect(); diff --git a/crates/pacdef_core/src/core.rs b/crates/pacdef_core/src/core.rs index 8e3e4c4..9baf114 100644 --- a/crates/pacdef_core/src/core.rs +++ b/crates/pacdef_core/src/core.rs @@ -181,11 +181,8 @@ impl Pacdef { .map(|g| g.path.as_path()) .collect(); - let success = run_edit_command(&group_files) - .context("running editor")? - .success(); + run_edit_command(&group_files).context("running editor")?; - ensure!(success, "editor exited with error"); Ok(()) } @@ -422,11 +419,7 @@ impl Pacdef { } if edit { - let success = run_edit_command(&paths) - .context("running editor")? - .success(); - - ensure!(success, "editor exited with error"); + run_edit_command(&paths).context("running editor")?; } Ok(())