summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorSerguey Parkhomovsky <xindigo@gmail.com>2026-03-21 09:50:26 -0700
committerSerguey Parkhomovsky <xindigo@gmail.com>2026-03-21 09:50:26 -0700
commit50a45092eab7f7f6c1f701bffe40226dcb6eeaf9 (patch)
tree80a79adb0dbf5b7e5b867d0752430deef4c6d9c5 /src/main.rs
parentd0b78cc12bae1614829b92a96dbe1dbccfb0bcfb (diff)
Allow config path to be passed by argument
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs12
1 files changed, 11 insertions, 1 deletions
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<Mutex<HashMap<String, PrinterState>>>;
+#[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();