summaryrefslogtreecommitdiff
path: root/src/packages.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/packages.rs')
-rw-r--r--src/packages.rs9
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 @@
1use std::{fs::File, io::Read}; 1use std::{fs::File, io::Read};
2 2
3use dnf::Dnf;
3use pacman::Pacman; 4use pacman::Pacman;
4use portage::Portage; 5use portage::Portage;
5use serde::{Deserialize, Serialize}; 6use serde::{Deserialize, Serialize};
6 7
7use crate::error::{Error, Result}; 8use crate::error::{Error, Result};
8 9
10mod dnf;
9mod pacman; 11mod pacman;
10mod portage; 12mod 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)]
34pub enum Manager { 36pub 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 }