Expand description
§A super light-weight dotenv library
With less than 20 lines of code of the core part, but meet most of the requirements of a dotenv. JUST KEEP IT SIMPLE!
§Examples
use dotconf::{init, init_with_path};
std::fs::write(".env", "a=b").unwrap();
init().expect("Failed to load env conf file (default: .env)");
std::fs::write(".dotenvfile", "
a=b # This is a comment
b=32
c=true
").unwrap();
init_with_path(".dotenvfile").expect("Failed to load from the specified env conf file");
// Read value with env::var with some simple type conversions
let a = dotconf::var("a").to_string().unwrap();
let b = dotconf::var("b").to_isize().unwrap();
let c = dotconf::var("c").to_bool().unwrap();Structs§
Functions§
- init
- Load dotenv file with a default path.
Use
init_with_pathto load from a specific file. - init_
with_ path - Load dotenv file with a specified path.
- parse_
dotconf_ file - Parse dotenv file as key-value pairs
use
#to start a comment. - var
- Read key-value pair with
env::var