Config refactoring: split List enum into three bools

This commit is contained in:
Phil Nash 2013-05-29 18:42:46 +01:00
parent 3c3beb57c3
commit c2ca80d9fb
4 changed files with 90 additions and 111 deletions

View file

@ -317,7 +317,7 @@ namespace Catch {
class ListOptionParser : public OptionParser {
public:
ListOptionParser() : OptionParser( 0, 2 ) {
ListOptionParser() : OptionParser( 0, 1 ) {
m_optionNames.push_back( "-l" );
m_optionNames.push_back( "--list" );
}
@ -346,27 +346,21 @@ namespace Catch {
}
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
config.listSpec = List::Tests;
if( cmd.argsCount() >= 1 ) {
if( cmd[0] == "all" )
config.listSpec = List::All;
if( cmd[0] == "all" ) {
config.listTests = true;
config.listTags = true;
config.listReporters = true;
}
else if( cmd[0] == "tests" )
config.listSpec = List::Tests;
config.listTests = true;
else if( cmd[0] == "tags" )
config.listSpec = List::Tags;
config.listTags = true;
else if( cmd[0] == "reporters" )
config.listSpec = List::Reports;
config.listReporters = true;
else
cmd.raiseError( "Expected tests, reporters or tags" );
}
if( cmd.argsCount() >= 2 ) {
if( cmd[1] == "xml" )
config.listSpec = static_cast<List::What>( config.listSpec | List::AsXml );
else if( cmd[1] == "text" )
config.listSpec = static_cast<List::What>( config.listSpec | List::AsText );
else
cmd.raiseError( "Expected xml or text" );
}
}
};