MCPcopy Create free account
hub / github.com/FidoProject/Fido / Session

Class Session

tests/catch.h:6282–6391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6280 }
6281
6282 class Session : NonCopyable {
6283 static bool alreadyInstantiated;
6284
6285 public:
6286
6287 struct OnUnusedOptions { enum DoWhat { Ignore, Fail }; };
6288
6289 Session()
6290 : m_cli( makeCommandLineParser() ) {
6291 if( alreadyInstantiated ) {
6292 std::string msg = "Only one instance of Catch::Session can ever be used";
6293 Catch::cerr() << msg << std::endl;
6294 throw std::logic_error( msg );
6295 }
6296 alreadyInstantiated = true;
6297 }
6298 ~Session() {
6299 Catch::cleanUp();
6300 }
6301
6302 void showHelp( std::string const& processName ) {
6303 Catch::cout() << "\nCatch v" << libraryVersion << "\n";
6304
6305 m_cli.usage( Catch::cout(), processName );
6306 Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
6307 }
6308
6309 int applyCommandLine( int argc, char const* argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
6310 try {
6311 m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
6312 m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
6313 if( m_configData.showHelp )
6314 showHelp( m_configData.processName );
6315 m_config.reset();
6316 }
6317 catch( std::exception& ex ) {
6318 {
6319 Colour colourGuard( Colour::Red );
6320 Catch::cerr()
6321 << "\nError(s) in input:\n"
6322 << Text( ex.what(), TextAttributes().setIndent(2) )
6323 << "\n\n";
6324 }
6325 m_cli.usage( Catch::cout(), m_configData.processName );
6326 return (std::numeric_limits<int>::max)();
6327 }
6328 return 0;
6329 }
6330
6331 void useConfigData( ConfigData const& _configData ) {
6332 m_configData = _configData;
6333 m_config.reset();
6334 }
6335
6336 int run( int argc, char const* argv[] ) {
6337
6338 int returnCode = applyCommandLine( argc, argv );
6339 if( returnCode == 0 )

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected