Added search query in output

Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
This commit is contained in:
TuDatTr 2023-07-29 16:06:36 +02:00
parent b19d1afe6d
commit a54a02a5fb
2 changed files with 7 additions and 5 deletions

View File

@ -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

View File

@ -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<dyn Error>> {
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::<Vec<_>>().await.unwrap();
let results = client.get_references(&args.search_term, ReferenceFormat::BibTeX).await?;
let references = results.take(1).try_collect::<Vec<_>>().await?;
for r in references {
println!("{}", r);
println!("Url: https://scholar.google.com/scholar?q={}\n\nReference: \n{}", &args.search_term, r);
}
Ok(())
}