From e7d307c5ddad5740837bd42b3419f04c39379798 Mon Sep 17 00:00:00 2001 From: Czurko Szabolcs Daniel Date: Thu, 14 Dec 2023 07:02:53 +0100 Subject: [PATCH] engine: Add --output-path to cloe-engine --- engine/src/main.cpp | 8 +++++--- engine/src/main_commands.hpp | 1 + engine/src/main_run.cpp | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/engine/src/main.cpp b/engine/src/main.cpp index 9db2b24ed..081972759 100644 --- a/engine/src/main.cpp +++ b/engine/src/main.cpp @@ -71,16 +71,17 @@ int main(int argc, char** argv) { run->add_option("-u,--uuid", run_options.uuid, "Override simulation UUID") ->envname("CLOE_SIMULATION_UUID"); run->add_flag("--allow-empty", run_options.allow_empty, "Allow empty simulations"); - run->add_flag("--write-output,!--no-write-output", run_options.write_output, + run->add_flag("-w,--write-output,!--no-write-output", run_options.write_output, "Do (not) write any output files") ->envname("CLOE_WRITE_OUTPUT"); + run->add_option("-o,--output-path", run_options.output_path, "Write output to given directory") + ->envname("CLOE_OUTPUT_PATH"); run->add_flag("--progress,!--no-progress", run_options.report_progress, "Do (not) report progress"); run->add_flag("--require-success,!--no-require-success", run_options.require_success, "Require simulation success") ->envname("CLOE_REQUIRE_SUCCESS"); - run->add_flag("--debug-lua", run_options.debug_lua, - "Debug the Lua simulation"); + run->add_flag("--debug-lua", run_options.debug_lua, "Debug the Lua simulation"); run->add_option("--debug-lua-port", run_options.debug_lua_port, "Port to listen on for debugger to attach to") ->envname("CLOE_DEBUG_LUA_PORT"); @@ -171,6 +172,7 @@ int main(int argc, char** argv) { lua_options.no_system_lua = true; run_options.require_success = true; } + stack_options.environment->prefer_external(false); stack_options.environment->allow_undefined(stack_options.interpolate_undefined); stack_options.environment->insert(CLOE_SIMULATION_UUID_VAR, "${" CLOE_SIMULATION_UUID_VAR "}"); diff --git a/engine/src/main_commands.hpp b/engine/src/main_commands.hpp index f984eed6b..848337a20 100644 --- a/engine/src/main_commands.hpp +++ b/engine/src/main_commands.hpp @@ -67,6 +67,7 @@ struct RunOptions { // Options std::string uuid; + std::string output_path; // Flags: int json_indent = 2; diff --git a/engine/src/main_run.cpp b/engine/src/main_run.cpp index ef9827997..ce7068e3d 100644 --- a/engine/src/main_run.cpp +++ b/engine/src/main_run.cpp @@ -91,6 +91,10 @@ int run(const RunOptions& opt, const std::vector& filepaths) { return EXIT_FAILURE; } + if (!opt.output_path.empty()) { + stack.engine.output_path = opt.output_path; + } + // Create simulation: Simulation sim(std::move(stack), std::move(lua), uuid); GLOBAL_SIMULATION_INSTANCE = ∼