You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
amethyst/src/operations/search.rs

49 lines
1.1 KiB
Rust

use std::process::Command;
use crate::internal::rpc::rpcsearch;
3 years ago
use crate::{log, Options};
3 years ago
pub fn aur_search(a: &str, options: Options) {
let verbosity = options.verbosity;
let res = rpcsearch(a.to_string());
if verbosity >= 1 {
log(format!(
"Found {} resuls for \"{}\" in AUR",
res.resultcount, a
));
3 years ago
}
for r in &res.results {
println!(
"aur/{} {}\n {}",
r.name,
r.version,
r.description
.as_ref()
.unwrap_or(&"No description".to_string())
3 years ago
)
}
}
pub fn repo_search(a: &str, options: Options) {
let verbosity = options.verbosity;
let rs = Command::new("pacman")
.arg("-Ss")
3 years ago
.arg(&a)
3 years ago
.output()
.expect("Something has gone wrong");
3 years ago
let str = String::from_utf8(rs.stdout).unwrap();
if verbosity >= 1 {
log(format!(
"Found {} results for \"{}\" in repos",
3 years ago
&str.split('\n').count() / 2,
&a
));
3 years ago
}
print!("{}", str);
}