From e687152db46f4f56d7c728b5b2b614ee8cb1f716 Mon Sep 17 00:00:00 2001 From: necrashter Date: Sat, 23 Apr 2022 17:03:14 +0300 Subject: Read multiple configs from command line --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 65b4430..be109d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,11 +43,17 @@ use log::{error}; async fn main() { log4rs::init_file("log.conf.yml", log4rs::config::Deserializers::default()).unwrap(); - let configs = vec!["config.yaml"]; + let mut args: Vec = std::env::args().collect(); - let combined_routes = configs.into_iter() + if args.len() == 1 { + // config.yaml is the default configuration file + args.push("config.yaml".to_string()); + } + + let combined_routes = args.into_iter() + .skip(1) // Skip the program name .filter_map(|filename| { - match Config::read(filename) { + match Config::read(&filename) { Some(config) => Some(routes::network(Db::new(config))), None => None, } -- cgit v1.2.3-70-g09d2