Added help option

This commit is contained in:
Phil Nash
2010-12-30 18:51:02 +00:00
parent c60156ad11
commit 27fdf01b76
3 changed files with 45 additions and 5 deletions

View File

@@ -19,10 +19,10 @@
namespace Catch
{
// -l, --list tests [xml] lists available tests (optionally in xml)
// -l, --list reports [xml] lists available reports (optionally in xml)
// -l, --list reporters [xml] lists available reports (optionally in xml)
// -l, --list all [xml] lists available tests and reports (optionally in xml)
// -t, --test "testspec" ["testspec", ...]
// -r, --report <type>
// -r, --reporter <type>
// -o, --out filename to write to
// -s, --success report successful cases too
// -b, --break breaks into debugger on test failure
@@ -37,6 +37,7 @@ namespace Catch
modeOutput,
modeSuccess,
modeBreak,
modeHelp,
modeError
};
@@ -55,7 +56,7 @@ namespace Catch
changeMode( cmd, modeList );
else if( cmd == "-t" || cmd == "--test" )
changeMode( cmd, modeTest );
else if( cmd == "-r" || cmd == "--report" )
else if( cmd == "-r" || cmd == "--reporter" )
changeMode( cmd, modeReport );
else if( cmd == "-o" || cmd == "--out" )
changeMode( cmd, modeOutput );
@@ -63,6 +64,8 @@ namespace Catch
changeMode( cmd, modeSuccess );
else if( cmd == "-b" || cmd == "--break" )
changeMode( cmd, modeBreak );
else if( cmd == "-h" || cmd == "-?" || cmd == "--help" )
changeMode( cmd, modeHelp );
}
else
{
@@ -157,7 +160,12 @@ namespace Catch
return setErrorMode( m_command + " does not accept arguments" );
m_config.setShouldDebugBreak( true );
break;
default:
case modeHelp:
if( m_args.size() != 0 )
return setErrorMode( m_command + " does not accept arguments" );
m_config.setShowHelp( true );
break;
default:
break;
}
m_args.clear();

View File

@@ -45,7 +45,8 @@ namespace Catch
RunnerConfig()
: m_reporter( NULL ),
m_listSpec( listNone ),
m_shouldDebugBreak( false )
m_shouldDebugBreak( false ),
m_showHelp( false )
{}
void setReporterInfo( const std::string& reporterName )
@@ -122,6 +123,15 @@ namespace Catch
{
return m_shouldDebugBreak;
}
void setShowHelp( bool showHelp )
{
m_showHelp = showHelp;
}
bool showHelp() const
{
return m_showHelp;
}
std::auto_ptr<ITestReporter> m_reporter;
std::string m_filename;
@@ -130,6 +140,7 @@ namespace Catch
ListInfo m_listSpec;
std::vector<std::string> m_testSpecs;
bool m_shouldDebugBreak;
bool m_showHelp;
};
} // end namespace Catch