Fix ticket #137 (--version would be nice) and also do some cleanup for help texts

http://apps.sourceforge.net/trac/cppcheck/ticket/137
This commit is contained in:
Reijo Tomperi 2009-03-06 23:17:42 +02:00
parent d725f0df58
commit 1ab57390cf
2 changed files with 20 additions and 11 deletions

View File

@ -107,11 +107,12 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
<arg choice="opt"><option>--force</option></arg> <arg choice="opt"><option>--force</option></arg>
<arg choice="opt"><option>--help</option></arg> <arg choice="opt"><option>--help</option></arg>
<arg choice="opt"><option>-I[dir]</option></arg> <arg choice="opt"><option>-I[dir]</option></arg>
<arg choice="opt"><option>-j[jobs]</option></arg>
<arg choice="opt"><option>--quiet</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>--unused-functions</option></arg> <arg choice="opt"><option>--unused-functions</option></arg>
<arg choice="opt"><option>--verbose</option></arg> <arg choice="opt"><option>--verbose</option></arg>
<arg choice="opt"><option>-j[jobs]</option></arg> <arg choice="opt"><option>--version</option></arg>
<arg choice="opt"><option>--xml</option></arg> <arg choice="opt"><option>--xml</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>
@ -170,6 +171,12 @@ default.</para>
files, this is not needed.</para> files, this is not needed.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-j [jobs]</option></term>
<listitem>
<para>Start [jobs] threads to do the checking work.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-q</option></term> <term><option>-q</option></term>
<term><option>--quiet</option></term> <term><option>--quiet</option></term>
@ -198,9 +205,9 @@ files, this is not needed.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>-j [jobs]</option></term> <term><option>--version</option></term>
<listitem> <listitem>
<para>Start [jobs] threads to do the checking work.</para> <para>Print out version information</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -78,6 +78,9 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
bool showHelp = false; bool showHelp = false;
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
{ {
if (strcmp(argv[i], "--version") == 0)
return "Cppcheck 1.29\n";
// Flag used for various purposes during debugging // Flag used for various purposes during debugging
if (strcmp(argv[i], "--debug") == 0) if (strcmp(argv[i], "--debug") == 0)
_settings._debug = true; _settings._debug = true;
@ -226,18 +229,16 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
FileLister::RecursiveAddFiles(_filenames, iter->c_str(), true); FileLister::RecursiveAddFiles(_filenames, iter->c_str(), true);
} }
if (argc <= 1 || showHelp) if (argc <= 1 || showHelp)
{ {
std::ostringstream oss; std::ostringstream oss;
oss << "Cppcheck 1.28\n" oss << "Cppcheck - A tool for static C/C++ code analysis\n"
"\n"
"A tool for static C/C++ code analysis\n"
"\n" "\n"
"Syntax:\n" "Syntax:\n"
" cppcheck [--all] [--force] [--help] [-Idir] [--quiet] [--style]\n" " cppcheck [--all] [--error-exitcode=[n]] [--force] [--help] \n"
" [--unused-functions] [--verbose] [--xml]\n" " [-Idir] [-j [jobs]] [--quiet] [--style] \n"
" [file or path1] [file or path]\n" " [--unused-functions] [--verbose] [--version] [--xml] \n"
" [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"
@ -255,11 +256,12 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
" -I [dir] Give include path. Give several -I parameters to give\n" " -I [dir] Give include path. Give several -I parameters to give\n"
" several paths. First given path is checked first. If\n" " several paths. First given path is checked first. If\n"
" paths are relative to source files, this is not needed\n" " paths are relative to source files, this is not needed\n"
" -j [jobs] Start [jobs] threads to do the checking simultaneously.\n"
" -q, --quiet Only print error messages\n" " -q, --quiet Only print error messages\n"
" -s, --style Check coding style\n" " -s, --style Check coding style\n"
" --unused-functions Check if there are unused functions\n" " --unused-functions Check if there are unused functions\n"
" -v, --verbose More detailed error reports\n" " -v, --verbose More detailed error reports\n"
" -j [jobs] Start [jobs] threads to do the checking simultaneously.\n" " --version Print out version number\n"
" --xml Write results in xml to error stream.\n" " --xml Write results in xml to error stream.\n"
"\n" "\n"
"Example usage:\n" "Example usage:\n"