use std::path::Path; use file::{FileError, LinksFile}; use mastodon::Mastodon; mod file; mod wikipedia; mod mastodon; fn main() { dotenv::dotenv().ok(); let app_code = std::env::var("APP_CODE").expect("APP_CODE required."); let app_token = std::env::var("APP_TOKEN").expect("APP_TOKEN required."); let app_instance = std::env::var("APP_INSTANCE").expect("APP_INSTANCE required."); let queue = LinksFile::new(Path::new("queue.txt")); let backup = LinksFile::new(Path::new("backup.txt")); let mastodon = Mastodon::new(app_instance, app_token); // get link to post let link_to_post = match queue.remove_first_line() { Ok(a) => a, Err(FileError::EmptyLine) => match backup.remove_first_line() { Ok(b) => b, Err(c) => panic!("{c:?}") }, Err(d) => panic!("{d:?}") }; println!("{link_to_post}") }