hummus 0.1.9-alpha

Pluggable configuration engine


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

hummus

Easy template-enabled configuration engine

DUB DUB DUB D Coverage Status

Usage

Below is an example of how we can use a provider to fill up the values within a complex data structure:

import  hummus.cfg : fill;
import std.stdio : writeln;

struct X
{
    private string p;
}

struct A
{
    private int x, y;
    private X z;
}

struct MinhaConfiguracao
{
    private string adres;
    private size_t porto;
    private A s;
}

auto mc = MinhaConfiguracao();

auto ds = new DummySink();
fill(mc, ds);

// show how the struct was filed
// up
writeln(mc);

// check values and make sure
// everything is there as
// expected
assert(mc.porto == 443);
assert(mc.s.x == 10);
assert(mc.s.y == -10);

Right at the end we can see how all the values would have been filled out when we did writeln(mc):

MinhaConfiguracao("v:adres", 443, A(10, -10, X("v:s.z.p")))

Providers

If you want to implement a provider then take a look at the documentation so you can see what you would need to implement.

The providers that come with this package are:

  1. EnvironmentProvider
  • This uses environment variables to provision
  • Module name is hummus.providers.env
  1. JSONProvider
  • This uses a JSON file to provision
  • Module name is hummus.providers.json

EnvironmentProvider

A name like root.a will be translated to a search for an environment variable named ROOT__A.

Development

Testing

In order to run the full test suite use the following command:

V=1 I__Z=2 dub test

The reason for the declaration of the environment variables V=1 I__Z=2 is because onfe of the tests is for the EnvironmentProvider which searches for environment variables, and in particular its unittest looks for those two.

License

Licensed under the LGPL-2.0-only .

Authors:
  • Tristan Brice Velloza Kildaire
Dependencies:
niknaks
Versions:
0.1.10-alpha 2025-Jun-30
0.1.9-alpha 2025-Jun-30
0.1.8-alpha 2025-Jun-30
0.1.7-alpha 2025-Jun-30
0.1.6-alpha 2025-Jun-30
Show all 19 versions
Download Stats:
  • 15 downloads today

  • 29 downloads this week

  • 29 downloads this month

  • 29 downloads total

Score:
0.5
Short URL:
hummus.dub.pm