From 217cd3e44299841afaf62228e5bdd1ca1aadc524 Mon Sep 17 00:00:00 2001 From: Kenneth Gitere Date: Sat, 17 Apr 2021 12:08:24 +0300 Subject: [PATCH] Minor refactor Change cli to grab version from the Cargo manifest Rename fetch_url to fetch_html --- src/cli.rs | 2 +- src/http.rs | 2 +- src/main.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 9815e08..a8701bc 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -8,7 +8,7 @@ pub fn cli_init() -> AppConfig { AppSettings::ArgRequiredElseHelp, AppSettings::UnifiedHelpMessage, ]) - .version("0.3.0-alpha1") + .version(clap::crate_version!()) .about( " Paperoni is an article downloader. diff --git a/src/http.rs b/src/http.rs index 9ff7ef8..9ddf192 100644 --- a/src/http.rs +++ b/src/http.rs @@ -7,7 +7,7 @@ use crate::{errors::ErrorKind, errors::PaperoniError, extractor::Extractor}; type HTMLResource = (String, String); -pub async fn fetch_url(url: &str) -> Result { +pub async fn fetch_html(url: &str) -> Result { let client = surf::Client::new(); println!("Fetching..."); diff --git a/src/main.rs b/src/main.rs index 7ad2560..8936713 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ mod moz_readability; use cli::AppConfig; use epub::generate_epubs; use extractor::Extractor; -use http::{download_images, fetch_url}; +use http::{download_images, fetch_html}; fn main() { let app_config = cli::cli_init(); @@ -30,7 +30,7 @@ fn main() { fn download(app_config: AppConfig) { let articles = task::block_on(async { - let urls_iter = app_config.urls().iter().map(|url| fetch_url(url)); + let urls_iter = app_config.urls().iter().map(|url| fetch_html(url)); let mut responses = stream::from_iter(urls_iter).buffered(app_config.max_conn()); let mut articles = Vec::new(); while let Some(fetch_result) = responses.next().await {