handle errors in editing files

This commit is contained in:
steven-omaha
2022-12-02 17:51:10 +01:00
parent 81c6b04e64
commit 1eb71b7651
4 changed files with 29 additions and 9 deletions
+7 -4
View File
@@ -1,15 +1,18 @@
use std::os::unix::process::CommandExt;
use std::path::PathBuf;
use std::process::Command;
use std::process::{Command, ExitStatus};
use anyhow::{anyhow, Result};
use crate::env::get_editor;
use crate::Package;
pub fn run_edit_command(files: &[PathBuf]) {
let mut cmd = Command::new("nvim");
pub fn run_edit_command(files: &[PathBuf]) -> Result<ExitStatus> {
let mut cmd = Command::new(get_editor()?);
for f in files {
cmd.arg(f.to_string_lossy().to_string());
}
cmd.exec();
cmd.status().map_err(|e| anyhow!(e))
}
pub fn run_install_command(diff: Vec<Package>) {