diff --git a/src/config/mod.rs b/src/config/mod.rs index 9b39933..3bbdf80 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,7 +1,22 @@ pub const APP_NAME: &str = "sender"; -pub fn get_paths(args: Vec) -> (String, String, String) { - (args[1].clone(), args[2].clone(), args[3].clone()) +pub fn get_paths(args: Vec) -> Result<(String, String), std::io::Error> { + if args.len() < 2 { + Err(std::io::Error::other("Not enough arguments")) + } else { + let numbers_path = args[1].clone(); + let message_path = args[2].clone(); + if !path_exists(&numbers_path) && !path_exists(&message_path) { + Err(std::io::Error::other("Paths do not exists")) + } else { + Ok((numbers_path, message_path)) + } + } +} + +fn path_exists(path: &str) -> bool { + let file = std::path::Path::new(path); + file.exists() } pub async fn parse_config() -> (textsender_models::config::auxiliary::TwilioConfig, bool) {