dconf 0.1.0

Dconf #

Dart package inspired by viper in golang to manage configuration

Why Dconf ? #

When building a modern application, you don’t want to worry about configuration file formats; you want to focus on building awesome software

Dconf provide :

  • Find, load, and unmarshal a configuration file in JSON or YAML formats.
  • Provide an alias system to easily rename parameters without breaking existing code.
  • Automatic binding from environment variable

Putting values #

You can put values in the configuration by simply create a configuration holder object

import 'package:dconf/dconf.dart';

void main() {
	var conf = new Config();
	conf["http.address"] = "localhost";
	conf["http.port"] = "8080";
}

Reading Config Files #

Dconf requires minimal configuration so it knows where to look for config files. Dconf can search multiple paths, but currently a single Dconf instance only supports a single configuration file. Dconf does not default to any configuration search paths leaving defaults decision to an application.

Here is an example of how to use Dconf to search for and read a configuration file. None of the specific paths are required, but at least one path should be provided where a configuration file is expected.

import 'package:dconf/dconf.dart';

void main() {
	var load = new IOLoader();
	load.addPath("./conf"); // Add lookup path
    load.addPath(".");
	var conf = load.load();
}

Register alias #

Aliases permit a single value to be referenced by multiple keys

import 'package:dconf/dconf.dart';

void main() {
	var conf = new Config();
	conf["http.address"] = "localhost";
	conf["http.port"] = "8080";
	conf.alias("server", "http");
	print(conf["server.port"]); // "8080"
}

0.1.0 #

First release of the package

  • Basic Loader to resolve configuration coming from files and ENV
  • Basic Config which handle merge, dot-notation resolver

example/main.dart

import 'package:dconf/dconf.dart';

void main() {
  var load = IOLoader();
  load.addPath("./example");
  var conf = load.load();
  print(conf);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dconf: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dconf/dconf.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Sep 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:dconf/dconf.dart with components: io.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
collection ^1.14.11 1.14.12
path ^1.6.2 1.6.4
yaml ^2.1.15 2.1.16
Transitive dependencies
charcode 1.1.2
meta 1.1.7
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
Dev dependencies
pedantic ^1.0.0
test ^1.5.3