add install and remove packages to Backend trait

This commit is contained in:
steven-omaha
2023-01-05 16:44:41 +01:00
parent ddcb5dec3d
commit 2f511cf87c
4 changed files with 31 additions and 24 deletions
-20
View File
@@ -1,11 +1,9 @@
use std::os::unix::process::CommandExt;
use std::path::PathBuf;
use std::process::{Command, ExitStatus};
use anyhow::{anyhow, Result};
use crate::env::get_editor;
use crate::Package;
pub fn run_edit_command(files: &[PathBuf]) -> Result<ExitStatus> {
let mut cmd = Command::new(get_editor()?);
@@ -14,21 +12,3 @@ pub fn run_edit_command(files: &[PathBuf]) -> Result<ExitStatus> {
}
cmd.status().map_err(|e| anyhow!(e))
}
pub fn run_install_command(diff: Vec<Package>) {
let mut cmd = Command::new("paru");
cmd.arg("-S");
for p in diff {
cmd.arg(format!("{p}"));
}
cmd.exec();
}
pub fn run_remove_command(unmanaged: Vec<Package>) {
let mut cmd = Command::new("paru");
cmd.arg("-Rsn");
for p in unmanaged {
cmd.arg(format!("{p}"));
}
cmd.exec();
}