LangBuilder/src/main.cpp

39 lines
1.2 KiB
C++

#include <filesystem>
#include <iostream>
#include "../extern/argparse.hpp"
#include "LocalizationData.hpp"
int main(int argc, const char* argv[]) {
argparse::ArgumentParser parser("example", "Argument parser example");
parser.add_argument("-p", "--path", "path", false).description("Base path of the data files for the language.");
parser.add_argument("-o", "--output", "output", false).description("Output file for language file.");
parser.enable_help();
auto err = parser.parse(argc, argv);
if (err) {
std::cout << err << std::endl;
return -1;
}
if (parser.exists("help")) {
parser.print_help();
return 0;
}
auto path = std::filesystem::current_path();
if (parser.exists("path")) {
path = parser.get<std::string>("path");
}
std::cout << "Building localization file from path " << path << "." << std::endl;
LocalizationData data;
data.LoadFromPath(path);
std::filesystem::path outFile;
if (parser.exists("output")) {
outFile = parser.get<std::string>("output");
} else {
outFile = path / data.GetCode();
outFile.replace_extension("l10n");
}
data.WriteToFile(outFile);
return 0;
}