| 19 | namespace cli { |
| 20 | |
| 21 | void setupRunOptions(CLI::App* parentApp, ScriptEngineInstance& ruby, ScriptEngineInstance& python) { |
| 22 | /// Set up a subcommand and capture a shared_ptr to a struct that holds all its options. |
| 23 | /// The variables of the struct are bound to the CLI options. |
| 24 | /// We use a shared ptr so that the addresses of the variables remain for binding, |
| 25 | /// You could return the shared pointer if you wanted to access the values in main. |
| 26 | |
| 27 | // TODO: modify utilities/filetypes/RunOptions.hpp and use that instead |
| 28 | auto opt = std::make_shared<WorkflowRunOptions>(); |
| 29 | |
| 30 | auto* const app = parentApp->add_subcommand("run", "Executes an OpenStudio Workflow file"); |
| 31 | |
| 32 | app->add_option("-w,--workflow", opt->osw_path, "Specify the FILE path to the workflow to run")->option_text("FILE"); |
| 33 | |
| 34 | app->add_flag( |
| 35 | "-m,--measures_only", |
| 36 | [opt](std::int64_t val) { |
| 37 | // fmt::print("val={}\n", val); |
| 38 | opt->no_simulation = (val == 1); |
| 39 | }, |
| 40 | "Only run the OpenStudio and EnergyPlus measures"); |
| 41 | |
| 42 | app->add_flag("-p,--postprocess_only", opt->post_process_only, "Only run the reporting measures"); |
| 43 | |
| 44 | app->add_flag( |
| 45 | "--export-epJSON", [opt](std::int64_t val) { (val != 0) && opt->runOptions.setEpjson((val == 1)); }, |
| 46 | "export epJSON file format. The default is IDF"); |
| 47 | |
| 48 | app->add_option("-s,--socket", opt->socket_port, "Pipe status messages to a socket on localhost PORT")->option_text("PORT"); |
| 49 | |
| 50 | auto* stdout_opt = |
| 51 | app->add_flag("--show-stdout", opt->show_stdout, "Prints the output of the workflow run in real time to the console, including E+ output") |
| 52 | ->group("Stdout Options"); |
| 53 | app->add_flag("--add-timings", opt->add_timings, "Print the start, end and elapsed times of each state of the simulation.") |
| 54 | ->needs(stdout_opt) |
| 55 | ->group("Stdout Options"); |
| 56 | app |
| 57 | ->add_flag("--style-stdout", opt->style_stdout, |
| 58 | "Style the stdout output to more clearly show the start and end of each state of the simulation.") |
| 59 | ->needs(stdout_opt) |
| 60 | ->group("Stdout Options"); |
| 61 | |
| 62 | app->add_flag( |
| 63 | "--debug", [opt](std::int64_t val) { (val != 0) && opt->runOptions.setDebug((val == 1)); }, |
| 64 | "Includes additional outputs for debugging failing workflows and does not clean up the run directory"); |
| 65 | |
| 66 | // FT options |
| 67 | static constexpr auto ftGroupName = "Forward Translator Options"; |
| 68 | app |
| 69 | ->add_flag( |
| 70 | "--runcontrolspecialdays,!--no-runcontrolspecialdays", |
| 71 | [opt](std::int64_t val) { |
| 72 | if (val != 0) { |
| 73 | opt->runOptions.forwardTranslatorOptions().setKeepRunControlSpecialDays((val == 1)); |
| 74 | } |
| 75 | }, |
| 76 | "Include RunControlSpecialDays (Holidays) [Default: True]") |
| 77 | ->group(ftGroupName); |
| 78 |
no test coverage detected