Skip to content

Commit

Permalink
engine: Add --output-path to cloe-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
CzBalti committed Apr 26, 2024
1 parent 25c8196 commit e7d307c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions engine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 "}");
Expand Down
1 change: 1 addition & 0 deletions engine/src/main_commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct RunOptions {

// Options
std::string uuid;
std::string output_path;

// Flags:
int json_indent = 2;
Expand Down
4 changes: 4 additions & 0 deletions engine/src/main_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ int run(const RunOptions& opt, const std::vector<std::string>& 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 = &sim;
Expand Down

0 comments on commit e7d307c

Please sign in to comment.