Make info fail if you pass empty arguments

This commit is contained in:
blank X 2020-12-28 01:49:50 +07:00
parent 9e43a5818d
commit 0d84c57106
3 changed files with 5 additions and 5 deletions

2
Cargo.lock generated
View File

@ -421,7 +421,7 @@ dependencies = [
[[package]]
name = "nhentairs"
version = "0.5.1"
version = "0.5.2"
dependencies = [
"reqwest",
"serde",

View File

@ -1,6 +1,6 @@
[package]
name = "nhentairs"
version = "0.5.1"
version = "0.5.2"
authors = ["blank X <theblankx@protonmail.com>"]
edition = "2018"

View File

@ -9,12 +9,12 @@ pub async fn run(args: env::Args) {
for arg in args {
query.push_str(&format!(" {}", arg));
}
if query.len() < 1 {
let query = query.trim();
if query.is_empty() {
eprintln!("Missing search query");
exit(1);
}
let client = reqwest::Client::new();
let search_info = utils::get_search_info(client.clone(), &query[1..]).await.unwrap();
let search_info = utils::get_search_info(reqwest::Client::new(), &query).await.unwrap();
if search_info.num_pages < 1 {
eprintln!("No results found");
exit(1);