Reading the configuration file https://code.dlang.org/packages/readconf
Go to file
Alexander Zhirov 8dbdea7331 Merge pull request 'dev' (#1) from dev into master
Reviewed-on: #1
2023-03-26 08:38:22 +00:00
img v0.2.0 2023-03-26 11:36:45 +03:00
source ready for testing 0.1.7 2023-03-26 02:35:08 +03:00
tests testing passed successfully 2023-03-26 03:26:31 +03:00
.gitignore v0.1.0 2023-03-24 02:26:02 +03:00
CHANGELOG.md changelog 2023-03-26 04:00:06 +03:00
LICENSE add license 2023-03-23 18:16:40 +03:00
README.md changelog 2023-03-26 04:00:06 +03:00
dub.json v0.2.0 2023-03-26 11:36:45 +03:00
dub.selections.json v0.1.0 2023-03-24 02:26:02 +03:00
dub.settings.json v0.0.1 2023-03-23 18:10:56 +03:00

README.md

readconf

Singleton for reading the configuration file required for your program.

What can do

  1. Separation of parameter and value by separators = and =>
  2. Commenting on lines using special characters ;, #, //, /*
  3. Support for sections for describing parameter blocks (sections are set by the name in [])
  4. Support for spaces and tabs for visual separation

Quick start

The settings.conf file (see the tests):

matches.png

Read settings.conf file:

import readconf;
import std.stdio;

void main()
{
    rc.read("./settings.conf");

    foreach (key, param; rc.sn.keys())
        writefln("%s => %s", key, param);

    writeln(rc.sn.key("value1"));

    foreach (key, param; rc.sn("part2").keys())
        writefln("%s => %s", key, param);

    writeln(rc.sn("part2").key("value1"));
}

Result:

value1 => text without quotes
value2 => Yes!
value3 => value in apostrophes
value4 => 1000
value5 => 0.000
value7 => //path
value8 => "Hey!"
text without quotes
value1 => this value will be in the new section
value3 => good value!
this value will be in the new section

Dub

Add a dependency on "readconf": "~>0.2.0"