From 5309d4347a2b5dad61314d7fd5b74d77e89316bf Mon Sep 17 00:00:00 2001 From: jnats Date: Sat, 2 Oct 2021 21:08:42 +0100 Subject: [PATCH] fixed up user readability --- Cargo.toml | 1 - src/mods/clone.rs | 11 ++--------- src/mods/help.rs | 2 +- src/mods/strs.rs | 19 +++++++++++-------- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d0fe7e5..29d02bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,5 +13,4 @@ raur = "2.0.2" runas = "*" ansi_term = "*" uwuizer = "*" -text_io = "*" moins = "*" diff --git a/src/mods/clone.rs b/src/mods/clone.rs index 4d6f3b9..845b9e0 100644 --- a/src/mods/clone.rs +++ b/src/mods/clone.rs @@ -4,15 +4,11 @@ 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, pkg: &str) { - let aurpkgname = results[0].name.to_string(); // v here + 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)); - for make_depend in &make_depends { - print!("{} ", make_depend); - } - println!(""); + 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); @@ -26,7 +22,6 @@ pub fn clone(noconfirm: bool, pkg: &str) { let path = Path::new(&cachedir); let pkgdir = format!("{}/{}", &cachedir, &pkg); let results = raur::search(&pkg).unwrap(); - let mut succ_install: bool = false; if results.len() == 0 { err_unrec(format!("No matching AUR packages found")); @@ -110,8 +105,6 @@ pub fn clone(noconfirm: bool, pkg: &str) { .status(); match install_result { Ok(_) => { - //succ(format!("Succesfully installed {}", pkg)); - //succ_install = true; uninstall_make_depend(results, pkg); } Err(_) => { diff --git a/src/mods/help.rs b/src/mods/help.rs index b43021a..6ff637f 100644 --- a/src/mods/help.rs +++ b/src/mods/help.rs @@ -14,7 +14,7 @@ ame -v / ver - contributors and version info ame - 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.")); + 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!(""); } diff --git a/src/mods/strs.rs b/src/mods/strs.rs index 036efde..266f650 100644 --- a/src/mods/strs.rs +++ b/src/mods/strs.rs @@ -1,7 +1,6 @@ use ansi_term::Colour; -use std::{process, env}; +use std::{process, env, io, io::Write}; use uwuizer::*; -use text_io::read; pub fn inf(a: std::string::String){ if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { @@ -41,23 +40,27 @@ pub fn succ(a: std::string::String) { pub fn prompt(a: std::string::String) -> bool { if env::var("AME_UWU").unwrap_or("n/a".to_string()) == "YES" { - println!("{} {} {}", + print!("{} {} {}", Colour::Purple.bold().paint("❖"), Colour::White.bold().paint(uwuize!(&a)), Colour::White.bold().paint("(Y/n): ")); - let yn: String = read!(); - if yn == "n" || yn == "N" || yn == "no" || yn == "No" { + io::stdout().flush().ok().expect("Couldn't flush stdout"); + let mut yn: String = String::new(); + let _ = std::io::stdin().read_line(&mut yn); + if yn.trim() == "n" || yn.trim() == "N" || yn.trim() == "no" || yn.trim() == "No" { false } else { true } } else { - println!("{} {} {}", + print!("{} {} {}", Colour::Purple.bold().paint("❖"), Colour::White.bold().paint(&a), Colour::White.bold().paint("(Y/n): ")); - let yn: String = read!(); - if yn == "n" || yn == "N" || yn == "no" || yn == "No" { + io::stdout().flush().ok().expect("Couldn't flush stdout"); + let mut yn: String = String::new(); + let _ = std::io::stdin().read_line(&mut yn); + if yn.trim() == "n" || yn.trim() == "N" || yn.trim() == "no" || yn.trim() == "No" { false } else { true