aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions.rs')
-rw-r--r--src/actions.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/actions.rs b/src/actions.rs
new file mode 100644
index 0000000..0f8d337
--- /dev/null
+++ b/src/actions.rs
@@ -0,0 +1,26 @@
+use regex::Regex;
+use structs::*;
+
+pub fn list_episodes(state: State, search: &str) {
+ let re = Regex::new(&search).unwrap();
+ for podcast in state.subscriptions() {
+ if re.is_match(&podcast.name) {
+ println!("Episodes for {}:", &podcast.name);
+ match Podcast::from_url(&podcast.url) {
+ Ok(podcast) => {
+ for title in podcast.list_episodes() {
+ println!("{}", title)
+ }
+ }
+ Err(err) => println!("{}", err),
+ }
+
+ }
+ }
+}
+
+pub fn list_subscriptions(state: State) {
+ for podcast in state.subscriptions() {
+ println!("{}", podcast.name);
+ }
+}