diff options
| author | Gus Power <gus@infinitesidequests.com> | 2025-05-15 15:18:39 +0100 |
|---|---|---|
| committer | Gus Power <gus@infinitesidequests.com> | 2025-05-15 15:18:39 +0100 |
| commit | 5f2466e463edcf6d161f9ba6371eaf7afc3549e3 (patch) | |
| tree | 6814ffd62c52245cc081ca6ebb419273d7b4b062 /src/main.rs | |
| parent | dd1483cb6d9c060a17dc68357975de2b1ec09c08 (diff) | |
construct full config, use Args to load it
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 40 |
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(()) } |
