refact(cmd): dont return exitstatus
This commit is contained in:
@@ -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<P>(files: &[P]) -> Result<ExitStatus>
|
||||
pub fn run_edit_command<P>(files: &[P]) -> Result<()>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
fn inner(files: &[&Path]) -> Result<ExitStatus> {
|
||||
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();
|
||||
|
||||
@@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user