i18n
jnats 3 years ago
parent 5309d4347a
commit fd6a008efb

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

@ -1,13 +1,27 @@
mod mods;
use mods::{clearcache::clearcache, clone::clone, help::help, install::install, inssort::inssort, search::{a_search, r_search}, uninstall::uninstall, upgrade::upgrade, update::update, ver::ver, strs::inf, strs::err_unrec, strs::err_rec, xargs::*};
use mods::{
clearcache::clearcache,
clone::clone,
help::help,
inssort::inssort,
install::install,
search::{a_search, r_search},
strs::err_rec,
strs::err_unrec,
strs::inf,
uninstall::uninstall,
update::update,
upgrade::upgrade,
ver::ver,
xargs::*,
};
use std::{env, process::exit, process::Command};
fn main() {
// let statements
let args: Vec<String> = env::args().collect();
let mut pkgs: Vec<String> = env::args().skip(2).collect();
// args catch
if args.len() <= 1 {
help();
@ -29,7 +43,7 @@ fn main() {
// upgrade
} else if oper == "-Syu" || oper == "-Syun" || oper == "upg" {
upgrade(noconfirm);
upgrade(noconfirm);
// update
} else if oper == "-Sy" || oper == "upd" {
@ -68,13 +82,14 @@ fn main() {
.expect("Something has gone wrong.");
match pass.code() {
Some(1) => {
err_rec(format!("No such operation \"{}\"", args.join(" ")));
inf(format!("Try running \"ame help\" for an overview of how to use ame"))
Some(1) => {
err_rec(format!("No such operation \"{}\"", args.join(" ")));
inf(format!(
"Try running \"ame help\" for an overview of how to use ame"
))
}
Some(_) => {}
None => err_unrec(format!("Something has gone terribly wrong.")),
}
Some(_) => {}
None => {
err_unrec(format!("Something has gone terribly wrong."))
}}
}
}

@ -1,12 +1,12 @@
pub mod clearcache;
pub mod clone;
pub mod help;
pub mod inssort;
pub mod install;
pub mod search;
pub mod strs;
pub mod uninstall;
pub mod upgrade;
pub mod update;
pub mod strs;
pub mod upgrade;
pub mod ver;
pub mod inssort;
pub mod xargs;

@ -1,5 +1,5 @@
use std::fs;
use crate::mods::strs::err_rec;
use std::fs;
pub fn clearcache() {
let path = format!("{}/.cache/ame/", std::env::var("HOME").unwrap());

@ -1,19 +1,26 @@
use crate::{
err_unrec, inf, inssort, mods::strs::prompt, mods::strs::sec, mods::strs::succ,
mods::uninstall::uninstall,
};
use git2::Repository;
use moins::Moins;
use std::{env, fs, path::Path, process::Command};
use crate::{err_unrec, inf, inssort, mods::strs::succ, mods::strs::sec, mods::strs::prompt, mods::uninstall::uninstall};
fn uninstall_make_depend(results: Vec<raur::Package>, pkg: &str) {
let aurpkgname = results[0].name.to_string();
let make_depends = raur::info(&[&aurpkgname]).unwrap()[0].make_depends.clone();
if make_depends.len() != 0 {
inf(format!("{} installed following make dependencies: {}", pkg, make_depends.join(", ")));
let remove = prompt(format!("Would you like to remove them?"));
if remove == true {
uninstall(true, make_depends);
}
let make_depends = raur::info(&[&aurpkgname]).unwrap()[0].make_depends.clone();
if make_depends.len() != 0 {
inf(format!(
"{} installed following make dependencies: {}",
pkg,
make_depends.join(", ")
));
let remove = prompt(format!("Would you like to remove them?"));
if remove == true {
uninstall(true, make_depends);
}
}
succ(format!("Succesfully installed {}", pkg));
}
@ -32,12 +39,9 @@ pub fn clone(noconfirm: bool, pkg: &str) {
if !path.is_dir() {
let cache_result = fs::create_dir(&path);
match cache_result {
Ok(_) => {
inf(format!("Created cache path (first run)"))
Ok(_) => inf(format!("Created cache path (first run)")),
Err(_) => err_unrec(format!("Could not create cache path")),
}
Err(_) => {
err_unrec(format!("Could not create cache path"))
}}
}
inf(format!("Cloning {} ...", pkg));
@ -45,48 +49,44 @@ pub fn clone(noconfirm: bool, pkg: &str) {
if Path::new(&pkgdir).is_dir() {
let rm_result = fs::remove_dir_all(&pkgdir);
match rm_result {
Ok(_) => {
inf(format!("Package path for {} already found. Removing to reinstall", pkg))
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!("Package path for {} already found, but could not remove to reinstall", pkg))
}}
}
let dir_result = fs::create_dir(&pkgdir);
match dir_result {
Ok(_) => {
inf(format!("Cloned {} to package directory", pkg))
Ok(_) => inf(format!("Cloned {} to package directory", pkg)),
Err(_) => err_unrec(format!("Couldn't create package directory for {}", pkg)),
}
Err(_) => {
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"))
Ok(_) => inf(format!("Entered package directory")),
Err(_) => err_unrec(format!("Could not enter package directory")),
}
Err(_) => {
err_unrec(format!("Could not enter package directory"))
}}
sec(format!("Installing AUR package depends"));
// you can use this to get the makedepends too - just use the make_depends field instead of the depends field
// | riiiiight
// | riiiiight
let aurpkgname = results[0].name.to_string(); // v here
let depends = raur::info(&[&aurpkgname]).unwrap()[0].depends.clone();
inssort(noconfirm, depends);
let clone = Repository::clone(&url, Path::new(&pkgdir));
match clone {
Ok(_) => {
inf(format!("Cloning {} into package directory", pkg));
Ok(_) => {
inf(format!("Cloning {} into package directory", pkg));
}
Err(_) => err_unrec(format!("Failed cloning {} into package directory", pkg)),
}
Err(_) => {
err_unrec(format!("Failed cloning {} into package directory", pkg))
}}
if noconfirm == false {
let pkgbuild = prompt(format!("View PKGBUILD?"));
@ -100,31 +100,33 @@ pub fn clone(noconfirm: bool, pkg: &str) {
if noconfirm == true {
sec(format!("Installing {} ...", pkg));
let install_result = Command::new("makepkg")
.arg("-si")
.arg("--noconfirm")
.status();
.arg("-si")
.arg("--noconfirm")
.status();
match install_result {
Ok(_) => {
uninstall_make_depend(results, pkg);
}
Err(_) => {
err_unrec(format!("Couldn't install {}", pkg));
}};
Ok(_) => {
uninstall_make_depend(results, pkg);
}
Err(_) => {
err_unrec(format!("Couldn't install {}", pkg));
}
};
} else {
sec(format!("Installing {} ...", pkg));
let install_result = Command::new("makepkg")
.arg("-si")
.status()
.expect("Couldn't call makepkg");
.arg("-si")
.status()
.expect("Couldn't call makepkg");
match install_result.code() {
Some(0) => {
uninstall_make_depend(results, pkg);
}
Some(_) => {
err_unrec(format!("Couldn't install {}", pkg));
}
None => {
err_unrec(format!("Couldn't install {}", pkg));
}};
Some(0) => {
uninstall_make_depend(results, pkg);
}
Some(_) => {
err_unrec(format!("Couldn't install {}", pkg));
}
None => {
err_unrec(format!("Couldn't install {}", pkg));
}
};
}
}

@ -1,9 +1,10 @@
use crate::mods::strs::{inf, err_rec};
use crate::mods::strs::{err_rec, inf};
pub fn help() {
println!("");
inf(format!("Usage:"));
println!("
println!(
"
ame -S(n) / ins <pkg> - install a package
ame -R(n) / -Rs(n) / rm <pkg> - remove a package
ame -Syu(n) / upg - upgrade all packages to latest version
@ -12,9 +13,9 @@ ame -Sa / aursea <pkg> - search for a package in the aur
ame -Sr / repsea <pkg> - search for a package in the repos
ame -v / ver - contributors and version info
ame <any valid pacman flags> - passes said flags to be processed by pacman");
ame <any valid pacman flags> - passes said flags to be processed by pacman"
);
println!("");
err_rec(format!("Appending 'n' where (n) is present passes '--noconfirm' to pacman. Use at your own risk. (alternatively, using '--noconfirm' as a flag works too.)"));
println!("");
}

@ -1,29 +1,23 @@
use crate::{clone, install, err_unrec, mods::strs::sec};
use std::process::{Stdio, Command};
use crate::{clone, err_unrec, install, mods::strs::sec};
use std::process::{Command, Stdio};
pub fn inssort(noconfirm: bool, pkgs: Vec<String>) {
let mut repo = vec![];
let mut aur = vec![];
for pkg in pkgs {
let out = Command::new("pacman")
.arg("-Ss")
.arg(&pkg)
.stdout(Stdio::null())
.status()
.expect("Something has gone wrong.");
.arg("-Ss")
.arg(&pkg)
.stdout(Stdio::null())
.status()
.expect("Something has gone wrong.");
match out.code() {
Some(0) => {
repo.push(pkg)
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")),
}
Some(1) => {
aur.push(pkg)
}
Some(_) => {
err_unrec(format!("Something has gone terribly wrong"))
}
None => {
err_unrec(format!("Process terminated"))
}}}
}
if repo.len() != 0 {
sec(format!("Installing repo packages: {}", &repo.join(", ")));

@ -1,31 +1,30 @@
use runas::Command;
use crate::mods::strs::{err_unrec, succ};
use runas::Command;
pub fn install(noconfirm: bool, pkg: &str) {
let pkgs: Vec<&str> = pkg.split(" ").collect();
if noconfirm == true {
let result = Command::new("pacman").arg("-Sy").arg("--noconfirm").args(&pkgs).status().expect("Couldn't call pacman");
let result = Command::new("pacman")
.arg("-Sy")
.arg("--noconfirm")
.args(&pkgs)
.status()
.expect("Couldn't call pacman");
match result.code() {
Some(0) => {
succ(format!("Succesfully installed packages: {}", pkg))
}
Some(_) => {
err_unrec(format!("Couldn't install packages: {}", pkg))
}
None => {
err_unrec(format!("Couldn't install packages: {}", pkg))
}};
Some(0) => succ(format!("Succesfully installed packages: {}", pkg)),
Some(_) => err_unrec(format!("Couldn't install packages: {}", pkg)),
None => err_unrec(format!("Couldn't install packages: {}", pkg)),
};
} else {
let result = Command::new("pacman").arg("-Sy").args(&pkgs).status().expect("Couldn't call pacman");
let result = Command::new("pacman")
.arg("-Sy")
.args(&pkgs)
.status()
.expect("Couldn't call pacman");
match result.code() {
Some(0) => {
succ(format!("Succesfully installed packages: {}", pkg))
}
Some(_) => {
err_unrec(format!("Couldn't install packages: {}", pkg))
}
None => {
err_unrec(format!("Couldn't install packages: {}", pkg))
}};
Some(0) => succ(format!("Succesfully installed packages: {}", pkg)),
Some(_) => err_unrec(format!("Couldn't install packages: {}", pkg)),
None => err_unrec(format!("Couldn't install packages: {}", pkg)),
};
}
}

@ -1,6 +1,6 @@
use std::{ops::Deref, process::Command};
use crate::mods::strs::{err_rec, err_unrec, succ};
use ansi_term::Colour;
use crate::mods::strs::{err_unrec, err_rec, succ};
use std::{ops::Deref, process::Command};
pub fn a_search(pkg: &str) {
let results = raur::search(&pkg);
@ -10,33 +10,27 @@ pub fn a_search(pkg: &str) {
err_rec(format!("No matching AUR packages found"));
}
for res in r {
println!("{}{} {}\n {}",
Colour::Cyan.bold().paint("aur/"),
Colour::White.bold().paint(&res.name),
Colour::Green.bold().paint(&res.version),
Colour::White.paint(res.description.as_ref().map_or("n/a", String::deref)));
println!(
"{}{} {}\n {}",
Colour::Cyan.bold().paint("aur/"),
Colour::White.bold().paint(&res.name),
Colour::Green.bold().paint(&res.version),
Colour::White.paint(res.description.as_ref().map_or("n/a", String::deref))
);
}
}
}
pub fn r_search(pkg: &str) {
let result = Command::new("pacman")
.arg("-Ss")
.arg(&pkg)
.status()
.unwrap();
.arg("-Ss")
.arg(&pkg)
.status()
.unwrap();
match result.code() {
Some(0) => {
succ(format!("Repo search successful"))
}
Some(1) => {
err_rec(format!("No matching repo packages found"))
}
Some(_) => {
err_unrec(format!("Someting went terribly wrong"))
}
None => {
err_unrec(format!("Couldn't search pacman repos"))
}};
Some(0) => succ(format!("Repo search successful")),
Some(1) => err_rec(format!("No matching repo packages found")),
Some(_) => err_unrec(format!("Someting went terribly wrong")),
None => err_unrec(format!("Couldn't search pacman repos")),
};
}

@ -1,49 +1,59 @@
use ansi_term::Colour;
use std::{process, env, io, io::Write};
use std::{env, io, io::Write, process};
use uwuizer::*;
pub fn inf(a: std::string::String){
pub fn inf(a: std::string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!("{} {}",
Colour::Purple.paint("❖"),
Colour::White.paint(uwuize!(&a)));
println!(
"{} {}",
Colour::Purple.paint("❖"),
Colour::White.paint(uwuize!(&a))
);
} else {
println!("{} {}",
Colour::Purple.paint("❖"),
Colour::White.paint(a));
println!("{} {}", Colour::Purple.paint("❖"), Colour::White.paint(a));
}
}
pub fn sec(a: std::string::String){
pub fn sec(a: std::string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!("{} {}",
Colour::Purple.bold().paint("❖"),
Colour::White.bold().paint(uwuize!(&a)));
println!(
"{} {}",
Colour::Purple.bold().paint("❖"),
Colour::White.bold().paint(uwuize!(&a))
);
} else {
println!("{} {}",
Colour::Purple.bold().paint("❖"),
Colour::White.bold().paint(a));
println!(
"{} {}",
Colour::Purple.bold().paint("❖"),
Colour::White.bold().paint(a)
);
}
}
pub fn succ(a: std::string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!("{} {}",
Colour::Green.bold().paint("✓"),
Colour::Green.paint(uwuize!(&a)));
println!(
"{} {}",
Colour::Green.bold().paint("✓"),
Colour::Green.paint(uwuize!(&a))
);
} else {
println!("{} {}",
Colour::Green.bold().paint("✓"),
Colour::Green.paint(&a));
println!(
"{} {}",
Colour::Green.bold().paint("✓"),
Colour::Green.paint(&a)
);
}
}
pub fn prompt(a: std::string::String) -> bool {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
print!("{} {} {}",
Colour::Purple.bold().paint("❖"),
Colour::White.bold().paint(uwuize!(&a)),
Colour::White.bold().paint("(Y/n): "));
print!(
"{} {} {}",
Colour::Purple.bold().paint("❖"),
Colour::White.bold().paint(uwuize!(&a)),
Colour::White.bold().paint("(Y/n): ")
);
io::stdout().flush().ok().expect("Couldn't flush stdout");
let mut yn: String = String::new();
let _ = std::io::stdin().read_line(&mut yn);
@ -53,10 +63,12 @@ pub fn prompt(a: std::string::String) -> bool {
true
}
} else {
print!("{} {} {}",
Colour::Purple.bold().paint("❖"),
Colour::White.bold().paint(&a),
Colour::White.bold().paint("(Y/n): "));
print!(
"{} {} {}",
Colour::Purple.bold().paint("❖"),
Colour::White.bold().paint(&a),
Colour::White.bold().paint("(Y/n): ")
);
io::stdout().flush().ok().expect("Couldn't flush stdout");
let mut yn: String = String::new();
let _ = std::io::stdin().read_line(&mut yn);
@ -68,31 +80,38 @@ pub fn prompt(a: std::string::String) -> bool {
}
}
pub fn err_unrec(a: std::string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!("{} {} {}",
Colour::Red.bold().paint(uwuize!("✖ Unrecoverable error:")),
Colour::Red.paint(uwuize!(&a)),
Colour::Red.bold().paint(uwuize!("Terminating.")));
println!(
"{} {} {}",
Colour::Red.bold().paint(uwuize!("✖ Unrecoverable error:")),
Colour::Red.paint(uwuize!(&a)),
Colour::Red.bold().paint(uwuize!("Terminating."))
);
process::exit(1);
} else {
println!("{} {} {}",
Colour::Red.bold().paint("✖ Unrecoverable error:"),
Colour::Red.paint(a),
Colour::Red.bold().paint("Terminating."));
println!(
"{} {} {}",
Colour::Red.bold().paint("✖ Unrecoverable error:"),
Colour::Red.paint(a),
Colour::Red.bold().paint("Terminating.")
);
process::exit(1);
}
}
pub fn err_rec(a: std::string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!("{} {}",
Colour::Yellow.bold().paint(uwuize!("⚠ WARNING:")),
Colour::Yellow.paint(uwuize!(&a)));
println!(
"{} {}",
Colour::Yellow.bold().paint(uwuize!("⚠ WARNING:")),
Colour::Yellow.paint(uwuize!(&a))
);
} else {
println!("{} {}",
Colour::Yellow.bold().paint("⚠ WARNING:"),
Colour::Yellow.paint(a));
println!(
"{} {}",
Colour::Yellow.bold().paint("⚠ WARNING:"),
Colour::Yellow.paint(a)
);
}
}

@ -1,46 +1,51 @@
use crate::mods::strs::{err_rec, err_unrec, sec, succ};
use runas::Command;
use crate::mods::strs::{err_unrec, sec, succ, err_rec};
use std::{fs, path::Path};
pub fn uninstall(noconfirm: bool, pkgs: Vec<String>) {
sec(format!("Attempting to uninstall packages: {}", &pkgs.join(" ")));
if noconfirm == true {
let result = Command::new("pacman").arg("-Rs").args(&pkgs).arg("--noconfirm").status().expect("Couldn't call pacman");
match result.code() {
Some(0) => {
succ(format!("Succesfully uninstalled 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").arg("-Rs").args(&pkgs).status().expect("Couldn't call pacman");
match result.code() {
Some(0) => {
succ(format!("Succesfully uninstalled 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);
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))
}};
}
sec(format!(
"Attempting to uninstall packages: {}",
&pkgs.join(" ")
));
if noconfirm == true {
let result = Command::new("pacman")
.arg("-Rs")
.args(&pkgs)
.arg("--noconfirm")
.status()
.expect("Couldn't call pacman");
match result.code() {
Some(0) => succ(format!(
"Succesfully uninstalled 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")
.arg("-Rs")
.args(&pkgs)
.status()
.expect("Couldn't call pacman");
match result.code() {
Some(0) => succ(format!(
"Succesfully uninstalled 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);
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,21 +1,16 @@
use runas::Command;
use crate::mods::strs::{err_unrec, sec, succ};
use runas::Command;
pub fn update() {
sec(format!("Syncing package repos"));
let result = Command::new("pacman")
.arg("-Sy")
.status()
.expect("Couldn't call 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"))
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")),
}
None => {
err_unrec(format!("Couldn't sync package repos"))
}}
}

@ -1,84 +1,75 @@
use crate::mods::strs::{err_unrec, inf, sec, succ};
use runas::Command;
use std::env;
use crate::mods::strs::{err_unrec, inf, sec, succ};
pub fn upgrade(noconfirm: bool){
pub fn upgrade(noconfirm: bool) {
let homepath = std::env::var("HOME").unwrap();
let cachedir = format!("/{}/.cache/ame/", homepath);
sec(format!("Performing system upgrade"));
if noconfirm == true {
let result = Command::new("pacman")
.arg("-Syu")
.arg("--noconfirm")
.status()
.expect("Couldn't call pacman");
.arg("-Syu")
.arg("--noconfirm")
.status()
.expect("Couldn't call pacman");
match result.code() {
Some(0) => {
succ(format!("All repo packages upgraded"))
}
Some(_) => {
err_unrec(format!("Couldn't upgrade packages"))
}
None => {
err_unrec(format!("Couldn't upgrade packages"))
}};
Some(0) => succ(format!("All repo packages upgraded")),
Some(_) => err_unrec(format!("Couldn't upgrade packages")),
None => err_unrec(format!("Couldn't upgrade packages")),
};
} else {
let result = Command::new("pacman")
.arg("-Syu")
.status()
.expect("Couldn't call pacman");
.arg("-Syu")
.status()
.expect("Couldn't call pacman");
match result.code() {
Some(0) => {
succ(format!("All repo packages upgraded"))
}
Some(_) => {
err_unrec(format!("Couldn't upgrade packages"))
}
None => {
err_unrec(format!("Couldn't upgrade packages"))
}};
Some(0) => succ(format!("All repo packages upgraded")),
Some(_) => err_unrec(format!("Couldn't upgrade packages")),
None => err_unrec(format!("Couldn't upgrade packages")),
};
}
for file in std::fs::read_dir(&cachedir).unwrap() {
let dir = &file.unwrap().path();
let output = std::process::Command::new("git").arg("pull").output().unwrap();
let output = std::process::Command::new("git")
.arg("pull")
.output()
.unwrap();
let update_available = String::from_utf8(output.stdout).unwrap();
let cd_result = env::set_current_dir(&dir);
match cd_result {
Ok(_) => {
inf(format!("Entered AUR package directory to pull changes"))
Ok(_) => inf(format!("Entered AUR package directory to pull changes")),
Err(_) => err_unrec(format!(
"Could not enter AUR package directory to pull changes"
)),
}
Err(_) => {
err_unrec(format!("Could not enter AUR package directory to pull changes"))
}}
if update_available != "Already up to date." {
let path_as_str = &dir.display().to_string();
let pkg: Vec<&str> = path_as_str.split("/").collect();
inf(format!("{} is up to date", pkg[pkg.len()-1]));
inf(format!("{} is up to date", pkg[pkg.len() - 1]));
} else {
let cd2_result = env::set_current_dir(&dir);
match cd2_result {
Ok(_) => {
inf(format!("Entering AUR package directory to install new version"))
Ok(_) => inf(format!(
"Entering AUR package directory to install new version"
)),
Err(_) => err_unrec(format!(
"Couldn't enter AUR package directory to install new version"
)),
}
Err(_) => {
err_unrec(format!("Couldn't enter AUR package directory to install new version"))
}}
let makepkg_result = std::process::Command::new("makepkg").arg("-si").status().expect("Couldn't call makepkg");
let makepkg_result = std::process::Command::new("makepkg")
.arg("-si")
.status()
.expect("Couldn't call makepkg");
match makepkg_result.code() {
Some(0) => {
succ(format!("New AUR package version installed"))
}
Some(_) => {
err_unrec(format!("Couldn't install new AUR package version"))
}
None => {
err_unrec(format!("Couldn't install new AUR package version"))
}};
Some(0) => succ(format!("New AUR package version installed")),
Some(_) => err_unrec(format!("Couldn't install new AUR package version")),
None => err_unrec(format!("Couldn't install new AUR package version")),
};
}
}
}

@ -3,7 +3,7 @@ use ansi_term::Colour;
pub fn ver() {
println!("");
inf(format!("ame - v2.3.1"));
inf(format!("ame - v2.4.0"));
println!("");
inf(format!("Contributors:"));
println!("- axtlos <axtlos@salyut.one>");
@ -11,9 +11,16 @@ pub fn ver() {
println!("- jasio <jasiobene@icloud.com>");
println!("- generic <mdc028@bucknell.edu>");
println!("");
inf(format!("This software is licensed under the BSD 3-Clause license."));
inf(format!(
"This software is licensed under the BSD 3-Clause license."
));
inf(format!("All source code is available at:"));
println!("");
println!("{}", Colour::Purple.bold().paint("https://github.com/crystal-linux/ame"));
println!(
"{}",
Colour::Purple
.bold()
.paint("https://github.com/crystal-linux/ame")
);
println!("");
}

@ -1,17 +1,17 @@
pub fn noconf(args: &Vec<String>) -> bool {
if args.contains(&"--noconfirm".to_string()) || args[1].ends_with(&"n".to_string()) {
true
} else {
false
}
if args.contains(&"--noconfirm".to_string()) || args[1].ends_with(&"n".to_string()) {
true
} else {
false
}
}
pub fn argssort(args: &mut Vec<String>) -> &Vec<String> {
if args.contains(&"--noconfirm".to_string()) {
args.retain(|x| x != &"--noconfirm".to_string());
println!("{:?}", args);
args
} else {
args
}
if args.contains(&"--noconfirm".to_string()) {
args.retain(|x| x != &"--noconfirm".to_string());
println!("{:?}", args);
args
} else {
args
}
}

Loading…
Cancel
Save