FsConfig icon indicating copy to clipboard operation
FsConfig copied to clipboard

Consecutive defaults

Open Slesa opened this issue 2 years ago • 1 comments

When working with configurations, sometimes they get overwritten depending on the origin. The order of the defaulting is discussable, but I think it is

  • read environment vars
  • read configuration file 1, maybe from server
  • read local configuration file
  • read arguments

and of course starting with settings that the programmer considers perfect as defaults.

type Settings { showAsWindow: bool; windowXsize: int; windowYsize: int }
let DefaultSettings = { true; 1024; 768 }

wouldn't it be nice to have a configuration chain like

let setup = DefaultSettings
|> EnvConfig.Get<Settings>
|> IniConfig.Get<Settings>
|> ArgConfig.Get<Settings>

Is this possible somehow?

Slesa avatar Feb 03 '23 10:02 Slesa

@Slesa I think you can achieve similar behaviour via IConfigurationRoot/ConfigurationBuilder support. Otherwise I think the lib would require some code changes (PRs welcome) to provide such a composability.

queil avatar Feb 06 '23 08:02 queil