GUI: Print command line help with -h and --help.

This commit is contained in:
Kimmo Varis 2011-04-07 16:07:55 +03:00
parent a5c12172f9
commit 1752cb62dc
1 changed files with 31 additions and 0 deletions

View File

@ -21,12 +21,21 @@
#include <QTextCodec> #include <QTextCodec>
#include <QTranslator> #include <QTranslator>
#include <QMetaType> #include <QMetaType>
#include <QStringList>
#include <iostream>
#include "mainwindow.h" #include "mainwindow.h"
#include "erroritem.h" #include "erroritem.h"
void ShowUsage();
bool CheckArgs(const QStringList &args);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
if (!CheckArgs(app.arguments()))
return 0;
app.setWindowIcon(QIcon(":icon.png")); app.setWindowIcon(QIcon(":icon.png"));
// Register this metatype that is used to transfer error info // Register this metatype that is used to transfer error info
@ -40,3 +49,25 @@ int main(int argc, char *argv[])
window.show(); window.show();
return app.exec(); return app.exec();
} }
// Check only arguments needing action before GUI is shown.
// Rest of the arguments are handled in MainWindow::HandleCLIParams()
bool CheckArgs(const QStringList &args)
{
if (args.contains("-h") || args.contains("--help"))
{
ShowUsage();
return false;
}
return true;
}
void ShowUsage()
{
std::cout << "Cppcheck GUI.\n\n";
std::cout << "Syntax:\n";
std::cout << " cppcheck-gui [OPTIONS] [files or paths]\n\n";
std::cout << "Options:\n";
std::cout << " -h, --help Print this help\n";
std::cout << " -p <file> Open given project file and start checking it\n";
}