This commit is contained in:
AB
2020-06-04 00:43:55 +03:00
parent 7b3b955caf
commit 29eacf8302
4 changed files with 142 additions and 164 deletions

View File

@ -4,7 +4,6 @@ use std::process;
extern crate chrono;
extern crate config;
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Config {
pub server: String,
@ -14,7 +13,6 @@ pub struct Config {
pub conf_file: String,
}
pub fn read() -> Config {
// Parse opts and args
let cli_args = App::new(env!("CARGO_PKG_NAME"))
@ -32,7 +30,11 @@ pub fn read() -> Config {
.get_matches();
info!("Logger initialized. Set RUST_LOG=[debug,error,info,warn,trace] Default: info");
info!("Starting {} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
info!(
"Starting {} {}",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION")
);
// Read config file and env vars
let config_file = cli_args.value_of("conf").unwrap();
@ -64,15 +66,11 @@ pub fn read() -> Config {
let username = match settings.get_str("username") {
Ok(username) => Some(username),
Err(_) => {
None
}
Err(_) => None,
};
let password = match settings.get_str("password") {
Ok(password) => Some(password),
Err(_) => {
None
}
Err(_) => None,
};
if password == None || username == None {
warn!("Insecure server detected. Set `username` and `password` directives to use auth.");
@ -84,4 +82,4 @@ pub fn read() -> Config {
mountpoint: mountpoint,
conf_file: config_file.to_string(),
}
}
}