GUI: Print command line help with -h and --help.
This commit is contained in:
parent
a5c12172f9
commit
1752cb62dc
31
gui/main.cpp
31
gui/main.cpp
|
@ -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";
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue