From 66b19296ef2535761cf5b7201b6b8d1b50f73add Mon Sep 17 00:00:00 2001 From: tripp <86533397+trippjoe@users.noreply.github.com> Date: Sat, 24 Sep 2022 12:06:26 -0400 Subject: [PATCH] add project path option to the compiler (#1826) --- goalc/main.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/goalc/main.cpp b/goalc/main.cpp index 4dd6cdd2cd..a5e0571fd0 100644 --- a/goalc/main.cpp +++ b/goalc/main.cpp @@ -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\\-\\.\\!\\?<>]");