[−][src]Crate envmnt
envmnt
Environment variables utility functions.
This library has many helper functions to access/modify/check environment variables.
Example
extern crate envmnt; fn main() { if !envmnt::exists("MY_ENV_VAR") { envmnt::set("MY_ENV_VAR", "SOME VALUE"); } let value = envmnt::get_or("MY_ENV_VAR", "DEFAULT_VALUE"); println!("Env Value: {}", &value); envmnt::set_bool("FLAG_VAR", true); let flag_value = envmnt::is_or("FLAG_VAR", false); println!("Bool Flag: {}", &flag_value); let pre_value = envmnt::get_set("MY_ENV_VAR", "SOME NEW VALUE"); let value = envmnt::get_or("MY_ENV_VAR", "DEFAULT_VALUE"); println!("New Env Value: {}", &value); println!("Previous Env Value: {:?}", &pre_value); }
Installation
In order to use this library, just add it as a dependency:
[dependencies]
envmnt = "*"
Contributing
License
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.
Functions
exists | Returns true environment variable is defined. |
get_or | Returns the environment variable value or if is not defined, the default value will be returned. |
get_remove | Removes the provided environment variable and returns its previous value (if any). |
get_set | Sets the environment variable value and returns the previous value. |
is_or | Returns false if environment variable value if falsy. The value is falsy if it is one of the following: |
remove | Removes the provided environment variable. |
set | Sets the environment variable value. |
set_bool | Sets the environment variable with a true/false value as string. |