bitwalker / toml-elixir

An implementation of TOML for Elixir projects, compliant with the latest specification
Apache License 2.0
202 stars 24 forks source link

How to access toml-values with iex -S mix #18

Closed tomece closed 5 years ago

tomece commented 5 years ago

With mix distillery.release I can access values from toml-config file, but how can I access them when I start with iex -S mix (it is only during development, but it would be cool to have a consistent development environment)

when I use your example I get:

** (SyntaxError) config/config.exs:3: syntax error before: config_provider

bitwalker commented 5 years ago

Not sure if you've already found the answer to your question, but could you clarify what example you are following that produces that error?

In general, there isn't an automatically convenient way to use the TOML configs in dev, at least not without doing some work in the shell to load the config. The simple way is to just use config = Toml.Provider.init(opts), then take the result of that and pass it to Toml.Provider.load(config, opts). You'd need to make sure your options match more or less what you use in your release, but that's trivial. This can also be further automated using your .iex.exs file, or even by just invoking those APIs in your Mix config file (i.e. config/config.exs). Typically though, I just use Mix config files in dev, and the TOML configs in releases, and do some testing before deployment to make sure I haven't missed any configuration.