oh lord - full cargo clippy + fmt
parent
bbec30ead5
commit
5330758ad5
@ -1,120 +1,121 @@
|
||||
use crate::mods::{
|
||||
database::rem_pkg,
|
||||
strs::{err_rec, err_unrec, sec, succ},
|
||||
};
|
||||
use runas::Command;
|
||||
use std::{fs, path::Path};
|
||||
|
||||
pub fn purge(noconfirm: bool, pkgs: Vec<String>) { // purge packages
|
||||
sec(format!(
|
||||
"Attempting to uninstall packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
if noconfirm == true {
|
||||
let result = Command::new("pacman")
|
||||
.arg("-Rsu")
|
||||
.args(&pkgs)
|
||||
.arg("--noconfirm")
|
||||
.status()
|
||||
.expect("Couldn't call pacman");
|
||||
match result.code() {
|
||||
Some(0) => {
|
||||
succ(format!(
|
||||
"Succesfully uninstalled packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
rem_pkg(&pkgs);
|
||||
}
|
||||
Some(_) => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
None => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
};
|
||||
} else {
|
||||
let result = Command::new("pacman")
|
||||
.arg("-Rsu")
|
||||
.args(&pkgs)
|
||||
.status()
|
||||
.expect("Couldn't call pacman");
|
||||
match result.code() {
|
||||
Some(0) => {
|
||||
succ(format!(
|
||||
"Succesfully uninstalled packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
rem_pkg(&pkgs);
|
||||
}
|
||||
Some(_) => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
None => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
};
|
||||
}
|
||||
for pkg in &pkgs {
|
||||
let pkgdir = format!("{}/.cache/ame/{}", std::env::var("HOME").unwrap(), pkg);
|
||||
let path = Path::new(&pkgdir);
|
||||
if path.is_dir() {
|
||||
let rm_result = fs::remove_dir_all(&path);
|
||||
match rm_result {
|
||||
Ok(_) => succ(format!("Removed AUR cache directory for {}", pkg)),
|
||||
Err(_) => err_unrec(format!("Failed to remove AUR cache directory for {}", pkg)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn purge_from_file(noconfirm: bool, file: &str) { // purge packages from list of packages
|
||||
let mut pkgs: Vec<String> = Vec::new();
|
||||
let contents = std::fs::read_to_string(&file).expect("Couldn't read file");
|
||||
for line in contents.lines() {
|
||||
pkgs.push(line.to_string());
|
||||
}
|
||||
sec(format!(
|
||||
"Attempting to uninstall packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
if noconfirm == true {
|
||||
let result = Command::new("pacman")
|
||||
.arg("-Rsu")
|
||||
.args(&pkgs)
|
||||
.arg("--noconfirm")
|
||||
.status()
|
||||
.expect("Couldn't call pacman");
|
||||
match result.code() {
|
||||
Some(0) => {
|
||||
succ(format!(
|
||||
"Succesfully uninstalled packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
rem_pkg(&pkgs);
|
||||
}
|
||||
Some(_) => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
None => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
};
|
||||
} else {
|
||||
let result = Command::new("pacman")
|
||||
.arg("-Rsu")
|
||||
.args(&pkgs)
|
||||
.status()
|
||||
.expect("Couldn't call pacman");
|
||||
match result.code() {
|
||||
Some(0) => {
|
||||
succ(format!(
|
||||
"Succesfully uninstalled packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
rem_pkg(&pkgs);
|
||||
}
|
||||
Some(_) => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
None => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
};
|
||||
}
|
||||
for pkg in &pkgs {
|
||||
let pkgdir = format!("{}/.cache/ame/{}", std::env::var("HOME").unwrap(), pkg);
|
||||
let path = Path::new(&pkgdir);
|
||||
if path.is_dir() {
|
||||
let rm_result = fs::remove_dir_all(&path);
|
||||
match rm_result {
|
||||
Ok(_) => succ(format!("Removed AUR cache directory for {}", pkg)),
|
||||
Err(_) => err_unrec(format!("Failed to remove AUR cache directory for {}", pkg)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
use crate::mods::{
|
||||
database::rem_pkg,
|
||||
strs::{err_rec, err_unrec, sec, succ},
|
||||
};
|
||||
use runas::Command;
|
||||
use std::{fs, path::Path};
|
||||
|
||||
pub fn purge(noconfirm: bool, pkgs: Vec<String>) {
|
||||
// purge packages
|
||||
sec(format!(
|
||||
"Attempting to uninstall packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
if noconfirm {
|
||||
let result = Command::new("pacman")
|
||||
.arg("-Rsu")
|
||||
.args(&pkgs)
|
||||
.arg("--noconfirm")
|
||||
.status()
|
||||
.expect("Couldn't call pacman");
|
||||
match result.code() {
|
||||
Some(0) => {
|
||||
succ(format!(
|
||||
"Succesfully uninstalled packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
rem_pkg(&pkgs);
|
||||
}
|
||||
Some(_) => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
None => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
};
|
||||
} else {
|
||||
let result = Command::new("pacman")
|
||||
.arg("-Rsu")
|
||||
.args(&pkgs)
|
||||
.status()
|
||||
.expect("Couldn't call pacman");
|
||||
match result.code() {
|
||||
Some(0) => {
|
||||
succ(format!(
|
||||
"Succesfully uninstalled packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
rem_pkg(&pkgs);
|
||||
}
|
||||
Some(_) => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
None => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
};
|
||||
}
|
||||
for pkg in &pkgs {
|
||||
let pkgdir = format!("{}/.cache/ame/{}", std::env::var("HOME").unwrap(), pkg);
|
||||
let path = Path::new(&pkgdir);
|
||||
if path.is_dir() {
|
||||
let rm_result = fs::remove_dir_all(&path);
|
||||
match rm_result {
|
||||
Ok(_) => succ(format!("Removed AUR cache directory for {}", pkg)),
|
||||
Err(_) => err_unrec(format!("Failed to remove AUR cache directory for {}", pkg)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn purge_from_file(noconfirm: bool, file: &str) {
|
||||
// purge packages from list of packages
|
||||
let mut pkgs: Vec<String> = Vec::new();
|
||||
let contents = std::fs::read_to_string(&file).expect("Couldn't read file");
|
||||
for line in contents.lines() {
|
||||
pkgs.push(line.to_string());
|
||||
}
|
||||
sec(format!(
|
||||
"Attempting to uninstall packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
if noconfirm {
|
||||
let result = Command::new("pacman")
|
||||
.arg("-Rsu")
|
||||
.args(&pkgs)
|
||||
.arg("--noconfirm")
|
||||
.status()
|
||||
.expect("Couldn't call pacman");
|
||||
match result.code() {
|
||||
Some(0) => {
|
||||
succ(format!(
|
||||
"Succesfully uninstalled packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
rem_pkg(&pkgs);
|
||||
}
|
||||
Some(_) => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
None => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
};
|
||||
} else {
|
||||
let result = Command::new("pacman")
|
||||
.arg("-Rsu")
|
||||
.args(&pkgs)
|
||||
.status()
|
||||
.expect("Couldn't call pacman");
|
||||
match result.code() {
|
||||
Some(0) => {
|
||||
succ(format!(
|
||||
"Succesfully uninstalled packages: {}",
|
||||
&pkgs.join(" ")
|
||||
));
|
||||
rem_pkg(&pkgs);
|
||||
}
|
||||
Some(_) => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
None => err_rec(format!("Couldn't uninstall packages: {}", &pkgs.join(" "))),
|
||||
};
|
||||
}
|
||||
for pkg in &pkgs {
|
||||
let pkgdir = format!("{}/.cache/ame/{}", std::env::var("HOME").unwrap(), pkg);
|
||||
let path = Path::new(&pkgdir);
|
||||
if path.is_dir() {
|
||||
let rm_result = fs::remove_dir_all(&path);
|
||||
match rm_result {
|
||||
Ok(_) => succ(format!("Removed AUR cache directory for {}", pkg)),
|
||||
Err(_) => err_unrec(format!("Failed to remove AUR cache directory for {}", pkg)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
pub fn rebuild(noconfirm: bool) {
|
||||
print!("installing crystal config")
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
use crate::mods::strs::{err_unrec, sec, succ};
|
||||
use runas::Command;
|
||||
|
||||
pub fn update() { // update the repositories
|
||||
sec(format!("Syncing package repos"));
|
||||
pub fn update() {
|
||||
// update the repositories
|
||||
sec("Syncing package repos".to_string());
|
||||
|
||||
let result = Command::new("pacman")
|
||||
.arg("-Sy")
|
||||
.status()
|
||||
.expect("Couldn't call pacman");
|
||||
match result.code() {
|
||||
Some(0) => succ(format!("Repos succesfully synced")),
|
||||
Some(_) => err_unrec(format!("Couldn't sync package repos")),
|
||||
None => err_unrec(format!("Couldn't sync package repos")),
|
||||
Some(0) => succ("Repos succesfully synced".to_string()),
|
||||
Some(_) => err_unrec("Couldn't sync package repos".to_string()),
|
||||
None => err_unrec("Couldn't sync package repos".to_string()),
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
pub fn noconf(args: &Vec<String>) -> bool { // noconfirm if user passed --noconfirm or added n to the end of the arg
|
||||
if args.contains(&"--noconfirm".to_string()) || args[0].ends_with(&"n".to_string()) {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
pub fn noconf(args: &[String]) -> bool {
|
||||
// noconfirm if user passed --noconfirm or added n to the end of the arg
|
||||
args.contains(&"--noconfirm".to_string()) || args[0].ends_with(&"n".to_string())
|
||||
}
|
||||
|
||||
pub fn argssort(args: &mut Vec<String>) -> &Vec<String> { // sort the args
|
||||
pub fn argssort(args: &mut Vec<String>) -> &Vec<String> {
|
||||
// sort the args
|
||||
if args.contains(&"--noconfirm".to_string()) {
|
||||
args.retain(|x| x != &"--noconfirm".to_string());
|
||||
args
|
||||
} else {
|
||||
args
|
||||
return args;
|
||||
}
|
||||
args
|
||||
}
|
||||
|
Loading…
Reference in New Issue