#include #include #include #include "../extern/args.hpp" #include "BuildData/BuildLibrary.hpp" #include "Globals.hpp" #include "Tester/AngelScript/BattleFunctions.hpp" #include "Tester/AngelScript/MiscMockFunctions.hpp" #include "Tester/AngelScript/TestFunctions.hpp" #include "Tester/TestRunner.hpp" int main(int argc, char** argv) { args::ArgumentParser parser("PkmnLib Script Tester.", ""); args::HelpFlag help(parser, "help", "Display this help menu", {'h', "help"}); std::string workingDirectory; args::HelpFlag helpFlag(parser, "help", "Display this help menu", {'h', "help"}); args::ValueFlag workingDirFlag(parser, "Working Directory", "Which work directory to use.", {"workdir"}); try { parser.ParseCLI(argc, argv); } catch (args::Help&) { std::cout << parser; return 0; } catch (args::ParseError& e) { std::cerr << e.what() << std::endl; std::cerr << parser; return 1; } catch (args::ValidationError& e) { std::cerr << e.what() << std::endl; std::cerr << parser; return 1; } if (workingDirFlag) { workingDirectory = args::get(workingDirFlag); } if (!workingDirectory.empty()) { chdir(std::filesystem::path(workingDirectory).c_str()); } std::function initialize = [](PkmnLib::Battling::ScriptResolver* resolver) { auto* scriptResolver = dynamic_cast(resolver); scriptResolver->DefineWord("TESTS"); TestFunctions::Register(scriptResolver); BattleFunctions::Register(scriptResolver); MiscMockFunctions::Register(scriptResolver); }; Globals::Library = BuildLibrary::Build("", initialize); if (!Globals::Library.HasValue()) { return 1; } auto* scriptResolver = dynamic_cast(Globals::Library.GetValue()->GetScriptResolver().get()); auto testRunner = TestRunner(scriptResolver); auto* engine = scriptResolver->GetBuilder().GetEngine(); return testRunner.RunAll(engine); }