Go to file
2022-10-13 02:19:59 +03:00
docs Add autogenerated documentation 2022-10-09 01:10:05 +03:00
examples Play around with examle properties a bit 2022-10-13 01:10:44 +03:00
source/mirage Add java load aliases for the unaware 2022-10-13 01:59:06 +03:00
testfiles Add INI config factory 2022-10-13 01:56:27 +03:00
.gitignore Add autogenerated documentation 2022-10-09 01:10:05 +03:00
CHANGES.md Add changelog 2022-10-09 00:22:34 +03:00
dub.json Tweak package description 2022-10-13 02:19:59 +03:00
dub.selections.json Rename project to detach it from Poodinis 2022-09-24 17:04:57 +03:00
LICENSE.txt Add project skeleton 2022-09-23 23:34:22 +03:00
makefile Add make step for building docs 2022-10-09 01:07:34 +03:00
README.md Tweak readme 2022-10-13 02:12:27 +03:00
TODO.md Add java load aliases for the unaware 2022-10-13 01:59:06 +03:00

Mirage Config

Version 0.0.0
Copyright 2022 Mike Bierlee
Licensed under the terms of the MIT license - See LICENSE.txt

DUB Package

Toolkit for loading and using application configuration from various formats.

Features:

  • Load from various file formats such as JSON, INI and Java properties (see Formats);
  • Environment variable substitution;
  • Internal configuration substitution (Value in config replaced by other path in config);
  • Parse configuration from string or JSONValue instead of from disk.

Getting started

DUB Dependency

See the DUB project page for instructions on how to include Mirage Config into your project.

Quickstart

import std.stdio : writeln;
import mirage : loadConfig, parseJavaProperties;

void main() {
    // Load configuration from file (see examples/quickstart/config.json):
    auto config = loadConfig("config.json");
    writeln(config.get("application.name"));
    writeln(config.get!long("application.version"));

    // Or parse directly from string:
    auto properties = parseJavaProperties("
        databaseDriver = Postgres
        database.host = localhost
        database.port = 5432
    ");

    auto databaseConfig = properties.getConfig("database");

    writeln(properties.get("databaseDriver"));
    writeln(databaseConfig.get("host"));
    writeln(databaseConfig.get("port"));
}

More formats are available (see Formats.)
For more details and examples, see the examples directory.

Formats

The following file formats are currently supported:

Format Extension Import* Loader Parser Factory
any below any below mirage loadConfig** (N/A)
JSON .json mirage.json loadJsonConfig parseJsonConfig*** JsonConfigFactory
Java .properties mirage.java loadJavaProperties parseJavaProperties JavaPropertiesFactory
INI .ini mirage.ini loadIniConfig parseIniConfig IniConfigFactory

* Any loader or parser can be imported from the mirage package since they are all publicly imported.
** Loads files based on their extension. If the file does not use one of the extensions in the table, you must use a specific loader.
*** Besides parsing strings like the other formats, it also accepts a JSONValue.

Documentation

You can generate documentation from the source code using DUB:

dub build --build=ddox

The documentation can then be found in docs/

History

For a full overview of changes, see CHANGES.md

Contributing

Any and all pull requests are welcome! If you (only) want discuss changes before making them, feel free to open an Issue on github. Please develop your changes on (a branch based on) the develop branch. Continuous integration is preferred so feature branches are not neccessary.