diff options
author | necrashter | 2022-04-23 17:03:14 +0300 |
---|---|---|
committer | Yigit Sever | 2022-04-23 18:10:12 +0300 |
commit | e687152db46f4f56d7c728b5b2b614ee8cb1f716 (patch) | |
tree | 23908453c5fb4b7a6f52c0b5bbb7c4b814f9e746 /src | |
parent | 72cdcda9eff98c7bd0cc07416c85e2d8c8de6983 (diff) | |
download | gradecoin-e687152db46f4f56d7c728b5b2b614ee8cb1f716.tar.gz gradecoin-e687152db46f4f56d7c728b5b2b614ee8cb1f716.tar.bz2 gradecoin-e687152db46f4f56d7c728b5b2b614ee8cb1f716.zip |
Read multiple configs from command line
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 12 |
1 files 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}; | |||
43 | async fn main() { | 43 | async fn main() { |
44 | log4rs::init_file("log.conf.yml", log4rs::config::Deserializers::default()).unwrap(); | 44 | log4rs::init_file("log.conf.yml", log4rs::config::Deserializers::default()).unwrap(); |
45 | 45 | ||
46 | let configs = vec!["config.yaml"]; | 46 | let mut args: Vec<String> = std::env::args().collect(); |
47 | 47 | ||
48 | let combined_routes = configs.into_iter() | 48 | if args.len() == 1 { |
49 | // config.yaml is the default configuration file | ||
50 | args.push("config.yaml".to_string()); | ||
51 | } | ||
52 | |||
53 | let combined_routes = args.into_iter() | ||
54 | .skip(1) // Skip the program name | ||
49 | .filter_map(|filename| { | 55 | .filter_map(|filename| { |
50 | match Config::read(filename) { | 56 | match Config::read(&filename) { |
51 | Some(config) => Some(routes::network(Db::new(config))), | 57 | Some(config) => Some(routes::network(Db::new(config))), |
52 | None => None, | 58 | None => None, |
53 | } | 59 | } |