added verbosity parsing and debug messages

i18n
michal 2 years ago
parent 5b8aa7ff76
commit 4b2272009f

@ -2,8 +2,8 @@ pub mod rpc;
pub mod structs;
mod sort;
pub fn sort(a: &[String]) -> structs::Sorted {
sort::sort(a)
pub fn sort(a: &[String], verbosity: i32) -> structs::Sorted {
sort::sort(a, verbosity)
}

@ -1,15 +1,35 @@
use crate::internal::{structs, rpc};
pub fn sort(a: &[String]) -> structs::Sorted {
pub fn sort(a: &[String], verbosity: i32) -> structs::Sorted {
#[allow(unused_mut)]
let mut repo: Vec<String> = vec![];
let mut aur: Vec<String> = vec![];
let mut nf: Vec<String> = vec![];
match verbosity {
0 => {}
1 => {
eprintln!("Sorting:");
eprintln!("{:?}", a);
}
_ => {
eprintln!("Sorting:");
for b in a {
eprintln!("{:?}", b);
}
}
}
for b in a {
if rpc::rpcinfo(b.to_string()).found {
if verbosity >= 1 {
eprintln!("{} found in AUR.", b);
}
aur.push(b.to_string());
} else {
if verbosity >= 1 {
eprintln!("{} not found.", b);
}
nf.push(b.to_string());
}
}

@ -1,11 +1,11 @@
#[derive(Debug)]
pub struct Sorted {
#[allow(dead_code)]
repo: Vec<String>,
pub repo: Vec<String>,
#[allow(dead_code)]
aur: Vec<String>,
pub aur: Vec<String>,
#[allow(dead_code)]
nf: Vec<String>
pub nf: Vec<String>
}
impl Sorted {

@ -58,7 +58,7 @@ fn main() {
)
.get_matches();
let verbosity = matches.occurrences_of("verbose");
let verbosity: i32 = matches.occurrences_of("verbose") as i32;
let packages: Vec<String> = matches
.subcommand_matches("install")
@ -68,12 +68,7 @@ fn main() {
.into_iter().map(|s| s.to_string()).collect();
if let true = matches.is_present("install") {
println!(
"Installing: {}\nVerbosity: {}\n{:?}",
packages.join(", "),
verbosity,
sort(&packages)
);
operations::install(packages);
let sorted = sort(&packages, verbosity);
operations::install(sorted.repo, verbosity);
}
}

@ -1,3 +1,15 @@
pub fn install(a: Vec<String>) {
println!("{:?}", &a);
pub fn install(a: Vec<String>, verbosity: i32) {
match verbosity {
0 => {},
1 => {
eprintln!("Installing from repos:");
eprintln!("{:?}", &a);
}
_ => {
eprintln!("Installing from repos:");
for b in a {
eprintln!("{:?}", b);
}
}
}
}

@ -2,6 +2,6 @@ mod install;
mod uninstall;
mod query;
pub fn install(a: Vec<String>) {
install::install(a);
pub fn install(a: Vec<String>, verbosity: i32) {
install::install(a, verbosity);
}
Loading…
Cancel
Save