dot_env

Types

pub opaque type DotEnv
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

pub const default: DotEnv = DotEnv(
  path: ".env",
  debug: True,
  capitalize: True,
  ignore_missing_file: 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