diff --git a/Cargo.toml b/Cargo.toml index 767c54d..9fd50a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ame" -version = "2.2.0" +version = "2.2.1" authors = [ "jnats ", "axtlos " ] edition = "2018" description = "a fast and efficient aur helper." diff --git a/src/main.rs b/src/main.rs index 506afea..764ffbd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,6 @@ fn main() { // upgrade } else if oper == "-Syu" || oper == "-Syun" || oper == "upg" { - inf(format!("Performing system upgrade")); if oper == ("-Syun") { upgrade(true, &cache_path); } else { diff --git a/src/mods/clone.rs b/src/mods/clone.rs index 3e959f8..b22e08b 100644 --- a/src/mods/clone.rs +++ b/src/mods/clone.rs @@ -1,6 +1,6 @@ use git2::Repository; use std::{env, fs, path::Path, process::Command}; -use crate::{err_unrec, inf, inssort}; +use crate::{err_unrec, inf, inssort, mods::strs::succ, mods::strs::sec}; pub fn clone(noconfirm: bool, pkg: &str) { let cachedir = format!("{}/.cache/ame", std::env::var("HOME").unwrap()); @@ -56,7 +56,11 @@ pub fn clone(noconfirm: bool, pkg: &str) { err_unrec(format!("Could not enter package directory")) }} - let aurpkgname = results[0].name.to_string(); + 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 + let aurpkgname = results[0].name.to_string(); // v here let depends = raur::info(&[&aurpkgname]).unwrap()[0].depends.clone(); if noconfirm == true { inssort(true, depends); @@ -67,28 +71,32 @@ pub fn clone(noconfirm: bool, pkg: &str) { Repository::clone(&url, Path::new(&pkgdir)).unwrap(); if noconfirm == true { - inf(format!("Installing {} ...", pkg)); + sec(format!("Installing {} ...", pkg)); let install_result = Command::new("makepkg") .arg("-si") .arg("--noconfirm") .status(); match install_result { Ok(_) => { - inf(format!("Succesfully installed {}", pkg)); + succ(format!("Succesfully installed {}", pkg)); } Err(_) => { err_unrec(format!("Couldn't install {}", pkg)); }}; } else { - inf(format!("Installing {} ...", pkg)); + sec(format!("Installing {} ...", pkg)); let install_result = Command::new("makepkg") .arg("-si") - .status(); - match install_result { - Ok(_) => { - inf(format!("Succesfully installed {}", pkg)); + .status() + .expect("Couldn't call makepkg"); + match install_result.code() { + Some(0) => { + succ(format!("Succesfully installed {}", pkg)); } - Err(_) => { + Some(_) => { + err_unrec(format!("Couldn't install {}", pkg)); + } + None => { err_unrec(format!("Couldn't install {}", pkg)); }}; } diff --git a/src/mods/inssort.rs b/src/mods/inssort.rs index 69d763c..57ec6c8 100644 --- a/src/mods/inssort.rs +++ b/src/mods/inssort.rs @@ -1,4 +1,4 @@ -use crate::{clone, install, inf, err_unrec}; +use crate::{clone, install, err_unrec, mods::strs::sec}; use std::process::{Stdio, Command}; pub fn inssort(noconfirm: bool, pkgs: Vec) { @@ -26,7 +26,7 @@ pub fn inssort(noconfirm: bool, pkgs: Vec) { }}} if repo.len() != 0 { - inf(format!("Installing repo packages: {}", &repo.join(", "))); + sec(format!("Installing repo packages: {}", &repo.join(", "))); if noconfirm == true { install(true, &repo.join(" ")); } else { @@ -35,7 +35,7 @@ pub fn inssort(noconfirm: bool, pkgs: Vec) { } for a in aur { - inf(format!("Installing AUR package: {}", a)); + sec(format!("Installing AUR package: {}", a)); if noconfirm == true { clone(true, &a); } else { diff --git a/src/mods/install.rs b/src/mods/install.rs index aaa40d3..a0b2d03 100644 --- a/src/mods/install.rs +++ b/src/mods/install.rs @@ -1,24 +1,30 @@ use runas::Command; -use crate::mods::strs::{inf, err_unrec}; +use crate::mods::strs::{err_unrec, succ}; 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(); - match result { - Ok(_) => { - inf(format!("Succesfully installed packages: {}", pkg)) + 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)) } - Err(_) => { + 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(); - match result { - Ok(_) => { - inf(format!("Succesfully installed packages: {}", pkg)) + 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)) } - Err(_) => { + None => { err_unrec(format!("Couldn't install packages: {}", pkg)) }}; } diff --git a/src/mods/search.rs b/src/mods/search.rs index db80ad3..2b3feba 100644 --- a/src/mods/search.rs +++ b/src/mods/search.rs @@ -1,6 +1,6 @@ use std::{ops::Deref, process::Command}; use ansi_term::Colour; -use crate::mods::strs::{err_unrec, err_rec, inf}; +use crate::mods::strs::{err_unrec, err_rec, succ}; pub fn a_search(pkg: &str) { let results = raur::search(&pkg); @@ -27,7 +27,7 @@ pub fn r_search(pkg: &str) { .unwrap(); match result.code() { Some(0) => { - inf(format!("Repo search successful")) + succ(format!("Repo search successful")) } Some(1) => { err_rec(format!("No matching repo packages found")) diff --git a/src/mods/strs.rs b/src/mods/strs.rs index bcc60a0..1352ced 100644 --- a/src/mods/strs.rs +++ b/src/mods/strs.rs @@ -3,6 +3,18 @@ use std::{process, env}; use uwuizer::*; 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))); + } else { + println!("{} {}", + Colour::Purple.paint("❖"), + Colour::White.paint(a)); + } +} + +pub fn sec(a: std::string::String){ if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { println!("{} {}", Colour::Purple.bold().paint("❖"), @@ -14,6 +26,19 @@ pub fn inf(a: std::string::String){ } } +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))); + } else { + println!("{} {}", + Colour::Green.bold().paint("✓"), + Colour::Green.paint(uwuize!(&a))); + } +} + + pub fn err_unrec(a: std::string::String) { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { println!("{} {} {}", @@ -30,8 +55,6 @@ pub fn err_unrec(a: std::string::String) { } } -// we havent actually used this one yet - pub fn err_rec(a: std::string::String) { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { println!("{} {}", diff --git a/src/mods/uninstall.rs b/src/mods/uninstall.rs index 448ed33..f9973fb 100644 --- a/src/mods/uninstall.rs +++ b/src/mods/uninstall.rs @@ -1,14 +1,14 @@ use runas::Command; -use crate::mods::strs::{inf, err_unrec}; +use crate::mods::strs::{err_unrec, sec, succ}; pub fn uninstall(noconfirm: bool, pkg: &str) { - inf(format!("Attempting to uninstall {}", pkg)); + sec(format!("Attempting to uninstall {}", pkg)); if noconfirm == true { let result = Command::new("pacman").arg("-Rs").arg(&pkg).arg("--noconfirm").status(); match result { Ok(_) => { - println!("") - } + succ(format!("Succesfully uninstalled {}", pkg)) + } Err(_) => { err_unrec(format!("Couldn't uninstall {}", pkg)) }}; @@ -16,7 +16,7 @@ pub fn uninstall(noconfirm: bool, pkg: &str) { let result = Command::new("pacman").arg("-Rs").arg(&pkg).status(); match result { Ok(_) => { - println!("") + succ(format!("Succesfully uninstalled {}", pkg)) } Err(_) => { err_unrec(format!("Couldn't uninstall {}", pkg)) diff --git a/src/mods/update.rs b/src/mods/update.rs index df77397..881a4dc 100644 --- a/src/mods/update.rs +++ b/src/mods/update.rs @@ -1,15 +1,15 @@ use runas::Command; -use crate::mods::strs::{inf, err_unrec}; +use crate::mods::strs::{err_unrec, sec, succ}; pub fn update() { - inf(format!("Syncing package repos")); + sec(format!("Syncing package repos")); let result = Command::new("pacman") .arg("-Sy") .status(); match result { Ok(_) => { - inf(format!("Repos succesfully synced")) + succ(format!("Repos succesfully synced")) } Err(_) => { err_unrec(format!("Couldn't sync package repos (how?)")) diff --git a/src/mods/upgrade.rs b/src/mods/upgrade.rs index 2767a44..7e22743 100644 --- a/src/mods/upgrade.rs +++ b/src/mods/upgrade.rs @@ -1,8 +1,9 @@ use runas::Command; use std::env; -use crate::mods::strs::{err_unrec, inf}; +use crate::mods::strs::{err_unrec, inf, sec, succ}; pub fn upgrade(noconfirm: bool, cachedir: &str){ + sec(format!("Performing system upgrade")); if noconfirm == true { let result = Command::new("pacman") .arg("-Syu") @@ -10,7 +11,7 @@ pub fn upgrade(noconfirm: bool, cachedir: &str){ .status(); match result { Ok(_) => { - inf(format!("All repo packages upgraded")) + succ(format!("All repo packages upgraded")) } Err(_) => { err_unrec(format!("Couldn't upgrade packages")) @@ -21,7 +22,7 @@ pub fn upgrade(noconfirm: bool, cachedir: &str){ .status(); match result { Ok(_) => { - inf(format!("All repo packages upgraded")) + succ(format!("All repo packages upgraded")) } Err(_) => { err_unrec(format!("Couldn't upgrade packages")) @@ -60,7 +61,7 @@ pub fn upgrade(noconfirm: bool, cachedir: &str){ let makepkg_result = std::process::Command::new("makepkg").arg("-si").status(); match makepkg_result { Ok(_) => { - inf(format!("New AUR package version installed")) + succ(format!("New AUR package version installed")) } Err(_) => { err_unrec(format!("Couldn't install new AUR package version"))