From a54a02a5fbaa73bc075f2a5f4c578c4aa3c4f209 Mon Sep 17 00:00:00 2001 From: TuDatTr Date: Sat, 29 Jul 2023 16:06:36 +0200 Subject: [PATCH] Added search query in output Signed-off-by: TuDatTr --- Cargo.toml | 2 +- src/main.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6ddb219..87c0b6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gsearch" -version = "0.1.0" +version = "0.2.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index 8fdb26c..e520d60 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use gscite::{Client, ReferenceFormat}; use futures_util::StreamExt; use futures_util::TryStreamExt; +use std::error::Error; use clap::Parser; @@ -13,14 +14,15 @@ pub struct Cli { } #[tokio::main] -async fn main() { +async fn main() -> Result<(), Box> { let args = Cli::parse(); let client = Client::default(); - let results = client.get_references(&args.search_term, ReferenceFormat::BibTeX).await.unwrap(); - let references = results.take(1).try_collect::>().await.unwrap(); + let results = client.get_references(&args.search_term, ReferenceFormat::BibTeX).await?; + let references = results.take(1).try_collect::>().await?; for r in references { - println!("{}", r); + println!("Url: https://scholar.google.com/scholar?q={}\n\nReference: \n{}", &args.search_term, r); } + Ok(()) }