Skip to content

feat: accept snake_case environment variable names - #302

Closed
Brian Gordon Davis (bgdnext64) wants to merge 1 commit into
mainfrom
feat/248-snake-case-env-vars
Closed

feat: accept snake_case environment variable names#302
Brian Gordon Davis (bgdnext64) wants to merge 1 commit into
mainfrom
feat/248-snake-case-env-vars

Conversation

@bgdnext64

Copy link
Copy Markdown
Collaborator

Adds support for snake_case environment variable names in addition to the existing concatenated form, addressing the readability concern raised in the issue.

Previously each flag mapped to a single environment variable built by uppercasing the flag name (for example subscriptionIDMPF_SUBSCRIPTIONID). MPF now also binds a snake_case variant derived from the flag's word boundaries, so MPF_SUBSCRIPTION_ID and MPF_SP_CLIENT_SECRET work too.

Details:

  • Added camelCaseToSnakeUpper, which splits a camelCase flag name on word/acronym boundaries (e.g. subscriptionIDSUBSCRIPTION_ID, spClientIDSP_CLIENT_ID).
  • bindFlags now explicitly binds each viper key to both the legacy concatenated env var and the snake_case env var, so existing setups keep working with no change. When both are set, the concatenated form takes precedence.
  • Documented the alias behavior in the command-line flags reference.

Tests:

  • TestCamelCaseToSnakeUpper covers the conversion across all global flags.
  • TestBindEnvVars verifies both the legacy and snake_case forms resolve correctly, with per-subtest isolation from any pre-existing MPF_* variables.

Fixes #248

@maniSbindra

Copy link
Copy Markdown
Contributor

Hi Brian Gordon Davis (@bgdnext64) PR #298 addresses the same issue. Closing this issue

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.

Feature Request: Support snake_case environment variable names in addition to current format

2 participants