2022-10-08 23:42:15 +02:00
|
|
|
module examples.quickstart.app;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Authors:
|
|
|
|
* Mike Bierlee, m.bierlee@lostmoment.com
|
2023-01-11 00:06:41 +01:00
|
|
|
* Copyright: 2022-2023 Mike Bierlee
|
2022-10-08 23:42:15 +02:00
|
|
|
* License:
|
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* The full terms of the license can be found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import std.stdio : writeln;
|
2022-10-13 20:37:12 +02:00
|
|
|
import mirage : loadConfig, parseIniConfig;
|
2022-10-08 23:42:15 +02:00
|
|
|
|
|
|
|
void main() {
|
2022-10-13 20:37:12 +02:00
|
|
|
// Load configuration from file (see examples/quickstart/config.json)
|
2022-10-08 23:42:15 +02:00
|
|
|
auto config = loadConfig("config.json");
|
|
|
|
writeln(config.get("application.name"));
|
|
|
|
writeln(config.get!long("application.version"));
|
|
|
|
|
2022-10-13 20:37:12 +02:00
|
|
|
// Or parse directly from string
|
|
|
|
auto ini = parseIniConfig("
|
2022-10-08 23:42:15 +02:00
|
|
|
databaseDriver = Postgres
|
2022-10-13 20:37:12 +02:00
|
|
|
|
|
|
|
[database]
|
|
|
|
host = localhost
|
|
|
|
port = 5432
|
2022-10-08 23:42:15 +02:00
|
|
|
");
|
|
|
|
|
2022-10-13 20:37:12 +02:00
|
|
|
auto databaseConfig = ini.getConfig("database");
|
2022-10-08 23:42:15 +02:00
|
|
|
|
2022-10-13 20:37:12 +02:00
|
|
|
writeln(ini.get("databaseDriver"));
|
2022-10-08 23:42:15 +02:00
|
|
|
writeln(databaseConfig.get("host"));
|
|
|
|
writeln(databaseConfig.get("port"));
|
|
|
|
}
|