Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
shorowit opened this issue Dec 11, 2023 · 1 comment · Fixed by #5065
Closed

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

shorowit opened this issue Dec 11, 2023 · 1 comment · Fixed by #5065
Assignees

Comments

@shorowit
Copy link
Contributor

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):

  • Ubuntu 20.04
  • OpenStudio 3.7.0
@shorowit shorowit added the Triage Issue needs to be assessed and labeled, further information on reported might be needed label Dec 11, 2023
@shorowit
Copy link
Contributor Author

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.

@jmarrec jmarrec added component - CLI and removed Triage Issue needs to be assessed and labeled, further information on reported might be needed labels Dec 19, 2023
@jmarrec jmarrec self-assigned this Dec 19, 2023
jmarrec added a commit that referenced this issue Dec 20, 2023
```
	3730 - OpenStudioCLI.execute_ruby_script.forward_flags.forward_help (Failed)
	3731 - OpenStudioCLI.execute_python_script.forward_flags.forward_help (Failed)
```
jmarrec added a commit that referenced this issue Dec 20, 2023
When script omitted, --help displays the C++ subcommand help

```
$os_build_rel/Products/openstudio execute_ruby_script --help
Executes a ruby file
Usage: /Users/julien/Software/Others/OS-build-release/Products/openstudio execute_ruby_script [OPTIONS] path [args...]

Positionals:
  path RUBY_SCRIPT                 Path to Ruby file
  args ARG ...                     Extra Arguments forwarded to the Ruby script

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

Any additional arguments passed after the Ruby file are forwarded
```

When --help is passed after the ruby script, the Ruby's script is displayed (if any):

```
$os_build_rel/Products/openstudio execute_ruby_script execute_ruby_script_optparse_path.rb --help
Usage: execute_ruby_script_optparse_path.rb -x building.xml

The Ruby help description.

    -x, --xml <FILE>                 HPXML file
```
jmarrec added a commit that referenced this issue Jan 2, 2024
Fix #5062 - Properly forward the --help flag to ruby/python scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants