Minor refactor

Change cli to grab version from the Cargo manifest
Rename fetch_url to fetch_html
This commit is contained in:
Kenneth Gitere 2021-04-17 12:08:24 +03:00
parent 7e9dcfc2b7
commit 217cd3e442
3 changed files with 4 additions and 4 deletions

View file

@ -8,7 +8,7 @@ pub fn cli_init() -> AppConfig {
AppSettings::ArgRequiredElseHelp, AppSettings::ArgRequiredElseHelp,
AppSettings::UnifiedHelpMessage, AppSettings::UnifiedHelpMessage,
]) ])
.version("0.3.0-alpha1") .version(clap::crate_version!())
.about( .about(
" "
Paperoni is an article downloader. Paperoni is an article downloader.

View file

@ -7,7 +7,7 @@ use crate::{errors::ErrorKind, errors::PaperoniError, extractor::Extractor};
type HTMLResource = (String, String); type HTMLResource = (String, String);
pub async fn fetch_url(url: &str) -> Result<HTMLResource, PaperoniError> { pub async fn fetch_html(url: &str) -> Result<HTMLResource, PaperoniError> {
let client = surf::Client::new(); let client = surf::Client::new();
println!("Fetching..."); println!("Fetching...");

View file

@ -18,7 +18,7 @@ mod moz_readability;
use cli::AppConfig; use cli::AppConfig;
use epub::generate_epubs; use epub::generate_epubs;
use extractor::Extractor; use extractor::Extractor;
use http::{download_images, fetch_url}; use http::{download_images, fetch_html};
fn main() { fn main() {
let app_config = cli::cli_init(); let app_config = cli::cli_init();
@ -30,7 +30,7 @@ fn main() {
fn download(app_config: AppConfig) { fn download(app_config: AppConfig) {
let articles = task::block_on(async { 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 responses = stream::from_iter(urls_iter).buffered(app_config.max_conn());
let mut articles = Vec::new(); let mut articles = Vec::new();
while let Some(fetch_result) = responses.next().await { while let Some(fetch_result) = responses.next().await {