Moved check for the existance of the substitution file from
loadSubstitutionFile to main
This commit is contained in:
parent
d657873f9f
commit
99d36745eb
2 changed files with 10 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
||||||
import std.array : array, replace;
|
import std.array : array, replace;
|
||||||
import std.datetime : Clock;
|
import std.datetime : Clock;
|
||||||
|
import std.file : exists, isFile;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
import std.getopt : defaultGetoptPrinter, getopt;
|
import std.getopt : defaultGetoptPrinter, getopt;
|
||||||
import std.json : JSONValue;
|
import std.json : JSONValue;
|
||||||
|
@ -35,8 +36,11 @@ void main(string[] args)
|
||||||
"mode" : "direct",
|
"mode" : "direct",
|
||||||
"type_dm" : "any",
|
"type_dm" : "any",
|
||||||
"itdLPxx_bcl" : "true"]);
|
"itdLPxx_bcl" : "true"]);
|
||||||
|
|
||||||
loadSubstitutionFile(substitutionFileName);
|
if (substitutionFileName.exists && substitutionFileName.isFile)
|
||||||
|
{
|
||||||
|
loadSubstitutionFile(substitutionFileName);
|
||||||
|
}
|
||||||
|
|
||||||
auto currentTime = Clock.currTime;
|
auto currentTime = Clock.currTime;
|
||||||
JSONValue j = ["time" : "%02s:%02s".format(currentTime.hour, currentTime.minute)];
|
JSONValue j = ["time" : "%02s:%02s".format(currentTime.hour, currentTime.minute)];
|
||||||
|
|
|
@ -4,19 +4,11 @@ public:
|
||||||
|
|
||||||
void loadSubstitutionFile(string fileName)
|
void loadSubstitutionFile(string fileName)
|
||||||
{
|
{
|
||||||
import std.file : slurp, exists, isFile;
|
import std.file : slurp;
|
||||||
import std.algorithm.iteration : each;
|
import std.algorithm.iteration : each;
|
||||||
|
auto data = slurp!(string, string)(fileName, `"%s" = "%s"`);
|
||||||
if (fileName.exists && fileName.isFile)
|
map = (string[string]).init;
|
||||||
{
|
data.each!(pair => map[pair[0]] = pair[1]);
|
||||||
auto data = slurp!(string, string)(fileName, `"%s" = "%s"`);
|
|
||||||
map = (string[string]).init;
|
|
||||||
data.each!(pair => map[pair[0]] = pair[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
map = (string[string]).init;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto substitute(string s) @safe nothrow
|
auto substitute(string s) @safe nothrow
|
||||||
|
|
Loading…
Reference in a new issue