aedi-property-reader 0.2.0
Aedi property reader, a library for reading configuration properties from multiple sources.
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:
This package provides sub packages which can be used individually:
aedi-property-reader:core - Core interfaces and components for aedi property reader
aedi-property-reader:arg - Command line argument locator and factory.
aedi-property-reader:env - Evnironment locator and factory
aedi-property-reader:json - Json document locator and factory
aedi-property-reader:sdlang - sdlang document loader and factory
aedi-property-reader:yaml - yaml document loader and factory
aedi-property-reader:xml - Xml document locator and factory
aedi-property-reader:properd - ini document loader and factory based on properd library
Aedi property reader, a configuration reader
Aedi property reader is a library for loading config properties from various sources, like xml, json, yaml, or sdlang.
Features
- Simple - Init container, define properties, use it.
- Powerful - Hierarchical organization of multiple files.
- Flexible - Supports multiple config formats and sources.
- Smart - Uses document syntax to guess D types for properties.
Installation
Add Aedi property reader as a dependency to a dub project:
Json configuration:
"aedi-property-reader": "~>0.2.0"
SDL configuration:
dependency "aedi-property-reader" version="~>0.2.0"
Quickstart
Aedi property reader provides an unified interface for reading config properties out of a multitude of sources. It is able to read configuration out of following sources:
- command line
- environment
- xml
- json
- sdlang
- yaml
- java like property files
To use aedi property reader to load configuration following steps are required:
- Create a property container out of a string or a file in specified format
- Define config properties to be read from source
- Use properties from config container
The example below shows the simplest use case presented in steps above:
module app;
import std.stdio;
import aermicioi.aedi;
import aermicioi.aedi_property_reader;
void properties(T : ConvertorContainer!(FromType, ToType), FromType, ToType)(T container) {
with (container.configure) { // Create a configuration context for config container
register!string("protocol"); // Define `protocol` property of type `string`
register!string("host");
register!string("resource");
register!ushort("port");
register!(string[string])("arguments"); // Define `arguments` property of type `string[string]`
register!(size_t[])("nope-an-array");
}
}
auto load() {
auto cont = json("config.json");
cont.properties();
return cont;
}
void main()
{
auto cont = load(); // Initialize config container
writeln("Dumping network connection information:");
writeln("Protocol: ", cont.locate!string("protocol")); // Write property found in configuration
writeln("Host: ", cont.locate!string("host"));
writeln("Port: ", cont.locate!ushort("port"));
writeln("Arguments: ", cont.locate!(string[string])("arguments")); // Write property found in configuration
writeln("nope-an-array: ", cont.locate!(size_t[])("nope-an-array"));
}
The output of example, will yield following answers:
Dumping network connection information:
Protocol: http
Host: host.io
Port: 8080
Arguments: ["pass":"json.weak-pass", "user":"json.bold-logic"]
nope-an-array: [6, 5, 4, 3, 2, 1]
Documentation
All public api documentation is available on aermicioi.github.io/aedi-property-reader/.
- Registered by Alexandru Ermicioi
- 0.2.0 released 6 years ago
- aermicioi/aedi-property-reader
- BSL-1.0
- Sub packages:
- aedi-property-reader:core, aedi-property-reader:arg, aedi-property-reader:env, aedi-property-reader:json, aedi-property-reader:sdlang, aedi-property-reader:yaml, aedi-property-reader:xml, aedi-property-reader:properd
- Dependencies:
- aedi-property-reader:properd, aedi-property-reader:sdlang, aedi-property-reader:yaml, aedi-property-reader:arg, aedi-property-reader:xml, aedi-property-reader:env, aedi-property-reader:json
- Versions:
-
0.2.0 2018-Jun-21 0.1.0 2017-Aug-20 ~master 2019-Feb-26 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
159 downloads total
-
- Score:
- 0.4
- Short URL:
- aedi-property-reader.dub.pm