diff options
| author | Nathan Jaremko | 2018-03-22 00:10:33 -0400 |
|---|---|---|
| committer | Nathan Jaremko | 2018-03-22 00:10:33 -0400 |
| commit | 829f9fca259034d1a63173bb19e43b1c24c3face (patch) | |
| tree | 8b59381393f1e41b994afe9a4b25af9ed0309629 /src/actions.rs | |
| parent | 7a110aa9098c5fa2c772dd5f4dcc93ef3322de00 (diff) | |
| download | podcast-829f9fca259034d1a63173bb19e43b1c24c3face.tar.bz2 | |
Fix ls/list to allow piping
Diffstat (limited to 'src/actions.rs')
| -rw-r--r-- | src/actions.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/actions.rs b/src/actions.rs index e9cf27b..19fc00c 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -13,6 +13,9 @@ use rss::Channel; use toml; pub fn list_episodes(search: &str) { + let stdout = io::stdout(); + let mut handle = stdout.lock(); + let re = Regex::new(&format!("(?i){}", &search)).expect("Failed to parse regex"); let mut path = get_podcast_dir(); path.push(".rss"); @@ -25,7 +28,12 @@ pub fn list_episodes(search: &str) { let podcast = Podcast::from(channel); let episodes = podcast.episodes(); for (num, ep) in episodes.iter().enumerate() { - println!("({}) {}", episodes.len() - num, ep.title().unwrap()); + write!( + &mut handle, + "({}) {}\n", + episodes.len() - num, + ep.title().unwrap() + ); } return; } @@ -98,8 +106,10 @@ pub fn update_rss(state: &mut State) { } pub fn list_subscriptions(state: &State) { + let stdout = io::stdout(); + let mut handle = stdout.lock(); for podcast in &state.subscriptions() { - println!("{}", &podcast.title); + write!(&mut handle, "{}\n", &podcast.title); } } |
