From ee95ec8d10e59b08f4b67d9ae2dffee184459e31 Mon Sep 17 00:00:00 2001 From: axtloss <3alouchi2006@gmail.com> Date: Sat, 2 Oct 2021 17:16:19 +0200 Subject: [PATCH] now prompts for deletion of make dependencies --- src/mods/clone.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/mods/clone.rs b/src/mods/clone.rs index 1dd7ce5..4d6f3b9 100644 --- a/src/mods/clone.rs +++ b/src/mods/clone.rs @@ -1,13 +1,32 @@ use git2::Repository; use moins::Moins; use std::{env, fs, path::Path, process::Command}; -use crate::{err_unrec, inf, inssort, mods::strs::succ, mods::strs::sec, mods::strs::prompt}; +use crate::{err_unrec, inf, inssort, mods::strs::succ, mods::strs::sec, mods::strs::prompt, mods::uninstall::uninstall}; + +fn uninstall_make_depend(results: Vec, pkg: &str) { + let aurpkgname = results[0].name.to_string(); // v here + let make_depends = raur::info(&[&aurpkgname]).unwrap()[0].make_depends.clone(); + + if make_depends.len() != 0 { + inf(format!("{} installed following make dependencies:", pkg)); + for make_depend in &make_depends { + print!("{} ", make_depend); + } + println!(""); + let remove = prompt(format!("Would you like to remove them?")); + if remove == true { + uninstall(true, make_depends); + } + } + succ(format!("Succesfully installed {}", pkg)); +} pub fn clone(noconfirm: bool, pkg: &str) { let cachedir = format!("{}/.cache/ame", std::env::var("HOME").unwrap()); let path = Path::new(&cachedir); let pkgdir = format!("{}/{}", &cachedir, &pkg); let results = raur::search(&pkg).unwrap(); + let mut succ_install: bool = false; if results.len() == 0 { err_unrec(format!("No matching AUR packages found")); @@ -91,7 +110,9 @@ pub fn clone(noconfirm: bool, pkg: &str) { .status(); match install_result { Ok(_) => { - succ(format!("Succesfully installed {}", pkg)); + //succ(format!("Succesfully installed {}", pkg)); + //succ_install = true; + uninstall_make_depend(results, pkg); } Err(_) => { err_unrec(format!("Couldn't install {}", pkg)); @@ -104,7 +125,7 @@ pub fn clone(noconfirm: bool, pkg: &str) { .expect("Couldn't call makepkg"); match install_result.code() { Some(0) => { - succ(format!("Succesfully installed {}", pkg)); + uninstall_make_depend(results, pkg); } Some(_) => { err_unrec(format!("Couldn't install {}", pkg));