All Projects → Roger-luo → Configurations.jl

Roger-luo / Configurations.jl

Licence: MIT License
Options & Configurations made easy.

Programming Languages

julia
2034 projects

Configurations

CI codecov Aqua QA Downloads

Configurations & Options made easy.

Installation

Configurations is a   Julia Language   package. To install Configurations, please open Julia's interactive session (known as REPL) and press ] key in the REPL to use the package mode, then type the following command

pkg> add Configurations

Usage

There are more detailed guide in the documentation.

This package provides a macro @option to let you define structs to represent options/configurations, and serialize between different option/configuration file formats such as TOML.

You can easily create hierarchical struct types:

julia> using Configurations

julia> "Option A"
       @option "option_a" struct OptionA
           name::String
           int::Int = 1
       end

julia> "Option B"
       @option "option_b" struct OptionB
           opt::OptionA = OptionA(;name = "Sam")
           float::Float64 = 0.3
       end

and then convert from a Dict to your option type via from_dict:

julia> d = Dict{String, Any}(
           "opt" => Dict{String, Any}(
               "name" => "Roger",
               "int" => 2,
           ),
           "float" => 0.33
       );

julia> option = from_dict(OptionB, d)
OptionB(;
    opt = OptionA(;
        name = "Roger",
        int = 2,
    ),
    float = 0.33,
)

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].