dot_env
Types
pub type Opts {
Opts(
path: String,
debug: Bool,
capitalize: Bool,
ignore_missing_file: Bool,
)
Default
}
Constructors
-
Opts( path: String, debug: Bool, capitalize: Bool, ignore_missing_file: Bool, )
Customized options for loading the .env file
Arguments
-
path
The path to the .env file relative to the project root eg. .env and src/.env are two different things, .env points to the root of the project, src/.env points to the src folder in the root of the project
-
debug
Print debug information if something goes wrong
-
capitalize
Force all keys to be uppercase
-
ignore_missing_file
In case the file is missing, ignore the error and continue
-
-
Default
Default options for loading the .env file - see
default
constant
Constants
Functions
pub fn load(dotenv: DotEnv) -> Nil
Load the .env file using the current DotEnv instance and set the environment variables
Example
import dot_env as dot
pub fn main() {
dot.new()
|> dot.set_path("src/.env")
|> dot.set_debug(False)
|> dot.load
}
pub fn load_default() -> Nil
Load the .env file at the default path (.env) and set the environment variables
Debug information will be printed to the console if something goes wrong and all keys will be capitalized
Example
import dot_env
pub fn main() {
dot_env.load_default()
}
pub fn load_with_opts(opts: Opts) -> Nil
Load the .env file at the specified path and set the environment variables
Debug information and key capitalization can be customized
Example
import dot_env
pub fn main() {
dot_env.load_with_opts(dot_env.Opts(path: "src/.env", debug: False, capitalize: False))
}
pub fn new() -> DotEnv
Create a default DotEnv instance. This is designed to use used as the starting point for using any of the builder methods
pub fn new_with_path(path: String) -> DotEnv
Create a new DotEnv instance with the specified path
pub fn path(instance: DotEnv) -> String
Get the path to the .env file in the current DotEnv instance
pub fn set_capitalize(
instance: DotEnv,
capitalize: Bool,
) -> DotEnv
Set whether to capitalize all keys in the current DotEnv instance
pub fn set_debug(instance: DotEnv, debug: Bool) -> DotEnv
Set whether to print debug information in the current DotEnv instance
pub fn set_ignore_missing_file(
instance: DotEnv,
ignore_missing_file: Bool,
) -> DotEnv
Set whether to ignore missing file errors in the current DotEnv instance