Skip to content

EnvParserOptions

Defined in: types.ts:33

Options for creating an env parser.

appName: string

Defined in: types.ts:38

Display name for this app — used in debug output. Should match your package.json name field.


optional loader?: EnvLoader

Defined in: types.ts:43

Custom loader strategy. Defaults to DotenvLoader.


optional logger?: EnvLogger

Defined in: types.ts:83

Structured logger for debug output (key-loaded counts, missing-key warnings, deprecation notices). Defaults to console.info/console.warn.


optional namespaces?: string[]

Defined in: types.ts:77

Namespace prefixes to filter and strip from raw env var keys. When set, only vars whose names start with one of these prefixes (case-insensitive, followed by _) are visible to the parser. The prefix is stripped before the key is normalised and looked up.

Uses a cascade model — later entries win when the same key exists under multiple prefixes. Put broad/global namespaces first and project-specific overrides last (same mental model as CSS specificity or Object.assign).

This lets you share an org-wide namespace (e.g. HOLOCRON_ set once in ~/.bashrc) as a base, then override individual vars with a project-specific prefix in .env, without copying every global var into each project.

// HOLOCRON_DEBUG is the global default; CLI_TEMPLATE_DEBUG overrides it.
createEnvParser({ appName: "my-cli", namespaces: ["HOLOCRON", "CLI_TEMPLATE"] })
// Single namespace — only HOLOCRON_* vars are visible
createEnvParser({ appName: "my-cli", namespaces: ["HOLOCRON"] })
// Completely custom — no org namespace at all
createEnvParser({ appName: "my-cli", namespaces: ["MY_TOOL"] })

optional parseValues?: boolean

Defined in: types.ts:49

Whether to coerce “true”/“false”/numeric strings into their native types. Defaults to true.