-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
31 lines (28 loc) · 1.09 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#define RAPIDJSON_ASSERT(x)
#include <FlowUtils/FlowJson.h>
#include <FlowUtils/FlowArgParser.h>
#include "FlowRender.h"
#include <chrono>
int main(int argc, char *argv[]) {
FlowArgParser fap;
fap.addIndexOption("template", "Template file", true);
fap.addIndexOption("values", "Values as JSON", true);
fap.parse(argc, argv);
if(!fap.hasRequiredOptions()){
std::cout << "missing parameters";
return EXIT_FAILURE;
}
const auto tmplPath = fap.getString("template");
const auto valuePath = fap.getString("values");
const auto tmpl = FlowFile::fileToString(tmplPath);
const auto values = FlowFile::fileToString(valuePath);
const auto document = FlowJson::parseJson(values);
FlowRender render;
auto start = std::chrono::high_resolution_clock::now();
const std::string result = render.render(tmpl, document);
auto finish = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish - start;
LOG_INFO << "Result:" << std::endl << result;
LOG_INFO << "Duration: " << elapsed.count();
return 0;
}