fixed #11919 - Removed deprecated command-line options `--template <template>` and `--template-format=<template>` (#5439)
This commit is contained in:
parent
a87e9e1042
commit
98ce46a3e5
|
@ -898,20 +898,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
}
|
||||
|
||||
// Output formatter
|
||||
else if (std::strcmp(argv[i], "--template") == 0 ||
|
||||
std::strncmp(argv[i], "--template=", 11) == 0) {
|
||||
// "--template format"
|
||||
if (argv[i][10] == '=')
|
||||
mSettings.templateFormat = argv[i] + 11;
|
||||
else if ((i+1) < argc && argv[i+1][0] != '-') {
|
||||
printMessage("'--template <template>' is deprecated and will be removed in 2.13 - please use '--template=<template>' instead");
|
||||
++i;
|
||||
mSettings.templateFormat = argv[i];
|
||||
} else {
|
||||
printError("argument to '--template' is missing.");
|
||||
return false;
|
||||
}
|
||||
// TODO: bail out when no placeholders are found?
|
||||
else if (std::strncmp(argv[i], "--template=", 11) == 0) {
|
||||
mSettings.templateFormat = argv[i] + 11;
|
||||
// TODO: bail out when no template is provided?
|
||||
|
||||
if (mSettings.templateFormat == "gcc") {
|
||||
mSettings.templateFormat = "{bold}{file}:{line}:{column}: {magenta}warning:{default} {message} [{id}]{reset}\\n{code}";
|
||||
|
@ -931,21 +920,12 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
mSettings.templateLocation = "{file}:{line}:{column}: note: {info}\\n{code}";
|
||||
mSettings.daca = true;
|
||||
}
|
||||
// TODO: bail out when no placeholders are found?
|
||||
}
|
||||
|
||||
else if (std::strcmp(argv[i], "--template-location") == 0 ||
|
||||
std::strncmp(argv[i], "--template-location=", 20) == 0) {
|
||||
// "--template-location format"
|
||||
if (argv[i][19] == '=')
|
||||
mSettings.templateLocation = argv[i] + 20;
|
||||
else if ((i+1) < argc && argv[i+1][0] != '-') {
|
||||
printMessage("'--template-location <template>' is deprecated and will be removed in 2.13 - please use '--template-location=<template>' instead");
|
||||
++i;
|
||||
mSettings.templateLocation = argv[i];
|
||||
} else {
|
||||
printError("argument to '--template-location' is missing.");
|
||||
return false;
|
||||
}
|
||||
else if (std::strncmp(argv[i], "--template-location=", 20) == 0) {
|
||||
mSettings.templateLocation = argv[i] + 20;
|
||||
// TODO: bail out when no template is provided?
|
||||
// TODO: bail out when no placeholders are found?
|
||||
}
|
||||
|
||||
|
|
|
@ -14,3 +14,4 @@ Changed interface:
|
|||
|
||||
Other:
|
||||
- Windows builds now default to the `native` platform instead of `win32A` or `win64`. Please specify it explicitly if you depedent on it.
|
||||
- The undocumented and deprecated command-line options `--template <template>` and `--template-format <template>` has been removed. Please use `--template=` and `--template-format=` instead.
|
|
@ -179,10 +179,8 @@ private:
|
|||
TEST_CASE(templatesSelfcheck);
|
||||
TEST_CASE(templatesNoPlaceholder);
|
||||
TEST_CASE(templateFormatInvalid);
|
||||
TEST_CASE(templateFormatInvalid2);
|
||||
TEST_CASE(templateFormatEmpty);
|
||||
TEST_CASE(templateLocationInvalid);
|
||||
TEST_CASE(templateLocationInvalid2);
|
||||
TEST_CASE(templateLocationEmpty);
|
||||
TEST_CASE(xml);
|
||||
TEST_CASE(xmlver2);
|
||||
|
@ -1416,24 +1414,12 @@ private:
|
|||
}
|
||||
|
||||
void templateFormatInvalid() {
|
||||
REDIRECT;
|
||||
const char* const argv[] = { "cppcheck", "--template", "--template-location={file}", "file.cpp" };
|
||||
ASSERT(!parser->parseFromArgs(4, argv));
|
||||
ASSERT_EQUALS("cppcheck: error: argument to '--template' is missing.\n", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
// TODO: will not error out as he next option does not start with a "-"
|
||||
void templateFormatInvalid2() {
|
||||
REDIRECT;
|
||||
settings->templateFormat.clear();
|
||||
settings->templateLocation.clear();
|
||||
const char* const argv[] = { "cppcheck", "--template", "file.cpp" };
|
||||
ASSERT(!parser->parseFromArgs(3, argv));
|
||||
ASSERT_EQUALS("file.cpp", settings->templateFormat);
|
||||
ASSERT_EQUALS("", settings->templateLocation);
|
||||
TODO_ASSERT_EQUALS("cppcheck: error: argument to '--template' is missing.\n",
|
||||
"cppcheck: '--template <template>' is deprecated and will be removed in 2.13 - please use '--template=<template>' instead\n"
|
||||
"cppcheck: error: no C or C++ source files found.\n", GET_REDIRECT_OUTPUT);
|
||||
ASSERT_EQUALS("cppcheck: error: unrecognized command line option: \"--template\".\n", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
// will use the default
|
||||
|
@ -1453,21 +1439,7 @@ private:
|
|||
REDIRECT;
|
||||
const char* const argv[] = { "cppcheck", "--template-location", "--template={file}", "file.cpp" };
|
||||
ASSERT(!parser->parseFromArgs(4, argv));
|
||||
ASSERT_EQUALS("cppcheck: error: argument to '--template-location' is missing.\n", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
// TODO: will not error out as the next option does not start with a "-"
|
||||
void templateLocationInvalid2() {
|
||||
REDIRECT;
|
||||
settings->templateFormat.clear();
|
||||
settings->templateLocation.clear();
|
||||
const char* const argv[] = { "cppcheck", "--template-location", "file.cpp" };
|
||||
ASSERT(!parser->parseFromArgs(3, argv));
|
||||
ASSERT_EQUALS("{file}:{line}:{column}: {inconclusive:}{severity}:{inconclusive: inconclusive:} {message} [{id}]\n{code}", settings->templateFormat);
|
||||
ASSERT_EQUALS("file.cpp", settings->templateLocation);
|
||||
TODO_ASSERT_EQUALS("",
|
||||
"cppcheck: '--template-location <template>' is deprecated and will be removed in 2.13 - please use '--template-location=<template>' instead\n"
|
||||
"cppcheck: error: no C or C++ source files found.\n", GET_REDIRECT_OUTPUT);
|
||||
ASSERT_EQUALS("cppcheck: error: unrecognized command line option: \"--template-location\".\n", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
// will use the default
|
||||
|
|
Loading…
Reference in New Issue