glm_stackable_config
gleam add glm_stackable_config
import glm_stackable_config as gsc
import tom
pub fn main() -> Nil {
// merge config3 onto config2 onto config1
use wibble_toml <- result.try({
"config1.toml"
|> tom.parse
|> gsc.merge(tom.parse("config2.toml")) // config2 values overwrite config1
|> gsc.merge(tom.parse("config3.toml")) // config3 values overwrite config2
})
// TODO: provide better examples
// define some cool base configs and then
// reference them in subsequent configs
use base <- result.try(tom.parse("base.toml"))
use wobble_toml <- result.try({
gsc.rebase(base, tom.parse("configX.toml"))
})
// now either transform the toml into a gleam record, or use
// it directly via tom.get_{int|float|string|bool}() functions.
// see tests for further use cases
}
Further documentation can be found at https://glm-stackable-config.hexdocs.pm/.
Development
gleam run # Run the project
gleam test # Run the tests