stop program when config from argument is not found

This commit is contained in:
jb-alvarado 2022-08-19 09:40:50 +02:00
parent 416c0f48f0
commit f45e469217

View File

@ -1,4 +1,7 @@
use std::path::{Path, PathBuf}; use std::{
path::{Path, PathBuf},
process::exit,
};
pub mod arg_parse; pub mod arg_parse;
@ -10,15 +13,18 @@ pub fn get_config(args: Args) -> PlayoutConfig {
Some(c) => { Some(c) => {
let path = PathBuf::from(format!("/etc/ffplayout/{c}.yml")); let path = PathBuf::from(format!("/etc/ffplayout/{c}.yml"));
if path.is_file() { if !path.is_file() {
Some(path.display().to_string()) println!(
} else { "Config file \"{c}\" under \"/etc/ffplayout/\" not found.\n\nCheck arguments!"
println!("no file"); );
args.config exit(1)
} }
Some(path.display().to_string())
} }
None => args.config, None => args.config,
}; };
let mut config = PlayoutConfig::new(cfg_path); let mut config = PlayoutConfig::new(cfg_path);
if let Some(gen) = args.generate { if let Some(gen) = args.generate {