Skip to content

Commit

Permalink
Removed another unwrap statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Oct 8, 2023
1 parent 09d6a4c commit 20b761a
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/command_line_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::utils::error::CustomError;

pub fn start_command_line(mut args: Args) {
println!("Starting from command line");
match args.nth(1).unwrap().as_str() {
match args.next().unwrap().as_str() {
"help" | "--help" => {
println!(r" The following commands are available:
users => Handles user management
Expand All @@ -36,23 +36,27 @@ pub fn start_command_line(mut args: Args) {
match args.next().unwrap().as_str() {
"refresh" => {
let podcast_rss_feed = args.next();
if podcast_rss_feed.is_none() {
println!("Please provide a podcast rss feed url");
exit(1);
}
let rss_feed = podcast_rss_feed.clone().unwrap();
let mut podcast_service = PodcastService::new();
let conn = &mut establish_connection();

match podcast_rss_feed {
Some(feed)=>{
let mut podcast_service = PodcastService::new();
let conn = &mut establish_connection();


let replaced_feed = rss_feed.replace(['\'', ' '], "");
println!("Refreshing podcast {}", replaced_feed);
let replaced_feed = feed.replace(['\'', ' '], "");
println!("Refreshing podcast {}", replaced_feed);

let podcast = Podcast::get_podcast_by_rss_feed(replaced_feed, conn).expect("Error getting podcast");
let podcast = Podcast::get_podcast_by_rss_feed(replaced_feed, conn).expect("Error getting podcast");

let mut podcast_episode_service = PodcastEpisodeService::new();
podcast_episode_service.insert_podcast_episodes(conn, podcast.clone()).unwrap();
podcast_service.schedule_episode_download(podcast, None, conn).unwrap();
let mut podcast_episode_service = PodcastEpisodeService::new();
podcast_episode_service.insert_podcast_episodes(conn, podcast.clone()).unwrap();
podcast_service.schedule_episode_download(podcast, None, conn).unwrap();
}
None=>{
println!("Please provide a podcast rss feed url");
exit(1);
}
}
}
"refresh-all" => {
let conn = &mut establish_connection();
Expand Down

0 comments on commit 20b761a

Please sign in to comment.