Fix Ticket #46, invalid commandline. (Also added -h and --help parameters)
This commit is contained in:
parent
67e4ea10c9
commit
5de5eab9fe
|
@ -103,11 +103,12 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>&dhpackage;</command>
|
<command>&dhpackage;</command>
|
||||||
<arg choice="opt"><option>--all</option></arg>
|
<arg choice="opt"><option>--all</option></arg>
|
||||||
<arg choice="opt"><option>--quiet</option></arg>
|
<arg choice="opt"><option>--force</option></arg>
|
||||||
|
<arg choice="opt"><option>--help</option></arg>
|
||||||
<arg choice="opt"><option>-Idir</option></arg>
|
<arg choice="opt"><option>-Idir</option></arg>
|
||||||
|
<arg choice="opt"><option>--quiet</option></arg>
|
||||||
<arg choice="opt"><option>--style</option></arg>
|
<arg choice="opt"><option>--style</option></arg>
|
||||||
<arg choice="opt"><option>--verbose</option></arg>
|
<arg choice="opt"><option>--verbose</option></arg>
|
||||||
<arg choice="opt"><option>--force</option></arg>
|
|
||||||
<arg choice="opt"><option>file or path</option></arg>
|
<arg choice="opt"><option>file or path</option></arg>
|
||||||
<arg choice="plain"><option>...</option></arg>
|
<arg choice="plain"><option>...</option></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
|
@ -142,6 +143,13 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
||||||
default.</para>
|
default.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-h</option></term>
|
||||||
|
<term><option>--help</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Print help text.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-I <dir></option></term>
|
<term><option>-I <dir></option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
|
@ -95,6 +95,14 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
||||||
else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--force") == 0)
|
else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--force") == 0)
|
||||||
_settings._force = true;
|
_settings._force = true;
|
||||||
|
|
||||||
|
// Print help
|
||||||
|
else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
||||||
|
{
|
||||||
|
pathnames.clear();
|
||||||
|
_filenames.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Include paths
|
// Include paths
|
||||||
else if (strcmp(argv[i], "-I") == 0 || strncmp(argv[i], "-I", 2) == 0)
|
else if (strcmp(argv[i], "-I") == 0 || strncmp(argv[i], "-I", 2) == 0)
|
||||||
{
|
{
|
||||||
|
@ -124,6 +132,11 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
||||||
_includePaths.push_back(path);
|
_includePaths.push_back(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (strncmp(argv[i], "-", 1) == 0 || strncmp(argv[i], "--", 2) == 0)
|
||||||
|
{
|
||||||
|
return "cppcheck: error: unrecognized command line option \"" + std::string(argv[i]) + "\"\n";
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
pathnames.push_back(argv[i]);
|
pathnames.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +157,8 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
||||||
"A tool for static C/C++ code analysis\n"
|
"A tool for static C/C++ code analysis\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Syntax:\n"
|
"Syntax:\n"
|
||||||
" cppcheck [--all] [--force] [-Idir] [--quiet] [--style] [--verbose] [file or path1] [file or path]\n"
|
" cppcheck [--all] [--force] [--help] [-Idir] [--quiet] [--style]\n"
|
||||||
|
" [--verbose] [file or path1] [file or path]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n"
|
"If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n"
|
||||||
"are checked recursively from given directory.\n\n"
|
"are checked recursively from given directory.\n\n"
|
||||||
|
@ -152,6 +166,7 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
||||||
" -a, --all Make the checking more sensitive. More bugs are detected,\n"
|
" -a, --all Make the checking more sensitive. More bugs are detected,\n"
|
||||||
" but there are also more false positives\n"
|
" but there are also more false positives\n"
|
||||||
" -f, --force Force checking on files that have \"too many\" configurations\n"
|
" -f, --force Force checking on files that have \"too many\" configurations\n"
|
||||||
|
" -h, --help Print this help\n"
|
||||||
" -I <dir> Give include path. Give several -I parameters to give several\n"
|
" -I <dir> Give include path. Give several -I parameters to give several\n"
|
||||||
" paths. First given path is checked first. If paths are\n"
|
" paths. First given path is checked first. If paths are\n"
|
||||||
" relative to source files, this is not needed.\n"
|
" relative to source files, this is not needed.\n"
|
||||||
|
|
Loading…
Reference in New Issue