now able to install packages from a specific repo by appending the repo to the package ( community/neofetch or aur/nofetch-git )

i18n
amy 3 years ago
parent 50864e05ad
commit 47b16a7f90

@ -1,6 +1,6 @@
[package] [package]
name = "ame" name = "ame"
version = "0.0.0" version = "2.4.1"
authors = [ "jnats <jnats@salyut.one>", "axtlos <axtlos@salyut.one>" ] authors = [ "jnats <jnats@salyut.one>", "axtlos <axtlos@salyut.one>" ]
edition = "2018" edition = "2018"
description = "a fast and efficient aur helper." description = "a fast and efficient aur helper."

@ -8,37 +8,62 @@ pub fn inssort(noconfirm: bool, as_dep: bool, pkgs: Vec<String>) {
let re = Regex::new(r"(\S+)((?:>=|<=)\S+$)").unwrap(); let re = Regex::new(r"(\S+)((?:>=|<=)\S+$)").unwrap();
let reg = Regex::new(r"((?:>=|<=)\S+$)").unwrap(); let reg = Regex::new(r"((?:>=|<=)\S+$)").unwrap();
for pkg in pkgs { for pkg in pkgs {
let caps = re.captures(&pkg); match pkg.contains("/") {
match caps { true => {
Some(_) => { match pkg.split("/").collect::<Vec<&str>>()[0] == "aur" {
let out = Command::new("pacman") true => {
.arg("-Ss") aur.push(pkg.split("/").collect::<Vec<&str>>()[1].to_string());
.arg(format!( }
"^{}$", false => {
caps.unwrap().get(1).map_or("", |m| m.as_str()) let out = Command::new("bash")
)) .arg("-c")
.stdout(Stdio::null()) .arg(format!("pacman -Sl {} | grep {}", pkg.split("/").collect::<Vec<&str>>()[0],pkg.split("/").collect::<Vec<&str>>()[1]))
.status() .stdout(Stdio::null())
.expect("Something has gone wrong."); .status()
match out.code() { .expect("Something has gone wrong.");
Some(0) => repo.push(reg.replace_all(&pkg, "").to_string()), match out.code() {
Some(1) => aur.push(pkg), Some(0) => repo.push(reg.replace_all(&pkg, "").to_string()),
Some(_) => err_unrec(format!("Something has gone terribly wrong")), Some(1) => err_unrec(format!("Package {} not found in repository {}", pkg.split("/").collect::<Vec<&str>>()[1],pkg.split("/").collect::<Vec<&str>>()[0])),
None => err_unrec(format!("Process terminated")), Some(_) => err_unrec(format!("Something has gone terribly wrong")),
None => err_unrec(format!("Process terminated")),
}
}
} }
} }
None => { false => {
let out = Command::new("pacman") let caps = re.captures(&pkg);
.arg("-Ss") match caps {
.arg(format!("^{}$", &pkg)) Some(_) => {
.stdout(Stdio::null()) let out = Command::new("pacman")
.status() .arg("-Ss")
.expect("Something has gone wrong."); .arg(format!(
match out.code() { "^{}$",
Some(0) => repo.push(pkg), caps.unwrap().get(1).map_or("", |m| m.as_str())
Some(1) => aur.push(pkg), ))
Some(_) => err_unrec(format!("Something has gone terribly wrong")), .stdout(Stdio::null())
None => err_unrec(format!("Process terminated")), .status()
.expect("Something has gone wrong.");
match out.code() {
Some(0) => repo.push(reg.replace_all(&pkg, "").to_string()),
Some(1) => aur.push(pkg),
Some(_) => err_unrec(format!("Something has gone terribly wrong")),
None => err_unrec(format!("Process terminated")),
}
}
None => {
let out = Command::new("pacman")
.arg("-Ss")
.arg(format!("^{}$", &pkg))
.stdout(Stdio::null())
.status()
.expect("Something has gone wrong.");
match out.code() {
Some(0) => repo.push(pkg),
Some(1) => aur.push(pkg),
Some(_) => err_unrec(format!("Something has gone terribly wrong")),
None => err_unrec(format!("Process terminated")),
}
}
} }
} }
} }

Loading…
Cancel
Save