Skip to content
Reads from, and writes to, an Erlang config file. Get (and set) a section of the file by providing a list of keys.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
config_parser.erl
sample.config
sample_usage.erl

README.md

config_parser.erl

I spent a couple days figuring out how to read in an Erlang config file and modify it, using Erlang (specifically, an escript.. but that doesn't really matter). It was annoying. Maybe this'll help someone else out!

There are only 4 functions:

  • read_terms: Takes a filename and uses file:consult to return the contents of a file with Erlang terms in it.
  • write_terms: Takes a filename, and uses file:write_file to write updated terms back out to it.
  • get_nested_terms: Takes a list of keys, and drills down into the value returned by read_terms, so you can update a specific section of Erlang terms.
  • set_nested_terms: Takes the same list of keys, the terms you updated, and the original full list of terms, and saves everything back in the proper place so you can pass it to write_terms.

There's a sample config file and erl module, which you can compile and call its functions to see how it affects the config file.

Issues?

If you have a problem, question, issue - better way to do something! - just let me know.

You can’t perform that action at this time.