Implement -v and --version for GUI
This commit is contained in:
parent
d7a52eaecd
commit
dc88f20201
31
gui/main.cpp
31
gui/main.cpp
|
@ -16,7 +16,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
@ -29,8 +28,11 @@
|
||||||
#endif
|
#endif
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "erroritem.h"
|
#include "erroritem.h"
|
||||||
|
#include "cppcheck.h"
|
||||||
|
|
||||||
|
|
||||||
void ShowUsage();
|
void ShowUsage();
|
||||||
|
void ShowVersion();
|
||||||
bool CheckArgs(const QStringList &args);
|
bool CheckArgs(const QStringList &args);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -65,6 +67,10 @@ bool CheckArgs(const QStringList &args)
|
||||||
ShowUsage();
|
ShowUsage();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (args.contains("-v") || args.contains("--version")) {
|
||||||
|
ShowVersion();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +84,8 @@ void ShowUsage()
|
||||||
" -h, --help Print this help\n"
|
" -h, --help Print this help\n"
|
||||||
" -p <file> Open given project file and start checking it\n"
|
" -p <file> Open given project file and start checking it\n"
|
||||||
" -l <file> Open given results xml file\n"
|
" -l <file> Open given results xml file\n"
|
||||||
" -d <directory> Specify the directory that was checked to generate the results xml specified with -l\n";
|
" -d <directory> Specify the directory that was checked to generate the results xml specified with -l\n"
|
||||||
|
" -v, --version Show program version\n";
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
QMessageBox msgBox(QMessageBox::Information,
|
QMessageBox msgBox(QMessageBox::Information,
|
||||||
"Cppcheck GUI",
|
"Cppcheck GUI",
|
||||||
|
@ -90,3 +97,23 @@ void ShowUsage()
|
||||||
std::cout << helpMessage;
|
std::cout << helpMessage;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShowVersion()
|
||||||
|
{
|
||||||
|
std::string versionMessage("Cppcheck ");
|
||||||
|
versionMessage += CppCheck::version();
|
||||||
|
const char * extraVersion = CppCheck::extraVersion();
|
||||||
|
if (*extraVersion != 0)
|
||||||
|
versionMessage += std::string(" (") + extraVersion + ")";
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
QMessageBox msgBox(QMessageBox::Information,
|
||||||
|
"Cppcheck GUI",
|
||||||
|
versionMessage.c_str(),
|
||||||
|
QMessageBox::Ok
|
||||||
|
);
|
||||||
|
(void)msgBox.exec();
|
||||||
|
#else
|
||||||
|
std::cout << versionMessage << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue