1
0
Fork 0

Fail on unspecified run mode

This commit is contained in:
clerie 2023-01-08 18:07:05 +01:00
parent 5aed8cf0ec
commit de00a92b88
1 changed files with 7 additions and 3 deletions

View File

@ -12,6 +12,7 @@ use std::str::FromStr;
#[derive(PartialEq)]
enum OperationMode {
None,
Exporter,
Validator,
}
@ -29,9 +30,9 @@ fn parse_nix_store_path(path: std::path::PathBuf) -> Result<(String, String), St
#[tokio::main]
async fn main() {
let mut listen = String::from("[::]:9152");
let mut operationmode = OperationMode::Exporter;
let mut operationmode = OperationMode::None;
let mut args = std::env::args();
args.next();
let name = args.next().unwrap();
loop {
let arg = if let Some(arg) = args.next() {
arg
@ -69,7 +70,10 @@ async fn main() {
} else if operationmode == OperationMode::Validator {
println!("Running NixOS Exporter in Validator mode");
app = app.route("/metrics", get(check));
}
} else {
println!("Run mode not specified, do {} --help", name);
std::process::exit(1);
};
let addr = SocketAddr::from_str(&listen).unwrap();
println!("listening on http://{}", addr);