- 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 property that doesn't exist will create an empty
Config(). - Clean up stranded empty
Configs withdelete_empty!(::Config).
c = Config()
c.one.two.three.four.five.six == Config()
# Internally we make the assumption that empty Config's shouldn't be there.
# Some functions will therefore call `delete_empty!` under the hood:
isempty(c) == true