mirror of
https://github.com/mbierlee/mirage-config.git
synced 2024-11-15 04:44:01 +01:00
Use ini in quickstart
is more sexy?
This commit is contained in:
parent
9fa1092e80
commit
52f7ad9cd2
16
README.md
16
README.md
|
@ -25,21 +25,23 @@ import std.stdio : writeln;
|
||||||
import mirage : loadConfig, parseJavaProperties;
|
import mirage : loadConfig, parseJavaProperties;
|
||||||
|
|
||||||
void main() {
|
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");
|
auto config = loadConfig("config.json");
|
||||||
writeln(config.get("application.name"));
|
writeln(config.get("application.name"));
|
||||||
writeln(config.get!long("application.version"));
|
writeln(config.get!long("application.version"));
|
||||||
|
|
||||||
// Or parse directly from string:
|
// Or parse directly from string
|
||||||
auto properties = parseJavaProperties("
|
auto ini = parseIniConfig("
|
||||||
databaseDriver = Postgres
|
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("host"));
|
||||||
writeln(databaseConfig.get("port"));
|
writeln(databaseConfig.get("port"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,24 +10,26 @@ module examples.quickstart.app;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import std.stdio : writeln;
|
import std.stdio : writeln;
|
||||||
import mirage : loadConfig, parseJavaProperties;
|
import mirage : loadConfig, parseIniConfig;
|
||||||
|
|
||||||
void main() {
|
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");
|
auto config = loadConfig("config.json");
|
||||||
writeln(config.get("application.name"));
|
writeln(config.get("application.name"));
|
||||||
writeln(config.get!long("application.version"));
|
writeln(config.get!long("application.version"));
|
||||||
|
|
||||||
// Or parse directly from string:
|
// Or parse directly from string
|
||||||
auto properties = parseJavaProperties("
|
auto ini = parseIniConfig("
|
||||||
databaseDriver = Postgres
|
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("host"));
|
||||||
writeln(databaseConfig.get("port"));
|
writeln(databaseConfig.get("port"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue