#[macro_use]
pub mod test_macro;
mod apt;
mod brew;
mod cargo;
mod cargo_binstall;
mod chocolatey;
mod dnf;
mod gem;
mod go;
mod guix;
mod nix;
mod npm;
mod pacman;
mod pip;
mod pip3;
mod pkg;
mod rua;
mod rustup;
mod scoop;
mod snap;
mod yay;
mod zypper;
pub use apt::Apt;
pub use brew::Brew;
pub use cargo::Cargo;
pub use cargo_binstall::CargoBinstall;
pub use chocolatey::Chocolatey;
pub use dnf::Dnf;
pub use gem::Gem;
pub use go::Go;
pub use guix::Guix;
pub use nix::Nix;
pub use npm::Npm;
pub use pacman::Pacman;
pub use pip::Pip;
pub use pip3::Pip3;
pub use pkg::Pkg;
pub use rua::Rua;
pub use rustup::Rustup;
pub use scoop::Scoop;
pub use snap::Snap;
pub use yay::Yay;
pub use zypper::Zypper;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use strum_macros::EnumIter;
#[enum_dispatch::enum_dispatch]
#[derive(Debug, Copy, Clone, Eq, PartialEq, EnumIter, Serialize, Deserialize)]
pub enum PackageManager {
Apt,
Brew,
Cargo,
CargoBinstall,
Chocolatey,
Dnf,
Gem,
Go,
Guix,
Nix,
Npm,
Pacman,
Pip,
Pip3,
Pkg,
Rua,
Rustup,
Scoop,
Snap,
Yay,
Zypper,
}
#[enum_dispatch::enum_dispatch(PackageManager)]
pub trait PackageManagerTrait {
fn full_name(self) -> &'static str;
fn commands(self) -> Vec<&'static str>;
fn sub_commands(self) -> Vec<&'static str>;
fn install_command(self) -> &'static str;
fn needs_root(self) -> bool;
#[allow(clippy::wrong_self_convention)]
fn is_installed(self, package: &str) -> PackageInstalledMethod;
fn known_flags_with_values(self) -> Vec<&'static str>;
fn capture_flags(self) -> Vec<CaptureFlag>;
fn invalidating_flags(self) -> Vec<&'static str>;
}
#[derive(Debug, Copy, Clone)]
pub enum CaptureFlag {
Single(&'static str),
SetValue(&'static str, &'static str),
DynamicValue(&'static str),
}
pub enum PackageInstalledMethod {
Script(String),
#[allow(unused)]
Path(PathBuf),
}
#[cfg(test)]
mod tests {
use crate::{
catch,
package_manager::{apt::Apt, PackageManager},
};
#[test]
fn test_empty() {
catch!(PackageManager::from(Apt), "no match" => ());
}
}