From 50a45092eab7f7f6c1f701bffe40226dcb6eeaf9 Mon Sep 17 00:00:00 2001 From: Serguey Parkhomovsky Date: Sat, 21 Mar 2026 09:50:26 -0700 Subject: Allow config path to be passed by argument --- src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index fdcdd47..187c0fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use axum::{Json, Router, extract::State, routing::get}; +use clap::Parser; use native_tls::TlsConnector; use printstats::*; use reqwest::Client; @@ -12,11 +13,20 @@ use tokio::task::{Id, JoinSet}; type StateMap = Arc>>; +#[derive(Parser, Debug)] +#[command(about = "Print statistics scraper")] +struct Args { + /// Path to the configuration file + #[arg(long, default_value = "config.toml")] + config: String, +} + #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); - let content = fs::read_to_string("config.toml").expect("Couldn't read config.toml"); + let args = Args::parse(); + let content = fs::read_to_string(&args.config).expect("Couldn't read config file"); let config = Config::load(&content); let state: StateMap = Arc::new(Mutex::new(HashMap::new())); let mut tasks = JoinSet::new(); -- cgit v1.2.3