33int main(
int argc,
char* argv[])
36 argparse::ArgumentParser program(
"jaffar",
"2.0.0");
38 program.add_argument(
"configFile").help(
"path to the Jaffar configuration script (.jaffar) file to run.").required();
39 program.add_argument(
"--dryRun").help(
"Only check for configuration without initializing or running the engine").default_value(
false).implicit_value(
true);
44 program.parse_args(argc, argv);
46 catch (
const std::runtime_error& err)
48 JAFFAR_THROW_LOGIC(
"%s\n%s", err.what(), program.help().str().c_str());
52 const std::string configFile = program.get<std::string>(
"configFile");
55 const bool isDryRun = program.get<
bool>(
"--dryRun");
60 if (isDryRun) setenv(
"JAFFAR_IS_DRY_RUN",
"1", 1);
63 jaffarCommon::logger::log(
"[J+] Loading script file: '%s'\n", configFile.c_str());
66 std::string configFileString;
67 if (jaffarCommon::file::loadStringFromFile(configFileString, configFile) ==
false)
68 JAFFAR_THROW_RUNTIME(
"[ERROR] Could not find or read from Jaffar config file: %s\n%s \n", configFile.c_str(), program.help().str().c_str());
71 nlohmann::json config;
74 config = nlohmann::json::parse(configFileString);
76 catch (
const std::exception& err)
78 JAFFAR_THROW_LOGIC(
"[ERROR] Parsing configuration file %s. Details:\n%s\n", configFile.c_str(), err.what());
87 jaffarCommon::logger::log(
"[J+] Finished dry run successfully.\n");
95 auto exitReason = d->run();
98 std::string exitReasonString;
104 exitReasonString =
"Input-history trie neared its hard memory ceiling (use Type \"Raw\" or a smaller State DB).";
107 auto finalStep = d->getCurrentStep();
110 jaffarCommon::logger::log(
"[J+] Step %lu - Exit Reason: %s\n", finalStep, exitReasonString.c_str());