use klauthed_core::config::provider::{EnvProvider, FileProvider, MemoryProvider};
use klauthed_core::config::{Config, Profile};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app_toml = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/config/app.toml");
let config = Config::builder(Profile::detect())
.with_provider(MemoryProvider::new().set("server", json!({ "port": 8080 })))
.with_provider(FileProvider::new(app_toml))
.with_provider(EnvProvider::new())
.build()
.await?;
println!("=== CONFIG QUICKSTART ===");
println!("profile : {}", config.profile());
let server = config.server()?;
println!("server bind : {}", server.bind_address());
let db = config.database()?;
println!("database system : {:?}", db.system);
println!("database url : {}", db.connection_url());
println!("database pool max: {}", db.pool.max_connections);
println!("database options : {:?}", db.options);
let cache = config.cache()?;
println!("cache url : {:?}", cache.connection_url());
let messaging = config.messaging()?;
println!("messaging backend: {:?}", messaging.backend());
let storage = config.storage()?;
println!("storage : {storage:?}");
Ok(())
}