1
Fork 0

Add a FeedOption enum to differentiate the CLI input options.

This commit is contained in:
Bauke 2022-09-21 22:52:16 +02:00
parent f52d89ad24
commit a4e31998e0
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 12 additions and 1 deletions

View File

@ -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<String>,
@ -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 <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("</title>").unwrap();
feeds_to_output.push(Feed {
text: Some(body[title_start..title_end].to_string()),
url: potential_feed.url,
..potential_feed
});
}