From 52f7ad9cd2aee470f224377036a1ac38cdfd1a4b Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Thu, 13 Oct 2022 21:37:12 +0300 Subject: [PATCH] Use ini in quickstart is more sexy? --- README.md | 16 +++++++++------- examples/quickstart/app.d | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3d23c8e..a91390b 100644 --- a/README.md +++ b/README.md @@ -25,21 +25,23 @@ import std.stdio : writeln; import mirage : loadConfig, parseJavaProperties; void main() { - // Load configuration from file (see examples/quickstart/config.json): + // Load configuration from file (see examples/quickstart/config.json) auto config = loadConfig("config.json"); writeln(config.get("application.name")); writeln(config.get!long("application.version")); - // Or parse directly from string: - auto properties = parseJavaProperties(" + // Or parse directly from string + auto ini = parseIniConfig(" databaseDriver = Postgres - database.host = localhost - database.port = 5432 + + [database] + host = localhost + port = 5432 "); - auto databaseConfig = properties.getConfig("database"); + auto databaseConfig = ini.getConfig("database"); - writeln(properties.get("databaseDriver")); + writeln(ini.get("databaseDriver")); writeln(databaseConfig.get("host")); writeln(databaseConfig.get("port")); } diff --git a/examples/quickstart/app.d b/examples/quickstart/app.d index 4949d65..d2c8209 100644 --- a/examples/quickstart/app.d +++ b/examples/quickstart/app.d @@ -10,24 +10,26 @@ module examples.quickstart.app; */ import std.stdio : writeln; -import mirage : loadConfig, parseJavaProperties; +import mirage : loadConfig, parseIniConfig; void main() { - // Load configuration from file (see examples/quickstart/config.json): + // Load configuration from file (see examples/quickstart/config.json) auto config = loadConfig("config.json"); writeln(config.get("application.name")); writeln(config.get!long("application.version")); - // Or parse directly from string: - auto properties = parseJavaProperties(" + // Or parse directly from string + auto ini = parseIniConfig(" databaseDriver = Postgres - database.host = localhost - database.port = 5432 + + [database] + host = localhost + port = 5432 "); - auto databaseConfig = properties.getConfig("database"); + auto databaseConfig = ini.getConfig("database"); - writeln(properties.get("databaseDriver")); + writeln(ini.get("databaseDriver")); writeln(databaseConfig.get("host")); writeln(databaseConfig.get("port")); }