aur-rs 0.1.1

Library for interacting with the Arch User Repository's RPC interface
Documentation
// Just a basic example of a simple application that finds a package via
// search_package_name() and then prints the package's name and description.
// This takes one argument which is the name of the package to search for.

use aur_rs::{Request, ReturnData};
use std::env;

#[tokio::main]
async fn main() {
    let args: Vec<String> = env::args().collect();

    if args.len() != 2 {
        panic!("Usage: pkg_find <package name>");
    }

    println!("Searching for package: {}", args[1]);

    let request = Request::default();
    let response: ReturnData = request
        .search_package_by_name(args[1].as_str())
        .await
        .expect("Failed to search package name");

    if response.results.is_empty() {
        panic!("No results found");
    }

    for package in &response.results {
        println!("Package name: {}", package.name);

        // print package.description if it exists
        if let Some(description) = &package.description {
            println!("Package description: {}", description);
        }

        println!();
    }
}