add project path option to the compiler (#1826)

This commit is contained in:
tripp
2022-09-24 12:06:26 -04:00
committed by GitHub
parent dc5dc9c76c
commit 66b19296ef
+15 -3
View File
@@ -30,6 +30,7 @@ int main(int argc, char** argv) {
std::string username = "#f";
std::string game = "jak1";
int nrepl_port = 8181;
fs::path project_path_override;
CLI::App app{"OpenGOAL Compiler / REPL"};
app.add_option("-c,--cmd", cmd, "Specify a command to run");
@@ -45,15 +46,26 @@ int main(int argc, char** argv) {
app.add_flag("--user-auto", auto_find_user,
"Attempt to automatically deduce the user, overrides '-user'");
app.add_option("-g,--game", game, "The game name: 'jak1' or 'jak2'");
app.add_option("--proj-path", project_path_override,
"Specify the location of the 'data/' folder");
app.validate_positionals();
CLI11_PARSE(app, argc, argv);
if (!file_util::setup_project_path(std::nullopt)) {
GameVersion game_version = game_name_to_version(game);
if (!project_path_override.empty()) {
if (!fs::exists(project_path_override)) {
lg::error("Error: project path override '{}' does not exist", project_path_override.string());
return 1;
}
if (!file_util::setup_project_path(project_path_override)) {
lg::error("Could not setup project path!");
return 1;
}
} else if (!file_util::setup_project_path(std::nullopt)) {
return 1;
}
GameVersion game_version = game_name_to_version(game);
if (auto_find_user) {
username = "#f";
std::regex allowed_chars("[0-9a-zA-Z\\-\\.\\!\\?<>]");