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