Machine-specific config for elixir CLI - what's a good convention?

Howdy folks,

I’m creating an elixir CLI to automate some release management tasks commonly performed internally in our engineering teams.

In addition to passing this CLI around, I’d also like some things to be configurable different from engineer to engineer, such as location of the directory where all repos should be cloned to or found (this CLI does things like clone all our microservices and apps, process commands across all of them - local environment maintenance and release preparation type activities).

I started by going down the road of saying that every engineer will have a yaml file in his home directory such as “.whateverrc”, and I read and parse all engineer-specific config values from there.

Is there a better practice in the elixir or erlang world?

As much as I despise YAML, that’s a reasonable solution if the engineers aren’t Elixir savy. If they are it’s pretty simple to copy the iex model and have a .iex.exs file of Elixir code that you import at runtime.

In general, the practice with Elixir CLI tools like iex and mix is that the configuration files are Elixir code with the .exsextension to differentiate runtime code vs compiled code. Only you can know if that’s a bridge too far for your users.

Hey- thanks! I didn’t realize that distinction. Perhaps I’ll refactor to pull in a .exs at runtime.

Here’s a follow-up - say I only want to pull in that YAML or exs file once during the runtime of the CLI command that is kicked off, but have a number of items in there needed by different modules.

What’s a conventional way to make sure the file is only read once and kept around for reference?

There are two things I’ve seen.

  1. Write stuff into a options map that you pass down through your all your functions.

  2. Store the info in an ETS table. See