dot_env

Types

pub opaque type DotEnv
pub type Opts {
  Opts(path: String, debug: Bool, capitalize: Bool)
  Default
}

Constructors

  • Opts(path: String, debug: Bool, capitalize: 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

  • Default

    Default options for loading the .env file - see default constant

Constants

pub const default: DotEnv = DotEnv(
  path: ".env",
  debug: True,
  capitalize: True,
)

Functions

pub fn load() -> 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()
}
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))
}
Search Document