- EasyConfig provides a friendly-syntax, nested
AbstractDict{Symbol, Any}data structure. - The advantages over other
AbstractDict/NamedTuples are:
- This is quite convenient for working with JSON specs (e.g. PlotlyLight.jl).
c = Config()
c.one.two.three = 1- Compare this to
OrderedDictandNamedTuple:
c = OrderedDict(:one => OrderedDict(:two => OrderedDict(:three => 1)))
c = (one = (two = (three = 1,),),)
c = (; one = (;two = (;three = 1)))- You can use any combination of
String/Symbolwithgetproperty/getindex. - For working interactively,
getpropertyis the most convenient to work with. - For working programmatically,
getindexis the most convenient to work with.
# getproperty
c.one.two.three
# getindex
c[:one][:two][:three]
# mix and match
c["one"].two."three"Create a Config with a NamedTuple-like or block syntax. The following examples create equivalent Configs:
@config (x.one=1, x.two=2, z=3)
@config x.one=1 x.two=2 z=3
@config begin
x.one = 1
x.two = 2
z = 3
end
let
c = Config()
c.x.one = 1
c.x.two = 2
c.z = 3
end- Accessing a non-existent property creates an
Undefined. - This is necessary for assigning deeply nested properties (an eventual
setindex!after nestedgetindex-es).config.a == Undefined(config, [:a]),config.a.b == Undefined(config, [:a, :b]), etc.config.a.b.c = 1==Undefined(config, [:a, :b])[:c] = 1