diff --git a/src/internal/mod.rs b/src/internal/mod.rs index 984ebd0..4343937 100644 --- a/src/internal/mod.rs +++ b/src/internal/mod.rs @@ -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) } diff --git a/src/internal/sort.rs b/src/internal/sort.rs index 3000f7f..9fc69db 100644 --- a/src/internal/sort.rs +++ b/src/internal/sort.rs @@ -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 = vec![]; let mut aur: Vec = vec![]; let mut nf: Vec = 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()); } } diff --git a/src/internal/structs.rs b/src/internal/structs.rs index 5b2fccd..78ff67b 100644 --- a/src/internal/structs.rs +++ b/src/internal/structs.rs @@ -1,11 +1,11 @@ #[derive(Debug)] pub struct Sorted { #[allow(dead_code)] - repo: Vec, + pub repo: Vec, #[allow(dead_code)] - aur: Vec, + pub aur: Vec, #[allow(dead_code)] - nf: Vec + pub nf: Vec } impl Sorted { diff --git a/src/main.rs b/src/main.rs index 6c3dfd5..2b5b539 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 = 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); } } diff --git a/src/operations/install.rs b/src/operations/install.rs index dcc1ce4..b69dd38 100644 --- a/src/operations/install.rs +++ b/src/operations/install.rs @@ -1,3 +1,15 @@ -pub fn install(a: Vec) { - println!("{:?}", &a); +pub fn install(a: Vec, verbosity: i32) { + match verbosity { + 0 => {}, + 1 => { + eprintln!("Installing from repos:"); + eprintln!("{:?}", &a); + } + _ => { + eprintln!("Installing from repos:"); + for b in a { + eprintln!("{:?}", b); + } + } + } } \ No newline at end of file diff --git a/src/operations/mod.rs b/src/operations/mod.rs index 7d75b7b..89dda79 100644 --- a/src/operations/mod.rs +++ b/src/operations/mod.rs @@ -2,6 +2,6 @@ mod install; mod uninstall; mod query; -pub fn install(a: Vec) { - install::install(a); +pub fn install(a: Vec, verbosity: i32) { + install::install(a, verbosity); } \ No newline at end of file