runtimer ~master
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
Add runtimer to dub.json
and run dub
to fetch the dependencies.
{
...
"dependencies": {
"runtimer": "~>0.1.0"
}
}
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
License and Copyright
See LICENSE
- Registered by Chris Barnes
- ~master released 8 years ago
- chrishalebarnes/runtimer
- The MIT License, see license file
- Copyright © 2016, Chris Barnes
- Authors:
- Dependencies:
- vibe-d:data
- Versions:
-
0.1.0 2016-Jan-18 ~master 2016-Apr-23 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
128 downloads total
-
- Score:
- 0.7
- Short URL:
- runtimer.dub.pm