refactor(cli): add an own config.rs file for the config logic
This commit is contained in:
parent
aa183a30bd
commit
3beef739a4
3 changed files with 22 additions and 21 deletions
|
|
@ -5,7 +5,7 @@ use clap::{Parser, Subcommand};
|
|||
use std::{env, sync::Arc};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::GLOBAL_CONFIG;
|
||||
use crate::config::GLOBAL_CONFIG;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version = env!("CARGO_PKG_VERSION"), about = "Send and receive files securely")]
|
||||
|
|
|
|||
20
caesar-cli/src/config.rs
Normal file
20
caesar-cli/src/config.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use lazy_static::lazy_static;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct CaesarConfig {
|
||||
pub app_environment: String,
|
||||
pub app_host: String,
|
||||
pub app_port: String,
|
||||
pub app_origin: String,
|
||||
pub app_relay: String,
|
||||
pub rust_log: String,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref GLOBAL_CONFIG: CaesarConfig = {
|
||||
let cfg: CaesarConfig = confy::load("caesar", "caesar")
|
||||
.expect("Konfigurationsdatei konnte nicht geladen werden");
|
||||
cfg
|
||||
};
|
||||
}
|
||||
|
|
@ -1,29 +1,10 @@
|
|||
use crate::cli::args::Args;
|
||||
use dotenvy::dotenv;
|
||||
use lazy_static::lazy_static;
|
||||
use serde::{self, Deserialize, Serialize};
|
||||
use tracing::error;
|
||||
use tracing_subscriber::filter::EnvFilter;
|
||||
|
||||
mod cli;
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||
struct CaesarConfig {
|
||||
app_environment: String,
|
||||
app_host: String,
|
||||
app_port: String,
|
||||
app_origin: String,
|
||||
app_relay: String,
|
||||
rust_log: String,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref GLOBAL_CONFIG: CaesarConfig = {
|
||||
let cfg: CaesarConfig = confy::load("caesar", "caesar")
|
||||
.expect("Konfigurationsdatei konnte nicht geladen werden");
|
||||
cfg
|
||||
};
|
||||
}
|
||||
mod config;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue