PkmnLibTools/src/main.cpp

42 lines
1.7 KiB
C++

#include <iostream>
#include "../extern/args.hpp"
#include "Tools/ScriptCompiler.hpp"
#include "Tools/ScriptHeadersExporter.hpp"
int main(int argc, const char* argv[]) {
args::ArgumentParser parser("PkmnLib tool executable.", "");
args::HelpFlag help(parser, "help", "Display this help menu", {'h', "help"});
args::Group tools(parser, "Tools");
args::Command exportScriptHeaders(tools, "export-script-headers", "Exports the Angelscript script headers");
args::Command compileScripts(tools, "compile-scripts", "Compile the given scripts");
args::ValueFlag<std::string> outPathExportScriptHeaders(exportScriptHeaders, "outpath", "The path to output to.",
{'o'});
args::ValueFlag<std::string> inPathCompileScripts(compileScripts, "inpath", "The path to read scripts from.",
{'i'});
args::ValueFlag<std::string> outPathCompileScripts(compileScripts, "outpath", "The path to output to.", {'o'});
try {
parser.ParseCLI(argc, argv);
} catch (const args::Help&) {
std::cout << parser;
return 0;
} catch (const args::ParseError& e) {
std::cerr << e.what() << std::endl;
std::cerr << parser;
return 1;
}
if (exportScriptHeaders) {
std::string outPathValue = args::get(outPathExportScriptHeaders);
ScriptHeadersExporter::Export(outPathValue);
} else if (compileScripts) {
std::string inPathValue = args::get(inPathCompileScripts);
std::string outPathValue = args::get(outPathCompileScripts);
ScriptCompiler::Compile(inPathValue, outPathValue);
} else {
std::stringstream ss;
return 1;
}
return 0;
}