aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 62d2f38..7fce580 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,45 @@
+use std::path::{Path, PathBuf};
+use std::process::exit;
+use clap::Parser;
+use log::info;
+use crate::config::Config;
+use crate::dyndns_service::DynDnsService;
+use crate::error::AppResult;
+use crate::ip_service::IpService;
+
mod dyndns_service;
mod ip_service;
mod config;
+mod error;
+
+#[derive(Parser, Debug)]
+#[command(version, about, long_about = None)]
+struct Args {
+ #[arg(short, long, default_value = "~/.config/multiwan-dyndns/config.json")]
+ config_file: PathBuf,
+}
fn main() {
- println!("Hello, world!");
+ env_logger::init();
+
+ let args = Args::parse();
+ match run(args) {
+ Ok(_) => exit(0),
+ Err(e) => {
+ log::error!("{}", e);
+ exit(1);
+ }
+ }
+}
+
+fn run(args: Args) -> AppResult<()> {
+ let config = Config::load(&args.config_file)?;
+ for network in config.networks {
+ // let ip = IpService::resolve(&network.ip_service)?;
+ // for dyndns in network.providers {
+ // DynDnsService::register(&dyndns, &ip)?;
+ // }
+ }
+
+ Ok(())
}