runtimer 0.1.0

Application runtime configuration for applications built in the D programming language.


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:

Runtimer

Application runtime configuration for applications built in the D programming language.

Getting Started

Import runtimer

import runtimer;

Write a struct that maps to a JSON object.

struct App
{
    short port;
    string hostname;
}

New up the configuration class inside of main. You can skip args if you don't want to be able to override the configuration from the command line. Finally, call initialize to have runtimer read in the configuration from disk.

void main(string[] args)
{
	auto configuration = new Configuration!(App)(args);
	configuration.initialize();
}

That will read in a configuration file from the root of the project called configuration.json that looks like this:

{
  "environment-path": "configuration",
  "default-environment": "development"
}

configuration.json specifies the default configuration and the path of all of the configurations. The actual configurations can be whatever you want. Here is an example with port and hostname.

configuration/development.json
{
  "port": 3000,
  "hostname": "127.0.0.1"
}
configuration/test.json
{
  "port": 80,
  "hostname": "192.168.1.300"
}

Now you can run the default-environment with

dub

Or you can specify which configuration to use like this:

dub -- --environment test

An environment can be specified with --environment or -e. A path can be specified with --path or -p

Without dub you can pass in configurations as arguments to the compiled binary as well.

Compiling and Running Tests

Compile runtimer with dub by simply running

dub  

Run the tests with dub by simply running

dub test

See LICENSE

Authors:
  • Chris Barnes
Dependencies:
vibe-d:data
Versions:
0.1.0 2016-Jan-18
~master 2016-Apr-23
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 128 downloads total

Score:
0.7
Short URL:
runtimer.dub.pm