From 63acd248ec13225a50195c46a98052f80ecd713a Mon Sep 17 00:00:00 2001 From: theBreadCompany Date: Mon, 18 Nov 2024 09:56:55 +0100 Subject: [PATCH] add help switch --- src/main.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0344dce..2c86ccf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ async fn main() { write_all().await; } "--help" => { - panic!("not implemented"); + print_help(); } _ => { panic!("bad command {}", cmd); @@ -53,6 +53,20 @@ async fn main() { } } +fn print_help() { + println!( + r" + Usage: sfwikiscraper + + --help: display this help + --all: fetch all recipes + --tier : fetches all recipes of the nth tier + --item : fetches the recipe (only by url for now) + --test : parse the json format shipped in + " + ); +} + async fn fetch_data(url: String) -> Vec { let webdata = reqwest::get(url) .await @@ -150,11 +164,14 @@ async fn write_all() { &join_all( (0..9) .into_iter() - .map(|i| async move { fetch_tier(i.to_string()).await }) + .map(|i| async move { fetch_tier(i.to_string()).await }), ) .await .into_iter() - .reduce(|mut acc, e| { acc.extend(e.iter().cloned()); acc }) + .reduce(|mut acc, e| { + acc.extend(e.iter().cloned()); + acc + }), ) .unwrap() .as_bytes(),