Skip to content

feat(Config): Add env-var prefix factory + Argu.MSConfig companion#308

Open
dimension-zero wants to merge 3 commits into
fsprojects:masterfrom
dimension-zero:pr/20-env-and-iconfig-readers
Open

feat(Config): Add env-var prefix factory + Argu.MSConfig companion#308
dimension-zero wants to merge 3 commits into
fsprojects:masterfrom
dimension-zero:pr/20-env-and-iconfig-readers

Conversation

@dimension-zero
Copy link
Copy Markdown
Contributor

feat(Config): Add env-var prefix factory + Argu.MSConfig companion

  • ConfigReaders.fs: New static member
    ConfigurationReader.FromEnvironmentVariables(prefix : string) that
    reads env vars with a fixed prefix prepended to the key. Composed
    from the existing EnvironmentVariableConfigurationReader via the
    existing FunctionConfigurationReader, so no new types in core.
    Existing FromEnvironmentVariables() is untouched.
  • New project src/Argu.MSConfig: thin adapter exposing any
    Microsoft.Extensions.Configuration.IConfiguration as an Argu
    IConfigurationReader. Lives in its own NuGet package so the core
    stays zero-dep on Microsoft.Extensions.*.
  • Directory.Packages.props: centrally-managed pin for
    Microsoft.Extensions.Configuration.Abstractions 8.0.0.
  • Argu.sln: register the new project under the existing F# tooling
    configuration.

test(EnvVarPrefix): Add coverage for FromEnvironmentVariables(prefix)

4 new tests:

  • FromEnvironmentVariables(prefix) prepends the prefix to the requested
    key, so reader.GetValue('HOST') reads env var MYAPP_HOST.
  • Missing keys come back as null (Argu's standard contract).
  • Round-trip through ArgumentParser.ParseConfiguration: a schema using
    CustomAppSettings keys is populated correctly when only the prefixed
    env vars are set.
  • No-arg FromEnvironmentVariables() is still functional (the new
    overload doesn't shadow the legacy one).

Net suite size on this branch: 112 -> 116.


dimension-zero and others added 3 commits May 23, 2026 18:03
* ConfigReaders.fs: New static member
  ConfigurationReader.FromEnvironmentVariables(prefix : string) that
  reads env vars with a fixed prefix prepended to the key. Composed
  from the existing EnvironmentVariableConfigurationReader via the
  existing FunctionConfigurationReader, so no new types in core.
  Existing FromEnvironmentVariables() is untouched.
* New project src/Argu.MSConfig: thin adapter exposing any
  Microsoft.Extensions.Configuration.IConfiguration as an Argu
  IConfigurationReader. Lives in its own NuGet package so the core
  stays zero-dep on Microsoft.Extensions.*.
* Directory.Packages.props: centrally-managed pin for
  Microsoft.Extensions.Configuration.Abstractions 8.0.0.
* Argu.sln: register the new project under the existing F# tooling
  configuration.
4 new tests:
* FromEnvironmentVariables(prefix) prepends the prefix to the requested
  key, so reader.GetValue('HOST') reads env var MYAPP_HOST.
* Missing keys come back as null (Argu's standard contract).
* Round-trip through ArgumentParser.ParseConfiguration: a schema using
  CustomAppSettings keys is populated correctly when only the prefixed
  env vars are set.
* No-arg FromEnvironmentVariables() is still functional (the new
  overload doesn't shadow the legacy one).

Net suite size on this branch: 112 -> 116.
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