make arch an optional backend
This commit is contained in:
@@ -13,7 +13,7 @@ categories = ["command-line-utilities"]
|
|||||||
features = ["alpm/docs-rs"]
|
features = ["alpm/docs-rs"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
alpm = "2.2"
|
alpm = { version = "2.2", optional = true }
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
clap = "4.1"
|
clap = "4.1"
|
||||||
const_format = { version = "0.2", default-features = false }
|
const_format = { version = "0.2", default-features = false }
|
||||||
@@ -27,3 +27,7 @@ serde_derive = "1.0"
|
|||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
|
||||||
pacdef_macros = { path = "../pacdef_macros", version = "0.1" }
|
pacdef_macros = { path = "../pacdef_macros", version = "0.1" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["arch"]
|
||||||
|
arch = ["dep:alpm"]
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
|
#[cfg(feature = "arch")]
|
||||||
pub mod arch;
|
pub mod arch;
|
||||||
pub mod rust;
|
pub mod rust;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use pacdef_macros::Register;
|
|||||||
|
|
||||||
#[derive(Debug, Register)]
|
#[derive(Debug, Register)]
|
||||||
pub enum Backends {
|
pub enum Backends {
|
||||||
|
#[cfg(feature = "arch")]
|
||||||
Arch,
|
Arch,
|
||||||
Rust,
|
Rust,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use const_format::formatcp;
|
|||||||
|
|
||||||
use crate::action::*;
|
use crate::action::*;
|
||||||
use crate::args;
|
use crate::args;
|
||||||
use crate::backend::{Arch, Backend, Backends, ToDoPerBackend};
|
use crate::backend::{Backend, Backends, ToDoPerBackend};
|
||||||
use crate::cmd::run_edit_command;
|
use crate::cmd::run_edit_command;
|
||||||
use crate::env::get_single_var;
|
use crate::env::get_single_var;
|
||||||
use crate::path::get_group_dir;
|
use crate::path::get_group_dir;
|
||||||
@@ -23,6 +23,7 @@ const UNREACHABLE_ARM: &str = "argument parser requires some subcommand to retur
|
|||||||
const ACTION_NOT_MATCHED: &str = "could not match action";
|
const ACTION_NOT_MATCHED: &str = "could not match action";
|
||||||
|
|
||||||
/// Most data that is required during runtime of the program.
|
/// Most data that is required during runtime of the program.
|
||||||
|
#[allow(dead_code)] // "`config` is only needed on Arch Linux"
|
||||||
pub struct Pacdef {
|
pub struct Pacdef {
|
||||||
args: ArgMatches,
|
args: ArgMatches,
|
||||||
config: Config,
|
config: Config,
|
||||||
@@ -94,6 +95,7 @@ impl Pacdef {
|
|||||||
let mut to_install = ToDoPerBackend::new();
|
let mut to_install = ToDoPerBackend::new();
|
||||||
|
|
||||||
for mut backend in Backends::iter() {
|
for mut backend in Backends::iter() {
|
||||||
|
#[cfg(feature = "arch")]
|
||||||
self.overwrite_values_from_config(&mut *backend);
|
self.overwrite_values_from_config(&mut *backend);
|
||||||
|
|
||||||
backend.load(&self.groups);
|
backend.load(&self.groups);
|
||||||
@@ -107,8 +109,9 @@ impl Pacdef {
|
|||||||
to_install
|
to_install
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "arch")]
|
||||||
fn overwrite_values_from_config(&mut self, backend: &mut dyn Backend) {
|
fn overwrite_values_from_config(&mut self, backend: &mut dyn Backend) {
|
||||||
if let Some(arch) = backend.as_any_mut().downcast_mut::<Arch>() {
|
if let Some(arch) = backend.as_any_mut().downcast_mut::<crate::backend::Arch>() {
|
||||||
arch.binary = self.config.aur_helper.clone();
|
arch.binary = self.config.aur_helper.clone();
|
||||||
arch.aur_rm_args = self.config.aur_rm_args.take();
|
arch.aur_rm_args = self.config.aur_rm_args.take();
|
||||||
}
|
}
|
||||||
@@ -166,6 +169,7 @@ impl Pacdef {
|
|||||||
let mut result = ToDoPerBackend::new();
|
let mut result = ToDoPerBackend::new();
|
||||||
|
|
||||||
for mut backend in Backends::iter() {
|
for mut backend in Backends::iter() {
|
||||||
|
#[cfg(feature = "arch")]
|
||||||
self.overwrite_values_from_config(&mut *backend);
|
self.overwrite_values_from_config(&mut *backend);
|
||||||
|
|
||||||
backend.load(&self.groups);
|
backend.load(&self.groups);
|
||||||
|
|||||||
Reference in New Issue
Block a user