Skip to content

env-var-defaults-api: Add public EnvVar API with default inference - #667

Open
janna-rn wants to merge 1 commit into
bkirwi:mainfrom
janna-rn:feature/env-var-defaults-api
Open

env-var-defaults-api: Add public EnvVar API with default inference#667
janna-rn wants to merge 1 commit into
bkirwi:mainfrom
janna-rn:feature/env-var-defaults-api

Conversation

@janna-rn

@janna-rn janna-rn commented Jun 2, 2026

Copy link
Copy Markdown

Expose environment variable metadata — including whether each variable is required, optional, or has a concrete default — as a first-class public API.

Public API additions:

  • EnvVarDefault sealed trait: Required, Optional, Value(str)
  • EnvVar case class: name, metavar, help, default
  • Help.envVars(command): List[EnvVar]

Internal changes:

  • Replace collectEnvOptions + EnvOptionHelp with collectEnvVars, which carries inheritedDefault through OrElse/App/Validate to infer defaults from withDefault / orNone
  • environmentVarHelpLines unified to use collectEnvVars; --help now shows: LOG_LEVEL= Log level (default: INFO) CACHE_TTL= Cache TTL in seconds (optional)
  • deduplicateEnvVars helper is Scala 2.12-compatible (no List.distinctBy)

Motivation: Wanting to enumerate env vars and their defaults. This exposes a stable public API.

Expose environment variable metadata — including whether each variable is
required, optional, or has a concrete default — as a first-class public API.

Public API additions:
- EnvVarDefault sealed trait: Required, Optional, Value(str)
- EnvVar case class: name, metavar, help, default
- Help.envVars(command): List[EnvVar]

Internal changes:
- Replace collectEnvOptions + EnvOptionHelp with collectEnvVars, which
  carries inheritedDefault through OrElse/App/Validate to infer defaults
  from withDefault / orNone
- environmentVarHelpLines unified to use collectEnvVars; --help now shows:
      LOG_LEVEL=<string>
          Log level (default: INFO)
      CACHE_TTL=<integer>
          Cache TTL in seconds (optional)
- deduplicateEnvVars helper is Scala 2.12-compatible (no List.distinctBy)

Motivation: Wanting to enumerate env vars and their
defaults. This exposes a stable public API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant