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

47 lines
1.2 KiB
Rust

use crate::internal::commands::ShellCommand;
use crate::internal::error::SilentUnwrap;
use crate::internal::exit_code::AppExitCode;
use crate::internal::rpc::rpcsearch;
use crate::{log, Options};
3 years ago
pub fn aur_search(query: &str, options: Options) {
3 years ago
let verbosity = options.verbosity;
let res = rpcsearch(query.to_string());
3 years ago
for package in &res.results {
3 years ago
println!(
"aur/{} {}\n {}",
package.name,
package.version,
package
.description
3 years ago
.as_ref()
.unwrap_or(&"No description".to_string())
3 years ago
)
}
if verbosity >= 1 {
log!("Found {} resuls for \"{}\" in AUR", res.resultcount, query);
}
3 years ago
}
pub fn repo_search(query: &str, options: Options) {
3 years ago
let verbosity = options.verbosity;
let output = ShellCommand::pacman()
.arg("-Ss")
.arg(query)
.wait_with_output()
.silent_unwrap(AppExitCode::PacmanError)
.stdout;
3 years ago
if verbosity >= 1 {
log!(
"Found {} results for \"{}\" in repos",
&output.split('\n').count() / 2,
&query
);
3 years ago
}
println!("{}", output)
3 years ago
}