Expand description
Simple Environment variable setter which loads a specified file, reads the key value pairs from each new line, and inserts them into the runtime environment. example:
EnvironmentLoader::new(file_path.to_str().unwrap());
Where file_path
is a &str
path to the desired env to load, and its content is as follows:
ⓘ
E1=123
E2=ABC
The result would be environment variables (E1
, E2
) being set with the specified values after the first =
sign.
A code snippet example for a use case:
use std::{fmt::Result, fs::metadata};
let config_path = "config/server.env";
match metadata(config_path) {
Ok(_) => envloader::EnvironmentLoader::new(config_path),
Err(_) => println!("Using system environment"),
}
Structs§
- Environment
Loader - Loads key value pairs from a file into the programs environment