From 851ae4926fba296098fa5f08f99ba64622232ed2 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 12 Feb 2023 00:21:11 +0100 Subject: config path as arg --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 976cad5..f507ed5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ pub mod config; use crate::config::Config; -use anyhow::{bail, Context, Result}; +use anyhow::{anyhow, bail, Context, Result}; use http_body_util::{combinators::BoxBody, BodyExt}; use hyper::{ body::Incoming, @@ -24,7 +24,10 @@ use tokio_rustls::TlsAcceptor; async fn main() -> anyhow::Result<()> { env_logger::init_from_env("LOG"); - let config = Arc::new(Config::load()?); + let config_path = std::env::args().skip(1).next().ok_or(anyhow!( + "first argument is expected to be the configuration file" + ))?; + let config = Arc::new(Config::load(&config_path)?); tokio::select! { x = serve_http(config.clone()) => x.context("serving http")?, -- cgit v1.2.3-70-g09d2