From a4e31998e06b2e8a4c62c964bd680cc62ab0182e Mon Sep 17 00:00:00 2001 From: Bauke Date: Wed, 21 Sep 2022 22:52:16 +0200 Subject: [PATCH] Add a FeedOption enum to differentiate the CLI input options. --- source/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/main.rs b/source/main.rs index 23c9824..3d7a3bc 100644 --- a/source/main.rs +++ b/source/main.rs @@ -39,6 +39,9 @@ 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, @@ -46,6 +49,13 @@ pub struct Feed { pub url: String, } +/// An enum for [`Feed`]s for which option was used in the CLI. +#[derive(Debug, PartialEq)] +pub enum FeedOption { + /// `-a, --appid ` was used. + AppID, +} + fn main() -> Result<()> { install()?; @@ -60,6 +70,7 @@ fn main() -> Result<()> { for appid in args.appid { potential_feeds.push(Feed { + option: FeedOption::AppID, text: Some(format!("Steam AppID {appid}")), url: format!("https://steamcommunity.com/games/{appid}/rss/"), }); @@ -77,7 +88,7 @@ fn main() -> Result<()> { let title_end = body.find("").unwrap(); feeds_to_output.push(Feed { text: Some(body[title_start..title_end].to_string()), - url: potential_feed.url, + ..potential_feed }); }