| 14 | #include <iostream> |
| 15 | |
| 16 | int main(int argc, char** argv) { |
| 17 | Catch::Session session; // There must be exactly one instance |
| 18 | |
| 19 | int height = 0; // Some user variable you want to be able to set |
| 20 | |
| 21 | // Build a new parser on top of Catch2's |
| 22 | using namespace Catch::Clara; |
| 23 | auto cli |
| 24 | = session.cli() // Get Catch2's command line parser |
| 25 | | Opt( height, "height" ) // bind variable to a new option, with a hint string |
| 26 | ["--height"] // the option names it will respond to |
| 27 | ("how high?"); // description string for the help output |
| 28 | |
| 29 | // Now pass the new composite back to Catch2 so it uses that |
| 30 | session.cli( cli ); |
| 31 | |
| 32 | // Let Catch2 (using Clara) parse the command line |
| 33 | int returnCode = session.applyCommandLine( argc, argv ); |
| 34 | if( returnCode != 0 ) // Indicates a command line error |
| 35 | return returnCode; |
| 36 | |
| 37 | // if set on the command line then 'height' is now set at this point |
| 38 | std::cout << "height: " << height << '\n'; |
| 39 | |
| 40 | return session.run(); |
| 41 | } |
nothing calls this directly
no test coverage detected