From 3b177d47c0db185d325be266644315ca5ab73660 Mon Sep 17 00:00:00 2001 From: Hat Kid <6624576+Hat-Kid@users.noreply.github.com> Date: Sun, 26 Jun 2022 23:32:02 +0200 Subject: [PATCH] goalc: add launch option for executing cmd on startup that keeps repl open (#1561) goalc: add launch option for executing cmd on startup --- goalc/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/goalc/main.cpp b/goalc/main.cpp index cb03801b8c..8498d3c255 100644 --- a/goalc/main.cpp +++ b/goalc/main.cpp @@ -26,11 +26,14 @@ int main(int argc, char** argv) { bool auto_debug = false; bool auto_find_user = false; std::string cmd = ""; + std::string startup_cmd = ""; std::string username = "#f"; int nrepl_port = 8181; CLI::App app{"OpenGOAL Compiler / REPL"}; app.add_option("-c,--cmd", cmd, "Specify a command to run"); + app.add_option("--startup-cmd", startup_cmd, + "Specify a command to run and keep the REPL open afterwards"); app.add_option("-u,--user", username, "Specify the username to use for your user profile in 'goal_src/user/'"); app.add_option("-p,--port", nrepl_port, "Specify the nREPL port. Defaults to 8181"); @@ -124,6 +127,11 @@ int main(int argc, char** argv) { compiler->save_repl_history(); } compiler = std::make_unique(username, std::make_unique()); + if (!startup_cmd.empty()) { + compiler->handle_repl_string(startup_cmd); + // reset to prevent re-executing on manual reload + startup_cmd = ""; + } status = ReplStatus::OK; } std::string input_from_stdin = compiler->get_repl_input();