Remove FeedOption, this won't be necessary after all.
This commit is contained in:
parent
f49e12db37
commit
e543f0aac0
|
@ -44,9 +44,6 @@ 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>,
|
||||||
|
|
||||||
|
@ -54,16 +51,6 @@ pub struct Feed {
|
||||||
pub url: String,
|
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 <APPID>` was used.
|
|
||||||
AppID,
|
|
||||||
|
|
||||||
/// `--url <URL>` was used.
|
|
||||||
Url,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
install()?;
|
install()?;
|
||||||
|
|
||||||
|
@ -81,7 +68,6 @@ 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: appid_to_rss_url(appid),
|
url: appid_to_rss_url(appid),
|
||||||
});
|
});
|
||||||
|
@ -94,7 +80,6 @@ fn main() -> Result<()> {
|
||||||
.and_then(|appid_match| appid_match.as_str().parse::<usize>().ok());
|
.and_then(|appid_match| appid_match.as_str().parse::<usize>().ok());
|
||||||
if let Some(appid) = appid {
|
if let Some(appid) = appid {
|
||||||
potential_feeds.push(Feed {
|
potential_feeds.push(Feed {
|
||||||
option: FeedOption::Url,
|
|
||||||
text: Some(format!("Steam AppID {appid}")),
|
text: Some(format!("Steam AppID {appid}")),
|
||||||
url: appid_to_rss_url(appid),
|
url: appid_to_rss_url(appid),
|
||||||
});
|
});
|
||||||
|
@ -106,12 +91,9 @@ fn main() -> Result<()> {
|
||||||
.with_style(ProgressStyle::with_template("Verifying {pos}/{len} {bar}")?);
|
.with_style(ProgressStyle::with_template("Verifying {pos}/{len} {bar}")?);
|
||||||
|
|
||||||
for potential_feed in potential_feeds {
|
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()?;
|
let response = ureq_agent.get(&potential_feed.url).call()?;
|
||||||
sleep(timeout);
|
sleep(timeout);
|
||||||
if response.content_type() == "text/xml" {
|
let potential_feed = if response.content_type() == "text/xml" {
|
||||||
let body = response.into_string()?;
|
let body = response.into_string()?;
|
||||||
let title_start = body.find("<title>").unwrap() + 7;
|
let title_start = body.find("<title>").unwrap() + 7;
|
||||||
let title_end = body.find("</title>").unwrap();
|
let title_end = body.find("</title>").unwrap();
|
||||||
|
@ -121,9 +103,6 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
feeds_to_output.push(potential_feed);
|
feeds_to_output.push(potential_feed);
|
||||||
|
|
Loading…
Reference in New Issue