1
0

Fail on unspecified run mode

This commit is contained in:
clerie 2023-01-08 18:07:05 +01:00
parent 5aed8cf0ec
commit de00a92b88

View File

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