mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 08:52:16 +00:00
main: slight refactoring
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -91,21 +91,22 @@ async fn get_data_stores(
|
||||
async fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
let parse_config = || {
|
||||
Figment::new()
|
||||
.merge(Toml::file(&args.config_file))
|
||||
.merge(Env::prefixed("RUSTICAL_").split("__"))
|
||||
.extract()
|
||||
};
|
||||
|
||||
match args.command {
|
||||
Some(Command::GenConfig(gen_config_args)) => cmd_gen_config(gen_config_args)?,
|
||||
Some(Command::Principals(principals_args)) => cmd_principals(principals_args).await?,
|
||||
Some(Command::Health(health_args)) => {
|
||||
let config: Config = Figment::new()
|
||||
.merge(Toml::file(&args.config_file))
|
||||
.merge(Env::prefixed("RUSTICAL_").split("__"))
|
||||
.extract()?;
|
||||
let config: Config = parse_config()?;
|
||||
cmd_health(config.http, health_args).await?;
|
||||
}
|
||||
None => {
|
||||
let config: Config = Figment::new()
|
||||
.merge(Toml::file(&args.config_file))
|
||||
.merge(Env::prefixed("RUSTICAL_").split("__"))
|
||||
.extract()?;
|
||||
let config: Config = parse_config()?;
|
||||
|
||||
setup_tracing(&config.tracing);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user