in classic jnats fashion i broke it - heres the fix

i18n
jnats 3 years ago
parent 957a014cc9
commit 8cd104c2c0

@ -1,5 +1,5 @@
mod mods;
use mods::{clearcache::clearcache, clone::clone, help::help, install::install, search::{a_search, r_search}, uninstall::uninstall, upgrade::upgrade, update::update, ver::ver};
use mods::{clearcache::clearcache, clone::clone, help::help, install::install, search::{a_search, r_search}, uninstall::uninstall, upgrade::upgrade, update::update, ver::ver, strs::inf};
use std::{env, process::exit, process::Command, process::Stdio};
fn main() {
@ -24,22 +24,24 @@ fn main() {
.arg(&arg)
.stdout(Stdio::null())
.status()
.unwrap();
if out.success() {
.expect("");
if out.code() == Some(0) {
inf(format!("Installing {}", arg));
install(&arg);
} else {
inf(format!("Cloning {} from the AUR", arg));
clone(&arg);
}
}
// remove
} else if oper == "-R" || oper == "-Rs" || oper=="rem" {
} else if oper == "-R" || oper == "-Rs" || oper == "rem" {
for arg in env::args().skip(2) {
uninstall(&arg);
}
// upgrade
} else if oper == "-Syu" || oper=="upg" {
} else if oper == "-Syu" || oper == "upg" {
upgrade(&cache_path);
// update
@ -47,26 +49,26 @@ fn main() {
update();
// general search
} else if oper == "-Ss" || oper=="sea" {
} else if oper == "-Ss" || oper == "sea" {
for arg in env::args().skip(2) {
r_search(&arg);
a_search(&arg);
}
// aur search
} else if oper == "-Sa" || oper=="aursea" {
} else if oper == "-Sa" || oper == "aursea" {
for arg in env::args().skip(2) {
a_search(&arg);
}
// repo search
} else if oper == "-Sr" || oper=="repsea" {
} else if oper == "-Sr" || oper == "repsea" {
for arg in env::args().skip(2) {
r_search(&arg);
}
// clear cache !! DEBUG ONLY !! DO NOT DO THIS IF YOU DONT KNOW WHAT YOURE DOING !!
} else if oper == "-Cc" || oper=="clr" {
} else if oper == "-Cc" || oper == "clr" {
clearcache();
// version / contrib

@ -9,8 +9,8 @@ pub fn clone(pkg: &str) {
let pkgpath = Path::new(&pkgdir);
let results = raur::search(&pkg).unwrap();
if results.len() <= 1 {
err_unrec(format!("No matching packages found"));
if results.len() == 0 {
err_unrec(format!("No matching AUR packages found"));
}
let url = format!("https://aur.archlinux.org/{}.git", results[0].name);
@ -28,16 +28,18 @@ pub fn clone(pkg: &str) {
inf(format!("Cloning {} ...", pkg));
let cd_result = env::set_current_dir(&pkgdir);
match cd_result {
Ok(_) => {
inf(format!("Entered cache directory"))
if pkgpath.is_dir() {
let rm_result = fs::remove_dir_all(&pkgpath);
match rm_result {
Ok(_) => {
inf(format!("Package path for {} already found. Removing to reinstall", pkg))
}
Err(_) => {
err_unrec(format!("Package path for {} already found, but could not remove to reinstall", pkg))
}}
}
Err(_) => {
err_unrec(format!(""))
}}
let dir_result = fs::create_dir(&pkg);
let dir_result = fs::create_dir(&pkgdir);
match dir_result {
Ok(_) => {
inf(format!("Cloned {} to package directory", pkg))
@ -46,6 +48,15 @@ pub fn clone(pkg: &str) {
err_unrec(format!("Couldn't create package directory for {}", pkg))
}}
let cd_result = env::set_current_dir(&pkgdir);
match cd_result {
Ok(_) => {
inf(format!("Entered package directory"))
}
Err(_) => {
err_unrec(format!("Could not enter package directory"))
}}
Repository::clone(&url, &pkgpath).unwrap();
let cd2_result = env::set_current_dir(&pkgpath);
@ -54,7 +65,7 @@ pub fn clone(pkg: &str) {
inf(format!("Entering package directory for {}", pkg))
}
Err(_) => {
err_unrec(format!("Couldn't enter cache directory for {}", pkg))
err_unrec(format!("Couldn't enter package directory for {}", pkg))
}}
inf(format!("Installing {} ...", pkg));

Loading…
Cancel
Save