Add a FeedOption enum to differentiate the CLI input options.
This commit is contained in:
parent
f52d89ad24
commit
a4e31998e0
|
@ -39,6 +39,9 @@ pub struct Args {
|
||||||
/// A simple feed struct.
|
/// A simple feed struct.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Feed {
|
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.
|
/// The text to use for the feed in the OPML output.
|
||||||
pub text: Option<String>,
|
pub text: Option<String>,
|
||||||
|
|
||||||
|
@ -46,6 +49,13 @@ pub struct Feed {
|
||||||
pub url: String,
|
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<()> {
|
fn main() -> Result<()> {
|
||||||
install()?;
|
install()?;
|
||||||
|
|
||||||
|
@ -60,6 +70,7 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
for appid in args.appid {
|
for appid in args.appid {
|
||||||
potential_feeds.push(Feed {
|
potential_feeds.push(Feed {
|
||||||
|
option: FeedOption::AppID,
|
||||||
text: Some(format!("Steam AppID {appid}")),
|
text: Some(format!("Steam AppID {appid}")),
|
||||||
url: format!("https://steamcommunity.com/games/{appid}/rss/"),
|
url: format!("https://steamcommunity.com/games/{appid}/rss/"),
|
||||||
});
|
});
|
||||||
|
@ -77,7 +88,7 @@ fn main() -> Result<()> {
|
||||||
let title_end = body.find("</title>").unwrap();
|
let title_end = body.find("</title>").unwrap();
|
||||||
feeds_to_output.push(Feed {
|
feeds_to_output.push(Feed {
|
||||||
text: Some(body[title_start..title_end].to_string()),
|
text: Some(body[title_start..title_end].to_string()),
|
||||||
url: potential_feed.url,
|
..potential_feed
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue