mirror of
https://github.com/darwincereska/envkit.git
synced 2026-06-11 10:23:23 -05:00
23 lines
573 B
Rust
23 lines
573 B
Rust
use envkit::EnvLoader;
|
|
|
|
fn main() -> Result<(), envkit::error::EnvError> {
|
|
unsafe {
|
|
std::env::set_var("APP_HOST", "127.0.0.1");
|
|
std::env::set_var("APP_PORT", "3000");
|
|
std::env::set_var("APP_ENABLED", "yes");
|
|
}
|
|
|
|
let loader = EnvLoader::new();
|
|
let app = loader.with_prefix("APP_");
|
|
|
|
let host: String = app.get("HOST")?;
|
|
let port: u16 = app.get_or("PORT", 8080);
|
|
let enabled: bool = app.get_or("ENABLED", false);
|
|
|
|
println!("host: {host}");
|
|
println!("port: {port}");
|
|
println!("enabled: {enabled}");
|
|
|
|
Ok(())
|
|
}
|