src/cli/RubyCLI.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "./RubyCLI.hpp" | ||
| 7 | #include "../scriptengine/ScriptEngine.hpp" | ||
| 8 | #include <iostream> | ||
| 9 | |||
| 10 | namespace openstudio { | ||
| 11 | |||
| 12 | 14 | int rubyCLI(ScriptEngineInstance& rubyEngine) { | |
| 13 | try { | ||
| 14 |
2/2✓ Branch 1 taken 14 times.
✓ Branch 6 taken 14 times.
|
14 | rubyEngine->exec(R"( |
| 15 | begin | ||
| 16 | require 'openstudio_cli' | ||
| 17 | rescue Exception => e | ||
| 18 | puts | ||
| 19 | puts "Error: #{e.message}" | ||
| 20 | puts "Backtrace:\n\t" + e.backtrace.join("\n\t") | ||
| 21 | raise | ||
| 22 | end | ||
| 23 | )"); | ||
| 24 | ✗ | } catch (const std::exception& e) { | |
| 25 | ✗ | rubyEngine->exec(R"(STDOUT.flush)"); | |
| 26 | ✗ | std::cout << "Exception: " << e.what() << std::endl; // endl will flush | |
| 27 | ✗ | return 1; | |
| 28 | ✗ | } catch (...) { | |
| 29 | ✗ | rubyEngine->exec(R"(STDOUT.flush)"); | |
| 30 | ✗ | std::cout << "Unknown Exception" << std::endl; // endl will flush | |
| 31 | ✗ | return 1; | |
| 32 | ✗ | } | |
| 33 | |||
| 34 |
1/1✓ Branch 4 taken 14 times.
|
14 | rubyEngine->exec(R"(STDOUT.flush)"); |
| 35 | 14 | std::cout << std::flush; | |
| 36 | 14 | return 0; | |
| 37 | } | ||
| 38 | |||
| 39 | } // namespace openstudio | ||
| 40 |