stop program when config from argument is not found
This commit is contained in:
parent
416c0f48f0
commit
f45e469217
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user