-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.cpp
49 lines (37 loc) · 1.46 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <CLI/CLI.hpp>
#include <chrono>
#include <filesystem>
#include <wmtk/components/run_components.hpp>
#include <wmtk/utils/Logger.hpp>
using json = nlohmann::json;
int main(int argc, char** argv)
{
using path = std::filesystem::path;
CLI::App app{argv[0]};
app.ignore_case();
path json_input_file;
app.add_option("-j, --json", json_input_file, "json specification file")->required(true);
bool is_strict = true;
// app.add_flag("--ns", is_strict, "Disables strict validation of input JSON");
CLI11_PARSE(app, argc, argv);
if (!std::filesystem::exists(json_input_file)) {
wmtk::logger().critical("File `{}` does not exist.", std::string(json_input_file));
return EXIT_FAILURE;
}
json spec_json;
{
std::ifstream f(json_input_file);
if (!f.is_open()) {
wmtk::logger().error("Could not open json file: {}", json_input_file.string());
return EXIT_FAILURE;
}
spec_json = json::parse(f);
}
if (!spec_json.contains("root_path")) spec_json["root_path"] = json_input_file;
const auto start = std::chrono::high_resolution_clock::now();
wmtk::components::run_components(spec_json, is_strict);
const auto stop = std::chrono::high_resolution_clock::now();
const auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start);
wmtk::logger().info("Wildmeshing runtime: {} ms", duration.count());
return EXIT_SUCCESS;
}