can now properly install from repos and aur

i18n
axtloss 3 years ago
parent 85c02b91af
commit e88e0e0950

@ -9,4 +9,5 @@ description = "a fast and efficient aur helper."
[dependencies]
git2 = "*"
raur = "2.0.2"
raur = "2.0.2"
runas = "*"

@ -5,4 +5,4 @@ pub fn clearcache() {
fs::remove_dir_all(&path).unwrap();
fs::create_dir(&path).unwrap();
}
}

@ -6,20 +6,17 @@ pub fn clone(pkg: &str) {
let error = format!("Couldn't install {}", &pkg);
let path = Path::new(&cachedir);
let results = raur::search(&pkg).expect(&error);
let url = format!("https://aur.archlinux.org/{}.git", &pkg);
let url = format!("https://aur.archlinux.org/{}.git", results[0].name);
if path.exists() {
fs::remove_dir_all(path).unwrap();
}
for _res in results.first() {
println!("Cloning {} ...", pkg);
Repository::clone(&url, &path).unwrap();
println!("Installing {} ...", pkg);
Command::new("makepkg")
.current_dir(&cachedir)
.arg("--noconfirm")
.arg("-si")
.output()
.expect(&error);
}
println!("Cloning {} ...", pkg);
Repository::clone(&url, &path).unwrap();
println!("Installing {} ...", pkg);
Command::new("makepkg")
.current_dir(&cachedir)
.arg("--noconfirm")
.arg("-si")
.status()
.expect(&error);
}

@ -0,0 +1,6 @@
use runas::Command;
pub fn install(pkg: &str) {
let errstr = format!("Something went wrong");
Command::new("pacman").arg("-S").arg(&pkg).status().expect(&errstr);
}

@ -1,14 +1,16 @@
mod clone;
mod uninstall;
mod help;
mod upgrade;
mod search;
mod clearcache;
use crate::{clone::clone, help::help, uninstall::uninstall, upgrade::upgrade, search::a_search, search::r_search, clearcache::clearcache};
use std::{env, process::exit};
mod install;
mod clone;
use crate::{clone::clone, help::help, uninstall::uninstall, upgrade::upgrade, search::a_search, search::r_search, clearcache::clearcache, install::install};
use std::{env, process::exit, process::Command};
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() <= 1 {
help();
exit(1);
@ -16,7 +18,12 @@ fn main() {
let oper = &args[1];
if oper == "-S" {
for arg in env::args().skip(2) {
clone(&arg);
let out = Command::new("pacman").arg("-Ss").arg(&arg).status().unwrap();
if out.success() {
install(&arg);
} else {
clone(&arg);
}
}
} else if oper == "-R" {
for arg in env::args().skip(2) {
@ -43,4 +50,4 @@ fn main() {
help();
exit(0);
}
}
}

@ -12,7 +12,6 @@ pub fn r_search(pkg: &str) {
Command::new("pacman")
.arg("-Ss")
.arg(&pkg)
.spawn()
//.status() TODO: for some reason cant use both .spawn and .status at the same time, need fix
.status()
.expect(&errstr);
}
}

@ -7,7 +7,6 @@ pub fn uninstall(pkg: &str) {
.arg("-R")
.arg("--noconfirm")
.arg(&pkg)
.spawn()
//.status() TODO: for some reason cant use both .spawn and .status at the same time, need fix
.status()
.expect(&errstr);
}
}

@ -4,7 +4,6 @@ pub fn upgrade() {
let errstr = format!("Something happened");
Command::new("pacman")
.arg("-Syu")
.spawn()
//.status() TODO: for some reason cant use both .spawn and .status at the same time, need fix
.status()
.expect(&errstr);
}
}

Loading…
Cancel
Save