Simple application configuration for Julia
Julia
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src Added support for tuples. Feb 13, 2016
test Add a test case that reads tuples. Feb 13, 2016
.travis.yml Fix package on 0.3 Dec 17, 2015
LICENSE Initial commit Jul 30, 2015
README.md Update README.md May 4, 2016
REQUIRE Fix on 0.3 by using Compat Oct 17, 2015

README.md

AppConf.jl

Build Status

A simple configuration module for Julia applications. Implements a basic syntax for a configuration file, and manages an environment variable JULIA_ENV to manage code differences for development and production environments.

Basic Configuration

When using AppConf, call parseconf with a path to your configuration file to load it.

using AppConf

parseconf("app.conf")

Where app.conf contains basic name-value pairs:

log.level=DEBUG
app.secret="provoke-dance-surveillance-friend"
session.timeout=60
require.auth=false

Then, the global variable conf will be a dictionary populated with those items.

julia> conf
Dict{AbstractString,Any} with 4 entries:
  "require.auth"    => false
  "app.secret"      => "provoke-dance-surveillance-friend"
  "log.level"       => "DEBUG"
  "session.timeout" => 60

Supported Values

Values will be interpreted as strings or numbers based on their structure. Strings can optionally be in double quotes. Arrays are also supported with the following syntax:

arr=["one", 2, three]

Is parsed into:

Dict{AbstractString,Any}("arr" => Any["one",2,"three"])

Using JULIA_ENV

The variable JULIA_ENV is set to "dev" by default. It can be overridden by setting its value in the system environment, or by setting env in the config file. The macros @dev and @prod allow code blocks to be specified to compile in only one environment.

@dev begin
  println("I'm on your laptop")
end
@prod begin
  println("I'm on your server")
end

TODO

Support full HOCON syntax to emulate TypeSafe config library.