diff --git a/src/Falco/ConfigBuilder.fs b/src/Falco/ConfigBuilder.fs index ab7757e..c38b381 100644 --- a/src/Falco/ConfigBuilder.fs +++ b/src/Falco/ConfigBuilder.fs @@ -9,14 +9,16 @@ type ConfigFile = | JsonFile of path : string type ConfigBuilderSpec = - { AddEnvVars : bool + { Config : IConfigurationBuilder -> IConfigurationBuilder + AddEnvVars : bool BasePath : string RequiredFiles : ConfigFile list OptionalFiles : ConfigFile list InMemory : Map } static member Empty = - { AddEnvVars = false + { Config = id + AddEnvVars = false BasePath = Directory.GetCurrentDirectory() RequiredFiles = [] OptionalFiles = [] @@ -29,6 +31,8 @@ type ConfigBuilder (args : string[]) = member _.Run(conf : ConfigBuilderSpec) = let mutable bldr = ConfigurationBuilder().SetBasePath(conf.BasePath) + conf.Config bldr |> ignore + for file in conf.RequiredFiles do match file with | IniFile file -> bldr.AddIniFile(file, optional = false, reloadOnChange = true) @@ -53,6 +57,10 @@ type ConfigBuilder (args : string[]) = bldr.Build() :> IConfiguration + [] + member _.Config (conf : ConfigBuilderSpec, fn : IConfigurationBuilder -> IConfigurationBuilder) = + { conf with Config = fn } + /// Sets the base path of the ConfigurationBuilder. [] member _.SetBasePath (conf : ConfigBuilderSpec, basePath : string) =