made ame a bit not stupid string-wise

i18n
jnats 3 years ago
parent 3e9a560238
commit b90f237d2b

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

@ -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 {

@ -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));
}};
}

@ -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<String>) {
@ -26,7 +26,7 @@ pub fn inssort(noconfirm: bool, pkgs: Vec<String>) {
}}}
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<String>) {
}
for a in aur {
inf(format!("Installing AUR package: {}", a));
sec(format!("Installing AUR package: {}", a));
if noconfirm == true {
clone(true, &a);
} else {

@ -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))
}};
}

@ -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"))

@ -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!("{} {}",

@ -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))

@ -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?)"))

@ -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"))

Loading…
Cancel
Save