diff --git a/README.adoc b/README.adoc index 9755379..fcd261b 100644 --- a/README.adoc +++ b/README.adoc @@ -33,6 +33,12 @@ You can optionally specify `check_type`: * `Html`: Default value, checks if a request is succeessful and returns HTTP OK - 200. * `Actuator`: Like `Html`, but checks if _Actuator_ shows that the application is up and running. +To use more than one configuration, pass the config file location as first argument to the application. + +---- +$ checkbar /etc/checkbar_example.toml +---- + === Colors To change the colors, use the following configuration. As an example the colors of the default configuration are shown. diff --git a/src/main.rs b/src/main.rs index acee653..1b0fc5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use serde::Deserialize; use std::fmt::{Display, Formatter, Result}; +use std::env; use std::fs; use std::process; use std::time::Duration; @@ -122,12 +123,15 @@ async fn print_states(check_configs: &[CheckConfig]) { println!("{}],", entries.join(",")); } +fn get_config_file() -> String { + match env::args().nth(1) { + Some(config_file) => config_file, + None => format!("{}/.checkbar.toml", dirs::home_dir().unwrap().to_str().unwrap_or("")) + } +} + fn get_config() -> Config { - let home_dir = dirs::home_dir().unwrap(); - match fs::read_to_string(format!( - "{}/.checkbar.toml", - home_dir.to_str().unwrap_or("") - )) { + match fs::read_to_string(get_config_file()) { Ok(config) => match toml::from_str(config.as_str()) { Ok(config) => config, Err(_e) => Config {