From e543f0aac07c8b35ec5e1392503d8583027b3056 Mon Sep 17 00:00:00 2001 From: Bauke Date: Thu, 22 Sep 2022 15:52:41 +0200 Subject: [PATCH] Remove FeedOption, this won't be necessary after all. --- source/main.rs | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/source/main.rs b/source/main.rs index 2d93826..81c39e2 100644 --- a/source/main.rs +++ b/source/main.rs @@ -44,9 +44,6 @@ pub struct Args { /// A simple feed struct. #[derive(Debug)] pub struct Feed { - /// The CLI option that was used for this feed. - pub option: FeedOption, - /// The text to use for the feed in the OPML output. pub text: Option, @@ -54,16 +51,6 @@ pub struct Feed { pub url: String, } -/// An enum for [`Feed`]s for which option was used in the CLI. -#[derive(Debug, Eq, PartialEq)] -pub enum FeedOption { - /// `-a, --appid ` was used. - AppID, - - /// `--url ` was used. - Url, -} - fn main() -> Result<()> { install()?; @@ -81,7 +68,6 @@ fn main() -> Result<()> { for appid in args.appid { potential_feeds.push(Feed { - option: FeedOption::AppID, text: Some(format!("Steam AppID {appid}")), url: appid_to_rss_url(appid), }); @@ -94,7 +80,6 @@ fn main() -> Result<()> { .and_then(|appid_match| appid_match.as_str().parse::().ok()); if let Some(appid) = appid { potential_feeds.push(Feed { - option: FeedOption::Url, text: Some(format!("Steam AppID {appid}")), url: appid_to_rss_url(appid), }); @@ -106,21 +91,15 @@ fn main() -> Result<()> { .with_style(ProgressStyle::with_template("Verifying {pos}/{len} {bar}")?); for potential_feed in potential_feeds { - let potential_feed = if [FeedOption::AppID, FeedOption::Url] - .contains(&potential_feed.option) - { - let response = ureq_agent.get(&potential_feed.url).call()?; - sleep(timeout); - if response.content_type() == "text/xml" { - let body = response.into_string()?; - let title_start = body.find("").unwrap() + 7; - let title_end = body.find("").unwrap(); - Feed { - text: Some(body[title_start..title_end].to_string()), - ..potential_feed - } - } else { - continue; + let response = ureq_agent.get(&potential_feed.url).call()?; + sleep(timeout); + let potential_feed = if response.content_type() == "text/xml" { + let body = response.into_string()?; + let title_start = body.find("").unwrap() + 7; + let title_end = body.find("").unwrap(); + Feed { + text: Some(body[title_start..title_end].to_string()), + ..potential_feed } } else { continue;