diff options
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 | } |