main.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // main.rs
  3. // Copyright (C) 2018 Paul Schaefer <schaefer.pp@gmail.com>
  4. // Distributed under terms of the LGPL-3.0+ license.
  5. //
  6. extern crate clap;
  7. extern crate paurl;
  8. use clap::{App, Arg, SubCommand};
  9. pub fn main() {
  10. let matches: clap::ArgMatches = App::new("Paurl -- Paul's AUR Library")
  11. .version("0.1")
  12. .author("Paul Schaefer -- schaeferpp")
  13. .about("Yet another (cool!) aur wrapper")
  14. .subcommand(
  15. SubCommand::with_name("search")
  16. .about("Search a package in the local database")
  17. .version("0.1")
  18. .arg(Arg::with_name("query")),
  19. )
  20. .get_matches();
  21. let ctxt = paurl::alpm::Context::new().unwrap();
  22. if let Some(matches) = matches.subcommand_matches("search") {
  23. let matches: &clap::ArgMatches = matches;
  24. let querystring = matches
  25. .value_of("query")
  26. .expect("Please specify a query string!");
  27. for pkg in paurl::search(querystring).unwrap() {
  28. match pkg {
  29. paurl::Package::AUR(pkg) => {
  30. println!("aur/{}", pkg.name);
  31. println!(" {}", pkg.description.unwrap_or_default());
  32. },
  33. paurl::Package::ALPM(pkg) => {
  34. println!("{}/{}", pkg.repo, pkg.name);
  35. println!(" {}", pkg.description);
  36. // println!(" ", pkg.get_description());
  37. },
  38. }
  39. }
  40. }
  41. }