cmdlineparser: add support for --template=
The GNU standard for long command line options is --option=value. All other long options of cppcheck support this, so add it for the template option, too. --template xxx can be made obsolete later. Should the documentation and tests also be changed now? Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
93b1bba8cb
commit
76dda36b64
|
@ -410,15 +410,20 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output formatter
|
// Output formatter
|
||||||
else if (strcmp(argv[i], "--template") == 0) {
|
else if (strcmp(argv[i], "--template") == 0 ||
|
||||||
|
strncmp(argv[i], "--template=", 11) == 0) {
|
||||||
// "--template path/"
|
// "--template path/"
|
||||||
++i;
|
if (argv[i][10] == '=')
|
||||||
if (i >= argc) {
|
_settings->_outputFormat = argv[i] + 11;
|
||||||
|
else {
|
||||||
|
++i;
|
||||||
|
_settings->_outputFormat = (argv[i] ? argv[i] : "");
|
||||||
|
}
|
||||||
|
if (_settings->_outputFormat.empty()) {
|
||||||
PrintMessage("cppcheck: argument to '--template' is missing.");
|
PrintMessage("cppcheck: argument to '--template' is missing.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_settings->_outputFormat = argv[i];
|
|
||||||
if (_settings->_outputFormat == "gcc")
|
if (_settings->_outputFormat == "gcc")
|
||||||
_settings->_outputFormat = "{file}:{line}: {severity}: {message}";
|
_settings->_outputFormat = "{file}:{line}: {severity}: {message}";
|
||||||
else if (_settings->_outputFormat == "vs")
|
else if (_settings->_outputFormat == "vs")
|
||||||
|
|
Loading…
Reference in New Issue