Adding code to main
sender Build / Check (pull_request) Successful in 27s
sender Build / Test Suite (pull_request) Failing after 39s
sender Build / Rustfmt (pull_request) Successful in 26s
sender Build / Clippy (pull_request) Failing after 27s
sender Build / build (pull_request) Successful in 28s
sender Build / Check (pull_request) Successful in 27s
sender Build / Test Suite (pull_request) Failing after 39s
sender Build / Rustfmt (pull_request) Successful in 26s
sender Build / Clippy (pull_request) Failing after 27s
sender Build / build (pull_request) Successful in 28s
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
pub const APP_NAME: &str = "sender";
|
pub const APP_NAME: &str = "sender";
|
||||||
|
|
||||||
|
/// Returns numbers and message paths
|
||||||
pub fn get_paths(args: Vec<String>) -> Result<(String, String), std::io::Error> {
|
pub fn get_paths(args: Vec<String>) -> Result<(String, String), std::io::Error> {
|
||||||
if args.len() < 2 {
|
if args.len() < 2 {
|
||||||
Err(std::io::Error::other("Not enough arguments"))
|
Err(std::io::Error::other("Not enough arguments"))
|
||||||
|
|||||||
+33
@@ -11,4 +11,37 @@ async fn main() {
|
|||||||
version::print_version();
|
version::print_version();
|
||||||
std::process::exit(-1);
|
std::process::exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match config::get_paths(args) {
|
||||||
|
Ok((n_path, m_path)) => {
|
||||||
|
println!("Message path: {m_path:?}");
|
||||||
|
println!("Phone Number path: {n_path:?}");
|
||||||
|
|
||||||
|
let (config, success) = config::parse_config().await;
|
||||||
|
if !success {
|
||||||
|
eprintln!("Error parsing config");
|
||||||
|
} else {
|
||||||
|
let contacts = match messaging::parse_numbers(&n_path) {
|
||||||
|
Ok(contacts) => contacts,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: {err:?}");
|
||||||
|
std::process::exit(-1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let message = match messaging::parse_message(&m_path) {
|
||||||
|
Ok(message) => message,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: {err:?}");
|
||||||
|
std::process::exit(-1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("Message: {:?}", message.content);
|
||||||
|
messaging::send_messages(&config, &contacts, &message, 5).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: {err:?}");
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user