currently builds and searches the AUR
This commit is contained in:
commit
decf1f14e6
4 changed files with 61 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/target
|
||||||
|
Cargo.lock
|
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "raur"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
aur-rs = "0.1.1"
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
20
src/main.rs
Normal file
20
src/main.rs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
mod search;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
// Collect command-line arguments
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
|
// Check if the correct number of arguments is passed
|
||||||
|
if args.len() != 2 {
|
||||||
|
eprintln!("Usage: raur <package name>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let package_name = &args[1];
|
||||||
|
|
||||||
|
// Call the async search function and await it
|
||||||
|
search::search(package_name).await;
|
||||||
|
}
|
31
src/search.rs
Normal file
31
src/search.rs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
use aur_rs::{Request, ReturnData};
|
||||||
|
|
||||||
|
pub async fn search(package_name: &str) {
|
||||||
|
println!("Searching for package: {}\n", package_name);
|
||||||
|
|
||||||
|
search_package_by_name(package_name).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn search_package_by_name(package_name: &str) {
|
||||||
|
let request = Request::default();
|
||||||
|
let response: ReturnData = request
|
||||||
|
.search_package_by_name(package_name)
|
||||||
|
.await
|
||||||
|
.expect("Failed to search package");
|
||||||
|
|
||||||
|
if response.results.is_empty() {
|
||||||
|
eprintln!("No results found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for package in &response.results {
|
||||||
|
println!("Package name: {}", package.name);
|
||||||
|
|
||||||
|
// Print the package description if it exists
|
||||||
|
if let Some(description) = &package.description {
|
||||||
|
println!("Description: {}", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue