mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-25 16:17:56 +01:00
Merge branch 'feature/configchecker' into 'development'
do a basic config check See merge request fabinfra/fabaccess/bffh!8
This commit is contained in:
commit
16c94ae473
18
src/main.rs
18
src/main.rs
@ -40,6 +40,7 @@ use error::Error;
|
|||||||
use slog::Logger;
|
use slog::Logger;
|
||||||
|
|
||||||
use paho_mqtt::AsyncClient;
|
use paho_mqtt::AsyncClient;
|
||||||
|
use crate::config::Config;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
use clap::{crate_version, crate_description, crate_name};
|
use clap::{crate_version, crate_description, crate_name};
|
||||||
@ -59,6 +60,10 @@ fn main() {
|
|||||||
.help("Print a default config to stdout instead of running")
|
.help("Print a default config to stdout instead of running")
|
||||||
.long("print-default")
|
.long("print-default")
|
||||||
)
|
)
|
||||||
|
.arg(Arg::with_name("check config")
|
||||||
|
.help("Check config for validity")
|
||||||
|
.long("check")
|
||||||
|
)
|
||||||
.arg(Arg::with_name("dump")
|
.arg(Arg::with_name("dump")
|
||||||
.help("Dump all databases into the given directory")
|
.help("Dump all databases into the given directory")
|
||||||
.long("dump")
|
.long("dump")
|
||||||
@ -87,6 +92,19 @@ fn main() {
|
|||||||
|
|
||||||
// Early return to exit.
|
// Early return to exit.
|
||||||
return;
|
return;
|
||||||
|
} else if matches.is_present("check config") {
|
||||||
|
let configpath = matches.value_of("config").unwrap_or("/etc/diflouroborane.dhall");
|
||||||
|
match config::read(&PathBuf::from_str(configpath).unwrap()) {
|
||||||
|
Ok(cfg) => {
|
||||||
|
//TODO: print a normalized version of the supplied config
|
||||||
|
println!("config is valid");
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("{}", e);
|
||||||
|
std::process::exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let retval;
|
let retval;
|
||||||
|
Loading…
Reference in New Issue
Block a user