Wire Sysio Wire Sysion 1.0.0
|
Contents
Let Catch take full control of args and config
Amending the config
Adding your own command line options
Version detection
The easiest way to use Catch is to let it supply main()
for you and handle configuring itself from the command line.
This is achieved by writing #define CATCH_CONFIG_MAIN
before the #include "catch.hpp"
in exactly one source file.
Sometimes, though, you need to write your own version of main(). You can do this by writing #define CATCH_CONFIG_RUNNER
instead. Now you are free to write main()
as normal and call into Catch yourself manually.
You now have a lot of flexibility - but here are three recipes to get your started:
If you just need to have code that executes before and/ or after Catch this is the simplest option.
If you still want Catch to process the command line, but you want to programmatically tweak the config, you can do so in one of two ways:
Take a look at the definitions of Config and ConfigData to see what you can do with them.
To take full control of the config simply omit the call to applyCommandLine()
.
Catch embeds a powerful command line parser called Clara. As of Catch2 (and Clara 1.0) Clara allows you to write composable option and argument parsers, so extending Catch's own command line options is now easy.
See the Clara documentation for more details.
Catch provides a triplet of macros providing the header's version,
CATCH_VERSION_MAJOR
CATCH_VERSION_MINOR
CATCH_VERSION_PATCH
these macros expand into a single number, that corresponds to the appropriate part of the version. As an example, given single header version v2.3.4, the macros would expand into 2
, 3
, and 4
respectively.