use rocksky::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let query = std::env::args()
.skip(1)
.collect::<Vec<_>>()
.join(" ");
if query.is_empty() {
eprintln!("usage: search <query>");
std::process::exit(1);
}
let client = Client::new();
let results = client.feed().search(&query).await?;
if let Some(total) = results.estimated_total_hits {
eprintln!(
"~{total} hit(s) in {} ms",
results.processing_time_ms.unwrap_or_default()
);
}
for hit in results.hits {
println!("{}", serde_json::to_string(&hit)?);
}
Ok(())
}