add custom aur helper rm args
This commit is contained in:
@@ -10,6 +10,7 @@ use crate::{impl_backend_constants, Group, Package};
|
|||||||
|
|
||||||
pub(crate) struct Pacman {
|
pub(crate) struct Pacman {
|
||||||
pub(crate) binary: String,
|
pub(crate) binary: String,
|
||||||
|
pub(crate) aur_rm_args: Option<Vec<String>>,
|
||||||
pub(crate) packages: HashSet<Package>,
|
pub(crate) packages: HashSet<Package>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,10 +54,16 @@ impl Backend for Pacman {
|
|||||||
/// Remove the specified packages.
|
/// Remove the specified packages.
|
||||||
fn remove_packages(&self, packages: &[Package]) -> Result<ExitStatus> {
|
fn remove_packages(&self, packages: &[Package]) -> Result<ExitStatus> {
|
||||||
let mut cmd = Command::new(&self.binary);
|
let mut cmd = Command::new(&self.binary);
|
||||||
|
|
||||||
cmd.args(self.get_switches_remove());
|
cmd.args(self.get_switches_remove());
|
||||||
|
if let Some(rm_args) = &self.aur_rm_args {
|
||||||
|
cmd.args(rm_args);
|
||||||
|
}
|
||||||
|
|
||||||
for p in packages {
|
for p in packages {
|
||||||
cmd.arg(format!("{p}"));
|
cmd.arg(format!("{p}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.status()
|
cmd.status()
|
||||||
.with_context(|| format!("running command [{cmd:?}]"))
|
.with_context(|| format!("running command [{cmd:?}]"))
|
||||||
}
|
}
|
||||||
@@ -97,6 +104,7 @@ impl Pacman {
|
|||||||
pub(crate) fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
binary: BINARY.to_string(),
|
binary: BINARY.to_string(),
|
||||||
|
aur_rm_args: None,
|
||||||
packages: HashSet::new(),
|
packages: HashSet::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const CONFIG_FILE_NAME: &str = "pacdef.yaml";
|
|||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub aur_helper: String,
|
pub aur_helper: String,
|
||||||
|
pub aur_rm_args: Option<Vec<String>>,
|
||||||
pub warn_not_symlinks: bool,
|
pub warn_not_symlinks: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ impl Default for Config {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
aur_helper: "paru".into(),
|
aur_helper: "paru".into(),
|
||||||
|
aur_rm_args: None,
|
||||||
warn_not_symlinks: true,
|
warn_not_symlinks: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-9
@@ -36,7 +36,7 @@ impl Pacdef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::unit_arg)]
|
#[allow(clippy::unit_arg)]
|
||||||
pub fn run_action_from_arg(self) -> Result<()> {
|
pub fn run_action_from_arg(mut self) -> Result<()> {
|
||||||
match self.args.subcommand() {
|
match self.args.subcommand() {
|
||||||
Some((CLEAN, _)) => self.clean_packages(),
|
Some((CLEAN, _)) => self.clean_packages(),
|
||||||
Some((EDIT, args)) => self.edit_group_files(args).context("editing group files"),
|
Some((EDIT, args)) => self.edit_group_files(args).context("editing group files"),
|
||||||
@@ -60,11 +60,11 @@ impl Pacdef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_missing_packages(&self) -> ToDoPerBackend {
|
fn get_missing_packages(&mut self) -> ToDoPerBackend {
|
||||||
let mut to_install = ToDoPerBackend::new();
|
let mut to_install = ToDoPerBackend::new();
|
||||||
|
|
||||||
for backend in Backends::iter() {
|
for backend in Backends::iter() {
|
||||||
let mut backend = self.overwrite_binary_from_config(backend);
|
let mut backend = self.overwrite_values_from_config(backend);
|
||||||
|
|
||||||
backend.load(&self.groups);
|
backend.load(&self.groups);
|
||||||
|
|
||||||
@@ -77,10 +77,11 @@ impl Pacdef {
|
|||||||
to_install
|
to_install
|
||||||
}
|
}
|
||||||
|
|
||||||
fn overwrite_binary_from_config(&self, backend: Box<dyn Backend>) -> Box<dyn Backend> {
|
fn overwrite_values_from_config(&mut self, backend: Box<dyn Backend>) -> Box<dyn Backend> {
|
||||||
if backend.get_section() == "pacman" {
|
if backend.get_section() == "pacman" {
|
||||||
Box::new(crate::backend::Pacman {
|
Box::new(crate::backend::Pacman {
|
||||||
binary: self.config.aur_helper.clone(),
|
binary: self.config.aur_helper.clone(),
|
||||||
|
aur_rm_args: self.config.aur_rm_args.take(),
|
||||||
packages: HashSet::new(),
|
packages: HashSet::new(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -88,7 +89,7 @@ impl Pacdef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn install_packages(&self) -> Result<()> {
|
fn install_packages(&mut self) -> Result<()> {
|
||||||
let to_install = self.get_missing_packages();
|
let to_install = self.get_missing_packages();
|
||||||
|
|
||||||
if to_install.nothing_to_do_for_all_backends() {
|
if to_install.nothing_to_do_for_all_backends() {
|
||||||
@@ -138,17 +139,17 @@ impl Pacdef {
|
|||||||
println!("pacdef, version: {}", env!("CARGO_PKG_VERSION"));
|
println!("pacdef, version: {}", env!("CARGO_PKG_VERSION"));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_unmanaged_packages(self) {
|
fn show_unmanaged_packages(mut self) {
|
||||||
let unmanaged_per_backend = &self.get_unmanaged_packages();
|
let unmanaged_per_backend = &self.get_unmanaged_packages();
|
||||||
|
|
||||||
unmanaged_per_backend.show(None);
|
unmanaged_per_backend.show(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_unmanaged_packages(&self) -> ToDoPerBackend {
|
fn get_unmanaged_packages(&mut self) -> ToDoPerBackend {
|
||||||
let mut result = ToDoPerBackend::new();
|
let mut result = ToDoPerBackend::new();
|
||||||
|
|
||||||
for backend in Backends::iter() {
|
for backend in Backends::iter() {
|
||||||
let mut backend = self.overwrite_binary_from_config(backend);
|
let mut backend = self.overwrite_values_from_config(backend);
|
||||||
|
|
||||||
backend.load(&self.groups);
|
backend.load(&self.groups);
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ impl Pacdef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean_packages(self) -> Result<()> {
|
fn clean_packages(mut self) -> Result<()> {
|
||||||
let to_remove = self.get_unmanaged_packages();
|
let to_remove = self.get_unmanaged_packages();
|
||||||
|
|
||||||
if to_remove.is_empty() {
|
if to_remove.is_empty() {
|
||||||
|
|||||||
+19
-18
@@ -60,24 +60,25 @@ fn get_action_for_package(
|
|||||||
reviews: &mut Reviews,
|
reviews: &mut Reviews,
|
||||||
backend: &Rc<Box<dyn Backend>>,
|
backend: &Rc<Box<dyn Backend>>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
loop {
|
todo!();
|
||||||
match ask_user_action_for_package()? {
|
// loop {
|
||||||
ReviewAction::AsDependency => todo!(),
|
// match ask_user_action_for_package()? {
|
||||||
ReviewAction::AssignGroupBackend => {
|
// ReviewAction::AsDependency => todo!(),
|
||||||
if let Some(val) = assign_group_backend(&package, groups)? {
|
// ReviewAction::AssignGroupBackend => {
|
||||||
break;
|
// if let Some(val) = assign_group_backend(&package, groups)? {
|
||||||
};
|
// break;
|
||||||
}
|
// };
|
||||||
ReviewAction::Delete => {
|
// }
|
||||||
reviews.delete.push((backend.clone(), package));
|
// ReviewAction::Delete => {
|
||||||
break;
|
// reviews.delete.push((backend.clone(), package));
|
||||||
}
|
// break;
|
||||||
ReviewAction::Info => backend.show_package_info(&package)?,
|
// }
|
||||||
ReviewAction::Invalid => (),
|
// ReviewAction::Info => backend.show_package_info(&package)?,
|
||||||
ReviewAction::Skip => break,
|
// ReviewAction::Invalid => (),
|
||||||
ReviewAction::Quit => bail!("user wants to quit"),
|
// ReviewAction::Skip => break,
|
||||||
}
|
// ReviewAction::Quit => bail!("user wants to quit"),
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user