@@ -1001,6 +1001,10 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
10011001 mSettings .outputFile = Path::simplifyPath (argv[i] + 14 );
10021002
10031003 else if (std::strncmp (argv[i], " --output-format=" , 16 ) == 0 ) {
1004+ if (mXmlOptionProvided ) {
1005+ outputFormatOptionMixingError ();
1006+ return Result::Fail;
1007+ }
10041008 const std::string format = argv[i] + 16 ;
10051009 // plist can not be handled here because it requires additional data
10061010 if (format == " text" )
@@ -1014,6 +1018,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
10141018 return Result::Fail;
10151019 }
10161020 mSettings .plistOutput = " " ;
1021+ mOutputFormatOptionProvided = true ;
10171022 }
10181023
10191024
@@ -1486,11 +1491,20 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
14861491
14871492 // Write results in results.xml
14881493 else if (std::strcmp (argv[i], " --xml" ) == 0 ) {
1494+ if (mOutputFormatOptionProvided ) {
1495+ outputFormatOptionMixingError ();
1496+ return Result::Fail;
1497+ }
14891498 mSettings .outputFormat = Settings::OutputFormat::xml;
1499+ mXmlOptionProvided = true ;
14901500 }
14911501
14921502 // Define the XML file version (and enable XML output)
14931503 else if (std::strncmp (argv[i], " --xml-version=" , 14 ) == 0 ) {
1504+ if (mOutputFormatOptionProvided ) {
1505+ outputFormatOptionMixingError ();
1506+ return Result::Fail;
1507+ }
14941508 int tmp;
14951509 if (!parseNumberArg (argv[i], 14 , tmp))
14961510 return Result::Fail;
@@ -1503,6 +1517,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
15031517 mSettings .xml_version = tmp;
15041518 // Enable also XML if version is set
15051519 mSettings .outputFormat = Settings::OutputFormat::xml;
1520+ mXmlOptionProvided = true ;
15061521 }
15071522
15081523 else {
@@ -2149,3 +2164,8 @@ std::list<FileWithDetails> CmdLineParser::filterFiles(const std::vector<std::str
21492164 });
21502165 return files;
21512166}
2167+
2168+ void CmdLineParser::outputFormatOptionMixingError () const
2169+ {
2170+ mLogger .printError (" '--output-format' and '--xml...' may not be used in conjunction." );
2171+ }
0 commit comments