From f45e469217655684cdde4cd98c5e0a75356694d6 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Fri, 19 Aug 2022 09:40:50 +0200 Subject: [PATCH] stop program when config from argument is not found --- ffplayout-engine/src/utils/mod.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ffplayout-engine/src/utils/mod.rs b/ffplayout-engine/src/utils/mod.rs index e8cc08d3..44a5baba 100644 --- a/ffplayout-engine/src/utils/mod.rs +++ b/ffplayout-engine/src/utils/mod.rs @@ -1,4 +1,7 @@ -use std::path::{Path, PathBuf}; +use std::{ + path::{Path, PathBuf}, + process::exit, +}; pub mod arg_parse; @@ -10,15 +13,18 @@ pub fn get_config(args: Args) -> PlayoutConfig { Some(c) => { let path = PathBuf::from(format!("/etc/ffplayout/{c}.yml")); - if path.is_file() { - Some(path.display().to_string()) - } else { - println!("no file"); - args.config + if !path.is_file() { + println!( + "Config file \"{c}\" under \"/etc/ffplayout/\" not found.\n\nCheck arguments!" + ); + exit(1) } + + Some(path.display().to_string()) } None => args.config, }; + let mut config = PlayoutConfig::new(cfg_path); if let Some(gen) = args.generate {