made ame a bit not stupid string-wise

i18n
jnats 3 years ago
parent 3e9a560238
commit b90f237d2b

@ -1,6 +1,6 @@
[package] [package]
name = "ame" name = "ame"
version = "2.2.0" version = "2.2.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."

@ -40,7 +40,6 @@ fn main() {
// upgrade // upgrade
} else if oper == "-Syu" || oper == "-Syun" || oper == "upg" { } else if oper == "-Syu" || oper == "-Syun" || oper == "upg" {
inf(format!("Performing system upgrade"));
if oper == ("-Syun") { if oper == ("-Syun") {
upgrade(true, &cache_path); upgrade(true, &cache_path);
} else { } else {

@ -1,6 +1,6 @@
use git2::Repository; use git2::Repository;
use std::{env, fs, path::Path, process::Command}; 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) { pub fn clone(noconfirm: bool, pkg: &str) {
let cachedir = format!("{}/.cache/ame", std::env::var("HOME").unwrap()); 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")) 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(); let depends = raur::info(&[&aurpkgname]).unwrap()[0].depends.clone();
if noconfirm == true { if noconfirm == true {
inssort(true, depends); inssort(true, depends);
@ -67,28 +71,32 @@ pub fn clone(noconfirm: bool, pkg: &str) {
Repository::clone(&url, Path::new(&pkgdir)).unwrap(); Repository::clone(&url, Path::new(&pkgdir)).unwrap();
if noconfirm == true { if noconfirm == true {
inf(format!("Installing {} ...", pkg)); sec(format!("Installing {} ...", pkg));
let install_result = Command::new("makepkg") let install_result = Command::new("makepkg")
.arg("-si") .arg("-si")
.arg("--noconfirm") .arg("--noconfirm")
.status(); .status();
match install_result { match install_result {
Ok(_) => { Ok(_) => {
inf(format!("Succesfully installed {}", pkg)); succ(format!("Succesfully installed {}", pkg));
} }
Err(_) => { Err(_) => {
err_unrec(format!("Couldn't install {}", pkg)); err_unrec(format!("Couldn't install {}", pkg));
}}; }};
} else { } else {
inf(format!("Installing {} ...", pkg)); sec(format!("Installing {} ...", pkg));
let install_result = Command::new("makepkg") let install_result = Command::new("makepkg")
.arg("-si") .arg("-si")
.status(); .status()
match install_result { .expect("Couldn't call makepkg");
Ok(_) => { match install_result.code() {
inf(format!("Succesfully installed {}", pkg)); Some(0) => {
succ(format!("Succesfully installed {}", pkg));
} }
Err(_) => { Some(_) => {
err_unrec(format!("Couldn't install {}", pkg));
}
None => {
err_unrec(format!("Couldn't install {}", pkg)); err_unrec(format!("Couldn't install {}", pkg));
}}; }};
} }

@ -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}; use std::process::{Stdio, Command};
pub fn inssort(noconfirm: bool, pkgs: Vec<String>) { pub fn inssort(noconfirm: bool, pkgs: Vec<String>) {
@ -26,7 +26,7 @@ pub fn inssort(noconfirm: bool, pkgs: Vec<String>) {
}}} }}}
if repo.len() != 0 { if repo.len() != 0 {
inf(format!("Installing repo packages: {}", &repo.join(", "))); sec(format!("Installing repo packages: {}", &repo.join(", ")));
if noconfirm == true { if noconfirm == true {
install(true, &repo.join(" ")); install(true, &repo.join(" "));
} else { } else {
@ -35,7 +35,7 @@ pub fn inssort(noconfirm: bool, pkgs: Vec<String>) {
} }
for a in aur { for a in aur {
inf(format!("Installing AUR package: {}", a)); sec(format!("Installing AUR package: {}", a));
if noconfirm == true { if noconfirm == true {
clone(true, &a); clone(true, &a);
} else { } else {

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

@ -1,6 +1,6 @@
use std::{ops::Deref, process::Command}; use std::{ops::Deref, process::Command};
use ansi_term::Colour; 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) { pub fn a_search(pkg: &str) {
let results = raur::search(&pkg); let results = raur::search(&pkg);
@ -27,7 +27,7 @@ pub fn r_search(pkg: &str) {
.unwrap(); .unwrap();
match result.code() { match result.code() {
Some(0) => { Some(0) => {
inf(format!("Repo search successful")) succ(format!("Repo search successful"))
} }
Some(1) => { Some(1) => {
err_rec(format!("No matching repo packages found")) err_rec(format!("No matching repo packages found"))

@ -3,6 +3,18 @@ use std::{process, env};
use uwuizer::*; 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)));
} 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" { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!("{} {}", println!("{} {}",
Colour::Purple.bold().paint("❖"), 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) { pub fn err_unrec(a: std::string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!("{} {} {}", 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) { pub fn err_rec(a: std::string::String) {
if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" {
println!("{} {}", println!("{} {}",

@ -1,14 +1,14 @@
use runas::Command; 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) { pub fn uninstall(noconfirm: bool, pkg: &str) {
inf(format!("Attempting to uninstall {}", pkg)); sec(format!("Attempting to uninstall {}", pkg));
if noconfirm == true { if noconfirm == true {
let result = Command::new("pacman").arg("-Rs").arg(&pkg).arg("--noconfirm").status(); let result = Command::new("pacman").arg("-Rs").arg(&pkg).arg("--noconfirm").status();
match result { match result {
Ok(_) => { Ok(_) => {
println!("") succ(format!("Succesfully uninstalled {}", pkg))
} }
Err(_) => { Err(_) => {
err_unrec(format!("Couldn't uninstall {}", pkg)) 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(); let result = Command::new("pacman").arg("-Rs").arg(&pkg).status();
match result { match result {
Ok(_) => { Ok(_) => {
println!("") succ(format!("Succesfully uninstalled {}", pkg))
} }
Err(_) => { Err(_) => {
err_unrec(format!("Couldn't uninstall {}", pkg)) err_unrec(format!("Couldn't uninstall {}", pkg))

@ -1,15 +1,15 @@
use runas::Command; use runas::Command;
use crate::mods::strs::{inf, err_unrec}; use crate::mods::strs::{err_unrec, sec, succ};
pub fn update() { pub fn update() {
inf(format!("Syncing package repos")); sec(format!("Syncing package repos"));
let result = Command::new("pacman") let result = Command::new("pacman")
.arg("-Sy") .arg("-Sy")
.status(); .status();
match result { match result {
Ok(_) => { Ok(_) => {
inf(format!("Repos succesfully synced")) succ(format!("Repos succesfully synced"))
} }
Err(_) => { Err(_) => {
err_unrec(format!("Couldn't sync package repos (how?)")) err_unrec(format!("Couldn't sync package repos (how?)"))

@ -1,8 +1,9 @@
use runas::Command; use runas::Command;
use std::env; 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){ pub fn upgrade(noconfirm: bool, cachedir: &str){
sec(format!("Performing system upgrade"));
if noconfirm == true { if noconfirm == true {
let result = Command::new("pacman") let result = Command::new("pacman")
.arg("-Syu") .arg("-Syu")
@ -10,7 +11,7 @@ pub fn upgrade(noconfirm: bool, cachedir: &str){
.status(); .status();
match result { match result {
Ok(_) => { Ok(_) => {
inf(format!("All repo packages upgraded")) succ(format!("All repo packages upgraded"))
} }
Err(_) => { Err(_) => {
err_unrec(format!("Couldn't upgrade packages")) err_unrec(format!("Couldn't upgrade packages"))
@ -21,7 +22,7 @@ pub fn upgrade(noconfirm: bool, cachedir: &str){
.status(); .status();
match result { match result {
Ok(_) => { Ok(_) => {
inf(format!("All repo packages upgraded")) succ(format!("All repo packages upgraded"))
} }
Err(_) => { Err(_) => {
err_unrec(format!("Couldn't upgrade packages")) 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(); let makepkg_result = std::process::Command::new("makepkg").arg("-si").status();
match makepkg_result { match makepkg_result {
Ok(_) => { Ok(_) => {
inf(format!("New AUR package version installed")) succ(format!("New AUR package version installed"))
} }
Err(_) => { Err(_) => {
err_unrec(format!("Couldn't install new AUR package version")) err_unrec(format!("Couldn't install new AUR package version"))

Loading…
Cancel
Save