mod rss; mod input; mod download; use std::fs; use anyhow::Context; fn main() -> anyhow::Result<()> { let args = { use clap::Parser; input::Args::parse() }; let config : input::Config = { let config = fs::read_to_string(&args.config) .context("failed to read in podcast configuration file")?; toml::from_str(&config[..])? }; let config_path = args.config.canonicalize()?; let Some(root) = config_path.parent() else { anyhow::bail!("could not get parent of configuration path for root directory") }; // Updating single podcast if let Some(alias) = args.podcast { if let Some(feed_url) = config.podcasts.get(&alias) { download::update_podcast(&alias, root, feed_url)?; } else { anyhow::bail!(r#"podcast "{}" not found in configuration file"#, alias) } } // Updating all podcasts else { for (alias, feed_url) in config.podcasts { download::update_podcast(&alias, root, &feed_url)?; } } Ok(()) }