diff --git a/src/main.rs b/src/main.rs index 764ffbd..dd1cc7a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ fn main() { let args: Vec = env::args().collect(); let homepath = std::env::var("HOME").unwrap(); let cache_path = format!("/{}/.cache/ame/", homepath); + let pkgs = env::args().skip(2).collect(); // args catch if args.len() <= 1 { @@ -19,7 +20,6 @@ fn main() { // install if oper == "-S" || oper == "-Sn" || oper == "ins" { - let pkgs = env::args().skip(2).collect(); if oper == "-Sn" { inssort(true, pkgs); } else { @@ -29,13 +29,9 @@ fn main() { // remove } else if oper == "-R" || oper == "-Rn " || oper == "-Rsn" || oper == "-Rs" || oper == "rm" { if oper == "-Rn" || oper == "-Rsn" { - for arg in env::args().skip(2) { - uninstall(true, &arg); - } + uninstall(true, pkgs); } else { - for arg in env::args().skip(2) { - uninstall(false, &arg); - } + uninstall(false, pkgs); } // upgrade diff --git a/src/mods/uninstall.rs b/src/mods/uninstall.rs index f9973fb..a817b0a 100644 --- a/src/mods/uninstall.rs +++ b/src/mods/uninstall.rs @@ -1,25 +1,25 @@ use runas::Command; use crate::mods::strs::{err_unrec, sec, succ}; -pub fn uninstall(noconfirm: bool, pkg: &str) { - sec(format!("Attempting to uninstall {}", pkg)); +pub fn uninstall(noconfirm: bool, pkg: Vec) { + sec(format!("Attempting to uninstall packages: {}", &pkg.join(" "))); if noconfirm == true { - let result = Command::new("pacman").arg("-Rs").arg(&pkg).arg("--noconfirm").status(); + let result = Command::new("pacman").arg("-Rs").args(&pkg).arg("--noconfirm").status(); match result { Ok(_) => { - succ(format!("Succesfully uninstalled {}", pkg)) + succ(format!("Succesfully uninstalled packages: {}", &pkg.join(" "))) } Err(_) => { - err_unrec(format!("Couldn't uninstall {}", pkg)) + err_unrec(format!("Couldn't uninstall packages: {}", &pkg.join(" "))) }}; } else { - let result = Command::new("pacman").arg("-Rs").arg(&pkg).status(); + let result = Command::new("pacman").arg("-Rs").args(&pkg).status(); match result { Ok(_) => { - succ(format!("Succesfully uninstalled {}", pkg)) + succ(format!("Succesfully uninstalled packages: {}", &pkg.join(" "))) } Err(_) => { - err_unrec(format!("Couldn't uninstall {}", pkg)) + err_unrec(format!("Couldn't uninstall packages: {}", &pkg.join(" "))) }}; } }