commit decf1f14e67053123023ba1fc5dd0434baf8180e Author: Tristan Smith Date: Thu Sep 12 00:43:44 2024 -0400 currently builds and searches the AUR diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef6c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..65671e3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "raur" +version = "0.1.0" +edition = "2021" + +[dependencies] +aur-rs = "0.1.1" +tokio = { version = "1", features = ["full"] } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..4a51bea --- /dev/null +++ b/src/main.rs @@ -0,0 +1,20 @@ +use std::env; + +mod search; + +#[tokio::main] +async fn main() { + // Collect command-line arguments + let args: Vec = env::args().collect(); + + // Check if the correct number of arguments is passed + if args.len() != 2 { + eprintln!("Usage: raur "); + return; + } + + let package_name = &args[1]; + + // Call the async search function and await it + search::search(package_name).await; +} diff --git a/src/search.rs b/src/search.rs new file mode 100644 index 0000000..7272554 --- /dev/null +++ b/src/search.rs @@ -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!(); + } +}