refact(fedora): Changes in Backend trait

Signed-off-by: innocentzero <isfarulhaque@proton.me>
This commit is contained in:
innocentzero
2024-04-11 21:14:49 +05:30
parent 24f1dce866
commit 39999908b0
3 changed files with 8 additions and 11 deletions
@@ -1,11 +1,12 @@
use core::panic; use core::panic;
use std::collections::HashSet; use std::collections::HashSet;
use std::process::{Command, ExitStatus}; use std::process::Command;
use anyhow::{Context, Result}; use anyhow::Result;
use crate::backend::backend_trait::{Backend, Switches, Text}; use crate::backend::backend_trait::{Backend, Switches, Text};
use crate::backend::macros::impl_backend_constants; use crate::backend::macros::impl_backend_constants;
use crate::cmd::run_external_command;
use crate::{Group, Package}; use crate::{Group, Package};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@@ -57,7 +58,7 @@ impl Backend for Fedora {
} }
/// Install the specified packages. /// Install the specified packages.
fn install_packages(&self, packages: &[Package], noconfirm: bool) -> Result<ExitStatus> { fn install_packages(&self, packages: &[Package], noconfirm: bool) -> Result<()> {
let mut cmd = Command::new("sudo"); let mut cmd = Command::new("sudo");
cmd.arg(self.get_binary()); cmd.arg(self.get_binary());
cmd.args(self.get_switches_install()); cmd.args(self.get_switches_install());
@@ -70,11 +71,10 @@ impl Backend for Fedora {
cmd.arg(format!("{p}")); cmd.arg(format!("{p}"));
} }
cmd.status() run_external_command(cmd)
.with_context(|| format!("running command {cmd:?}"))
} }
fn remove_packages(&self, packages: &[Package], noconfirm: bool) -> Result<ExitStatus> { fn remove_packages(&self, packages: &[Package], noconfirm: bool) -> Result<()> {
let mut cmd = Command::new("sudo"); let mut cmd = Command::new("sudo");
cmd.arg(self.get_binary()); cmd.arg(self.get_binary());
cmd.args(self.get_switches_remove()); cmd.args(self.get_switches_remove());
@@ -87,11 +87,10 @@ impl Backend for Fedora {
cmd.arg(format!("{p}")); cmd.arg(format!("{p}"));
} }
cmd.status() run_external_command(cmd)
.with_context(|| format!("running command [{cmd:?}]"))
} }
fn make_dependency(&self, _: &[Package]) -> Result<ExitStatus> { fn make_dependency(&self, _: &[Package]) -> Result<()> {
panic!("Not supported by the package manager!") panic!("Not supported by the package manager!")
} }
} }
@@ -2,7 +2,6 @@
pub mod arch; pub mod arch;
#[cfg(feature = "debian")] #[cfg(feature = "debian")]
pub mod debian; pub mod debian;
#[cfg(feature = "fedora")]
pub mod fedora; pub mod fedora;
pub mod flatpak; pub mod flatpak;
pub mod python; pub mod python;
-1
View File
@@ -18,7 +18,6 @@ pub enum Backends {
#[cfg(feature = "debian")] #[cfg(feature = "debian")]
Debian, Debian,
Flatpak, Flatpak,
#[cfg(feature = "fedora")]
Fedora, Fedora,
Python, Python,
Rust, Rust,