mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-15 20:26:53 +02:00
getValue() with default return value
This commit is contained in:
parent
eb8d0fe039
commit
f5fc13cbad
11
src/config.d
11
src/config.d
|
@ -40,6 +40,16 @@ final class Config
|
|||
}
|
||||
}
|
||||
|
||||
string getValue(string key, string value)
|
||||
{
|
||||
auto p = key in values;
|
||||
if (p) {
|
||||
return *p;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool load(string filename)
|
||||
{
|
||||
scope(failure) return false;
|
||||
|
@ -65,4 +75,5 @@ unittest
|
|||
auto cfg = new Config("");
|
||||
cfg.load("onedrive.conf");
|
||||
assert(cfg.getValue("sync_dir") == "~/OneDrive");
|
||||
assert(cfg.getValue("empty", "default") == "default");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue