diff options
author | fxqnlr <[email protected]> | 2024-09-29 15:31:54 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-09-29 15:31:54 +0200 |
commit | 83ac2ad62c27a3089f892b409405f74c4952f2da (patch) | |
tree | 176b819060c5da7ae83510bedec784401a7533d1 /src/packages.rs | |
parent | 5f23d5506698081722eef6e34f11c7fb24e0b212 (diff) | |
parent | d1a9d0d8a8746a63b93f8f14ee4f51b1cd240349 (diff) | |
download | arbs-83ac2ad62c27a3089f892b409405f74c4952f2da.tar arbs-83ac2ad62c27a3089f892b409405f74c4952f2da.tar.gz arbs-83ac2ad62c27a3089f892b409405f74c4952f2da.zip |
Merge remote-tracking branch 'origin/dnf'
Diffstat (limited to 'src/packages.rs')
-rw-r--r-- | src/packages.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/packages.rs b/src/packages.rs index 41b9478..5fb08d0 100644 --- a/src/packages.rs +++ b/src/packages.rs | |||
@@ -1,11 +1,13 @@ | |||
1 | use std::{fs::File, io::Read}; | 1 | use std::{fs::File, io::Read}; |
2 | 2 | ||
3 | use dnf::Dnf; | ||
3 | use pacman::Pacman; | 4 | use pacman::Pacman; |
4 | use portage::Portage; | 5 | use portage::Portage; |
5 | use serde::{Deserialize, Serialize}; | 6 | use serde::{Deserialize, Serialize}; |
6 | 7 | ||
7 | use crate::error::{Error, Result}; | 8 | use crate::error::{Error, Result}; |
8 | 9 | ||
10 | mod dnf; | ||
9 | mod pacman; | 11 | mod pacman; |
10 | mod portage; | 12 | mod portage; |
11 | 13 | ||
@@ -32,6 +34,7 @@ pub struct Package { | |||
32 | 34 | ||
33 | #[derive(Debug, Clone, clap::ValueEnum, Serialize, Deserialize)] | 35 | #[derive(Debug, Clone, clap::ValueEnum, Serialize, Deserialize)] |
34 | pub enum Manager { | 36 | pub enum Manager { |
37 | Dnf, | ||
35 | Pacman, | 38 | Pacman, |
36 | Portage, | 39 | Portage, |
37 | } | 40 | } |
@@ -62,14 +65,16 @@ impl Manager { | |||
62 | 65 | ||
63 | fn from_str(value: &str) -> Result<Self> { | 66 | fn from_str(value: &str) -> Result<Self> { |
64 | Ok(match value { | 67 | Ok(match value { |
65 | "arch" => Self::Pacman, | 68 | "fedora" => Box::new(Dnf), |
66 | "gentoo" => Self::Portage, | 69 | "arch" => Box::new(Pacman), |
70 | "gentoo" => Box::new(Portage), | ||
67 | _ => return Err(Error::Unsupported), | 71 | _ => return Err(Error::Unsupported), |
68 | }) | 72 | }) |
69 | } | 73 | } |
70 | 74 | ||
71 | pub fn to_package_manager(&self) -> Box<dyn PackageManager> { | 75 | pub fn to_package_manager(&self) -> Box<dyn PackageManager> { |
72 | match self { | 76 | match self { |
77 | Self::Dnf => Box::new(Dnf), | ||
73 | Self::Pacman => Box::new(Pacman), | 78 | Self::Pacman => Box::new(Pacman), |
74 | Self::Portage => Box::new(Portage), | 79 | Self::Portage => Box::new(Portage), |
75 | } | 80 | } |