NREL / OpenStudio

OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance.
https://www.openstudio.net/
Other
505 stars 192 forks source link

OS 3.7 CLI regression for `openstudio foo.rb --help` #5062

Closed shorowit closed 10 months ago

shorowit commented 11 months ago

Issue overview

As tested with OpenStudio-HPXML, the --help argument is not correctly passed to the ruby script that is being executed.

Current Behavior

With OpenStudio 3.7, the CLI itself processes the --help argument:

$ openstudio workflow/run_simulation.rb --help
Executes a ruby file
Usage: openstudio execute_ruby_script [OPTIONS] path

Positionals:
  path TEXT:FILE REQUIRED          Path to ruby file

Options:
  -h,--help                        Print this help message and exit

You can pass extra arguments after the ruby file, they will be forwarded.

Expected Behavior

I'd expect it to work the same way it did in OpenStudio 3.6 where our ruby script receives the --help argument.

$ openstudio workflow/run_simulation.rb --help
Usage: run_simulation.rb -x building.xml
    -x, --xml <FILE>                 HPXML file
    -o, --output-dir <DIR>           Output directory
        --output-format TYPE         Output file format type (csv, json, msgpack, csv_dview)
        --hourly TYPE                Request hourly output type (ALL, total, fuels, enduses, systemuses, emissions, emissionfuels, emissionenduses, hotwater, loads, componentloads, unmethours, temperatures, airflows, weather, resilience); can be called multiple times
        --daily TYPE                 Request daily output type (ALL, total, fuels, enduses, systemuses, emissions, emissionfuels, emissionenduses, hotwater, loads, componentloads, unmethours, temperatures, airflows, weather, resilience); can be called multiple times
        --monthly TYPE               Request monthly output type (ALL, total, fuels, enduses, systemuses, emissions, emissionfuels, emissionenduses, hotwater, loads, componentloads, unmethours, temperatures, airflows, weather, resilience); can be called multiple times
        --timestep TYPE              Request timestep output type (ALL, total, fuels, enduses, systemuses, emissions, emissionfuels, emissionenduses, hotwater, loads, componentloads, unmethours, temperatures, airflows, weather, resilience); can be called multiple times
    -s, --skip-validation            Skip Schema/Schematron validation for faster performance
        --add-component-loads        Add heating/cooling component loads calculation
        --add-stochastic-schedules   Add detailed stochastic occupancy schedules
    -t NAME,                         Add timeseries output variable; can be called multiple times
        --add-timeseries-output-variable
        --ep-input-format TYPE       EnergyPlus input file format (idf, epjson)
    -b, --building-id ID             ID of Building to simulate (required when multiple HPXML Building elements); use "ALL" to simulate a single whole MF building
    -v, --version                    Reports the version
    -d, --debug                      Generate additional debug output/files
    -h, --help                       Display help

Possible Solution

I would think that any argument after foo.rb should be forwarded to, and processed by, the ruby script.

Details

Environment

Some additional details about your environment for this issue (if relevant):

shorowit commented 11 months ago

After discussing with @jmarrec, he's going to see if we can allow openstudio execute_ruby_script --help to continue working like it does, but forward the --help argument when a ruby script is included in the command (e.g. openstudio execute_ruby_script foo.rb --help). He says it might require disabling CLI11's default --help and handling it conditionally, but should be doable.