Skip to content

Commit

Permalink
Exit when config file is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Aug 23, 2024
1 parent 9a3c673 commit ea77492
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bbox-core/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::config::Loglevel;
use crate::config::{config_error_exit, Loglevel};
use crate::service::OgcApiService;
use clap::{ArgMatches, Args, Command, CommandFactory, FromArgMatches, Parser, Subcommand};
use log::warn;
use std::env;
use std::path::PathBuf;
use std::path::{Path, PathBuf};

#[derive(Args, Debug)]
pub struct GlobalArgs {
Expand Down Expand Up @@ -69,7 +69,11 @@ impl CliArgs {
return;
};
if let Some(config) = args.config {
env::set_var("BBOX_CONFIG", config);
if Path::new(&config).exists() {
env::set_var("BBOX_CONFIG", config);
} else {
config_error_exit(format!("Config file {config:?} not found."));
}
}
}
}
Expand Down

0 comments on commit ea77492

Please sign in to comment.